]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
remake and add isHTML check to popover as well
authorJacob Thornton <jacobthornton@gmail.com>
Wed, 4 Apr 2012 22:02:30 +0000 (15:02 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Wed, 4 Apr 2012 22:02:30 +0000 (15:02 -0700)
docs/assets/bootstrap.zip
docs/assets/js/bootstrap-popover.js
docs/assets/js/bootstrap-tooltip.js
js/bootstrap-popover.js
js/bootstrap-tooltip.js

index ea0088fcf54627550a5d7b61898224fbc4d3eda3..9b90ba4770f291f695f0ca6756d00556575f6908 100644 (file)
Binary files a/docs/assets/bootstrap.zip and b/docs/assets/bootstrap.zip differ
index ee47e43a2e64ddc66aef038fc9b08317b00ff4d9..df6ef3dfffd0ffc06d8a0dc8832a511375f24017 100644 (file)
@@ -38,8 +38,8 @@
         , title = this.getTitle()
         , content = this.getContent()
 
-      $tip.find('.popover-title').html(title)
-      $tip.find('.popover-content > *').html(content)
+      $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
+      $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
 
       $tip.removeClass('fade top bottom left right in')
     }
index 4704d1e0295b6d1c3540dfd9f93133e2cbfa3ab0..2f9254ed2acc0d3e387178f985c83b1cd8cbf45d 100644 (file)
       }
     }
 
+  , isHTML: function( text ) {
+      // html string detection logic adapted from jQuery
+      return typeof text != 'string'
+        || ( text.charAt(0) === "<"
+          && text.charAt( text.length - 1 ) === ">"
+          && text.length >= 3
+        ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
+    }
+
   , setContent: function () {
       var $tip = this.tip()
-      $tip.find('.tooltip-inner').html(this.getTitle())
+        , title = this.getTitle()
+
+      $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
       $tip.removeClass('fade in top bottom left right')
     }
 
index ee47e43a2e64ddc66aef038fc9b08317b00ff4d9..df6ef3dfffd0ffc06d8a0dc8832a511375f24017 100644 (file)
@@ -38,8 +38,8 @@
         , title = this.getTitle()
         , content = this.getContent()
 
-      $tip.find('.popover-title').html(title)
-      $tip.find('.popover-content > *').html(content)
+      $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
+      $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
 
       $tip.removeClass('fade top bottom left right in')
     }
index 63e903cb489a5204f4841e81d4736500438007f5..2f9254ed2acc0d3e387178f985c83b1cd8cbf45d 100644 (file)
   , setContent: function () {
       var $tip = this.tip()
         , title = this.getTitle()
-        , isHTML = this.isHTML(title)
 
-      $tip.find('.tooltip-inner')[isHTML ? 'html' : 'text'](title)
+      $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
       $tip.removeClass('fade in top bottom left right')
     }