]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
tests & docs & twipsy too
authorRod Vagg <rod@vagg.org>
Sun, 6 Nov 2011 02:20:09 +0000 (13:20 +1100)
committerRod Vagg <rod@vagg.org>
Sun, 6 Nov 2011 02:20:09 +0000 (13:20 +1100)
docs/javascript.html
js/bootstrap-twipsy.js
js/tests/unit/bootstrap-popover.js
js/tests/unit/bootstrap-twipsy.js

index 82dcffba75724f91937073bfd2805efb998e5e7f..90b7be0c5365638fb80be6e32786d0f9539ef1fd 100644 (file)
@@ -487,8 +487,8 @@ $('#.tabs').bind('change', function (e) {
             <thead>
              <tr>
                <th style="width: 100px;">Name</th>
-               <th style="width: 100px;">type</th>
-               <th style="width: 50px;">default</th>
+               <th style="width: 95px;">type</th>
+               <th style="width: 95px;">default</th>
                <th>description</th>
              </tr>
             </thead>
@@ -557,7 +557,13 @@ $('#.tabs').bind('change', function (e) {
                <td>template</td>
                <td>string</td>
                <td>[default markup]</td>
-               <td>The html template used for rendering a twipsy.</td>
+               <td>the html template used for rendering a twipsy</td>
+             </tr>
+             <tr>
+               <td>contentSelector</td>
+               <td>string</td>
+               <td>.twipsy-inner</td>
+               <td>selector used to find the title element within the tooltip</td>
              </tr>
             </tbody>
           </table>
@@ -613,8 +619,8 @@ $('#.tabs').bind('change', function (e) {
             <thead>
              <tr>
                <th style="width: 100px;">Name</th>
-               <th style="width: 100px;">type</th>
-               <th style="width: 50px;">default</th>
+               <th style="width: 95px;">type</th>
+               <th style="width: 95px;">default</th>
                <th>description</th>
              </tr>
             </thead>
@@ -689,7 +695,19 @@ $('#.tabs').bind('change', function (e) {
                <td>template</td>
                <td>string</td>
                <td>[default markup]</td>
-               <td>The html template used for rendering a popover.</td>
+               <td>the html template used for rendering a popover</td>
+             </tr>
+             <tr>
+               <td>titleSelector</td>
+               <td>string</td>
+               <td>.title</td>
+               <td>selector used to find the title element within the popover</td>
+             </tr>
+             <tr>
+               <td>contentSelector</td>
+               <td>string</td>
+               <td>.content p</td>
+               <td>selector used to find the content element within the popover</td>
              </tr>
             </tbody>
           </table>
index e249c815d714fcb67b5671824d35fe9af03c6aea..9eb6e79f4e5da346c214ae62aba0cace7386b723 100644 (file)
 
   , setContent: function () {
       var $tip = this.tip()
-      $tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
+      $tip.find(this.options.contentSelector)[this.options.html ? 'html' : 'text'](this.getTitle())
       $tip[0].className = 'twipsy'
     }
 
   , title: 'title'
   , trigger: 'hover'
   , template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
+  , contentSelector: '.twipsy-inner'
   }
 
   $.fn.twipsy.elementOptions = function(ele, options) {
     return $.extend({}, options, $(ele).data())
   }
 
-}( window.jQuery || window.ender );
\ No newline at end of file
+}( window.jQuery || window.ender );
index 3e13d2fd206ed31ba3035e6aade2e49ecf4a1b85..69f3e0d7fa1ed5ea5a84be2d34a0c1646ac699ec 100644 (file)
@@ -73,4 +73,27 @@ $(function () {
         $('#qunit-runoff').empty()
       })
 
-})
\ No newline at end of file
+      test("should allow arbitrary template html with title and content selector options", function() {
+        $.support.transition = false
+        var expectedTitle = 'Gotta make you understand'
+          , popover = $('<a href="#">@rvagg</a>')
+              .attr('title', expectedTitle)
+              .data('content', '<p><b>Never gonna give you up</b>,</p><p>Never gonna let you down</p>')
+              .appendTo('#qunit-runoff')
+              .popover({
+                    html: true
+                  , titleSelector: 'h1'
+                  , contentSelector: '.rick > .roll'
+                  , template: '<div class="rick"><h1></h1><div class="roll"></div></div>'
+                })
+              .popover('show')
+
+        ok($('.popover > div > h1').length, 'h1 tag was inserted')
+        ok($('.popover > div > h1').text() === expectedTitle)
+        ok($('.popover > .rick > .roll > p').length === 2, 'p > b tags were inserted')
+        popover.popover('hide')
+        ok(!$('.popover').length, 'popover was removed')
+        $('#qunit-runoff').empty()
+      })
+
+})
index 04000696ae0dbe0e31763c6bbe44d2cb7379fe10..74855931a6467e7ac6659346fdd853cee61af31d 100644 (file)
@@ -78,4 +78,22 @@ $(function () {
         $('#qunit-runoff').empty()
       })
 
-})
\ No newline at end of file
+      test("should allow arbitrary template html with content selector options", function() {
+        $.support.transition = false
+        var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
+          .appendTo('#qunit-runoff')
+          .twipsy({
+                html: true
+              , contentSelector: 'h1'
+              , template: '<div><h1>Funky Twipsy!</h1><p class="funky"><b>@rvagg was here</b></p></div>'
+            })
+          .twipsy('show')
+
+        ok($('.twipsy h1').length, 'h1 tag was inserted')
+        ok($('.twipsy p>b').length, 'p > b tags were inserted')
+        ok($('.twipsy h1>b').length, 'h1 tag was customised')
+        twipsy.twipsy('hide')
+        ok(!$(".twipsy").length, 'twipsy removed')
+        $('#qunit-runoff').empty()
+      })
+})