Permalink
Browse files

remake and add isHTML check to popover as well

  • Loading branch information...
1 parent 4bd6118 commit 83febb3452ecd81241ddc004509ec64de8b13a92 @fat fat committed Apr 4, 2012
View
Binary file not shown.
@@ -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')
}
@@ -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')
}
View
@@ -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')
}
View
@@ -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')
}

4 comments on commit 83febb3

This commit seems to have broken the popover functionality giving a
Uncaught TypeError: Object [object Object] has no method 'isHTML'
on
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
where "this" is the window scope.

Owner
fat replied Apr 24, 2012

why would your setContent have the window's scope?

Not sure, I submitted the issue+comment on behalf of a college which encountered this problem so I am not even entirely sure of the context and he isn't used to open source projects (till half a year ago he worked in a asp.net environment) so I reverted his popover.js to a pre this commit version which solved the issue and quickly wanted to dump a message here that I had observed this problem. Possibly I will have some time Friday afternoon to look into this for a bit longer (it could be that he had a version mismatch of an older bootstrap version with the newest version of this file)

Owner
fat replied Apr 27, 2012

hm... ok let me know, thanks!

Please sign in to comment.