mirror of
https://github.com/twbs/bootstrap.git
synced 2025-04-06 23:57:36 +02:00
remake and add isHTML check to popover as well
This commit is contained in:
parent
4bd611884a
commit
83febb3452
Binary file not shown.
4
docs/assets/js/bootstrap-popover.js
vendored
4
docs/assets/js/bootstrap-popover.js
vendored
@ -38,8 +38,8 @@
|
|||||||
, title = this.getTitle()
|
, title = this.getTitle()
|
||||||
, content = this.getContent()
|
, content = this.getContent()
|
||||||
|
|
||||||
$tip.find('.popover-title').html(title)
|
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||||
$tip.find('.popover-content > *').html(content)
|
$tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
|
||||||
|
|
||||||
$tip.removeClass('fade top bottom left right in')
|
$tip.removeClass('fade top bottom left right in')
|
||||||
}
|
}
|
||||||
|
13
docs/assets/js/bootstrap-tooltip.js
vendored
13
docs/assets/js/bootstrap-tooltip.js
vendored
@ -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 () {
|
, setContent: function () {
|
||||||
var $tip = this.tip()
|
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')
|
$tip.removeClass('fade in top bottom left right')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
js/bootstrap-popover.js
vendored
4
js/bootstrap-popover.js
vendored
@ -38,8 +38,8 @@
|
|||||||
, title = this.getTitle()
|
, title = this.getTitle()
|
||||||
, content = this.getContent()
|
, content = this.getContent()
|
||||||
|
|
||||||
$tip.find('.popover-title').html(title)
|
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||||
$tip.find('.popover-content > *').html(content)
|
$tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
|
||||||
|
|
||||||
$tip.removeClass('fade top bottom left right in')
|
$tip.removeClass('fade top bottom left right in')
|
||||||
}
|
}
|
||||||
|
3
js/bootstrap-tooltip.js
vendored
3
js/bootstrap-tooltip.js
vendored
@ -167,9 +167,8 @@
|
|||||||
, setContent: function () {
|
, setContent: function () {
|
||||||
var $tip = this.tip()
|
var $tip = this.tip()
|
||||||
, title = this.getTitle()
|
, 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')
|
$tip.removeClass('fade in top bottom left right')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user