]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
add template option and make title an optional attribute for popover
authorJacob Thornton <jacobthornton@gmail.com>
Sun, 30 Oct 2011 02:59:51 +0000 (19:59 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Sun, 30 Oct 2011 02:59:51 +0000 (19:59 -0700)
docs/javascript.html
js/bootstrap-popover.js
js/bootstrap-twipsy.js

index 3aac2a82f8f2263600e8fb5695122581d0f25a0b..b80ff58fc5504a9a5b6af1123bd9441304f5c142 100644 (file)
@@ -553,6 +553,12 @@ $('#.tabs').bind('change', function (e) {
                <td>'hover'</td>
                <td>how tooltip is triggered - hover | focus | manual</td>
              </tr>
+             <tr>
+               <td>template</td>
+               <td>string</td>
+               <td>[default markup]</td>
+               <td>The html template used for rendering a twipsy.</td>
+             </tr>
             </tbody>
           </table>
           <p><span class="label notice">Notice</span> Individual twipsy instance options can alternatively be specified through the use of data attributes.</code></p>
@@ -679,6 +685,12 @@ $('#.tabs').bind('change', function (e) {
                <td>'hover'</td>
                <td>how tooltip is triggered - hover | focus | manual</td>
              </tr>
+             <tr>
+               <td>template</td>
+               <td>string</td>
+               <td>[default markup]</td>
+               <td>The html template used for rendering a popover.</td>
+             </tr>
             </tbody>
           </table>
           <p><span class="label notice">Notice</span> Individual popover instance options can alternatively be specified through the use of data attributes.</code></p>
@@ -693,7 +705,7 @@ $('#.tabs').bind('change', function (e) {
           <p>Hides an elements popover.</p>
           <pre class="prettyprint linenums">$('#element').popover('hide')</pre>
           <h3>Demo</h3>
-          <a href="#" class="btn danger" rel="popover" title="A Title" data-content="And here's some amazing content. It's very engaging. right?">hover for popover</a>
+          <a href="#" class="btn danger" rel="popover" title="A title" data-content="And here's some amazing content. It's very engaging. right?">hover for popover</a>
           <script>
             $(function () {
               $("a[rel=popover]")
index e8f4ce096bed6faf7cb1cc5da9df771f035b776e..95ca39ab7afa563a7534b0796c140b057f6fe08c 100644 (file)
       $tip[0].className = 'popover'
     }
 
+  , hasContent: function () {
+      return this.getTitle() || this.getContent()
+    }
+
   , getContent: function () {
       var content
        , $e = this.$element
@@ -57,7 +61,7 @@
   , tip: function() {
       if (!this.$tip) {
         this.$tip = $('<div class="popover" />')
-          .html('<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>')
+          .html(this.options.template)
       }
       return this.$tip
     }
@@ -74,6 +78,9 @@
     return this
   }
 
-  $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { placement: 'right'})
+  $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
+    placement: 'right'
+  , template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>'
+  })
 
 }( window.jQuery || window.ender );
\ No newline at end of file
index f0e5b1b90dd2a743104924f64f9531599c73ee9a..6066ab06ad74cd84b05edf02103137910d4be5d9 100644 (file)
@@ -72,7 +72,7 @@
         , $tip
         , tp
 
-      if (this.getTitle() && this.enabled) {
+      if (this.hasContent() && this.enabled) {
         $tip = this.tip()
         this.setContent()
 
       }
     }
 
+  , hasContent: function () {
+      return this.getTitle()
+    }
+
   , getTitle: function() {
       var title
         , $e = this.$element
 
   , tip: function() {
       if (!this.$tip) {
-        this.$tip = $('<div class="twipsy" />').html('<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>')
+        this.$tip = $('<div class="twipsy" />').html(this.options.template)
       }
       return this.$tip
     }
   , offset: 0
   , title: 'title'
   , trigger: 'hover'
+  , template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
   }
 
   $.fn.twipsy.elementOptions = function(ele, options) {