aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2012-04-04 15:02:30 -0700
committerJacob Thornton <[email protected]>2012-04-04 15:02:30 -0700
commit83febb3452ecd81241ddc004509ec64de8b13a92 (patch)
tree049d15d5ebed8c11e804cfc293f3f695072b8aea
parent4bd611884a5f1dd02878f73bccd51d85c1e49186 (diff)
downloadbootstrap-83febb3452ecd81241ddc004509ec64de8b13a92.tar.xz
bootstrap-83febb3452ecd81241ddc004509ec64de8b13a92.zip
remake and add isHTML check to popover as well
-rw-r--r--docs/assets/bootstrap.zipbin56893 -> 57150 bytes
-rw-r--r--docs/assets/js/bootstrap-popover.js4
-rw-r--r--docs/assets/js/bootstrap-tooltip.js13
-rw-r--r--js/bootstrap-popover.js4
-rw-r--r--js/bootstrap-tooltip.js3
5 files changed, 17 insertions, 7 deletions
diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip
index ea0088fcf..9b90ba477 100644
--- a/docs/assets/bootstrap.zip
+++ b/docs/assets/bootstrap.zip
Binary files differ
diff --git a/docs/assets/js/bootstrap-popover.js b/docs/assets/js/bootstrap-popover.js
index ee47e43a2..df6ef3dff 100644
--- a/docs/assets/js/bootstrap-popover.js
+++ b/docs/assets/js/bootstrap-popover.js
@@ -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')
}
diff --git a/docs/assets/js/bootstrap-tooltip.js b/docs/assets/js/bootstrap-tooltip.js
index 4704d1e02..2f9254ed2 100644
--- a/docs/assets/js/bootstrap-tooltip.js
+++ b/docs/assets/js/bootstrap-tooltip.js
@@ -155,9 +155,20 @@
}
}
+ , 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')
}
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js
index ee47e43a2..df6ef3dff 100644
--- a/js/bootstrap-popover.js
+++ b/js/bootstrap-popover.js
@@ -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')
}
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index 63e903cb4..2f9254ed2 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -167,9 +167,8 @@
, 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')
}