aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorAlexandr Kondrashov <[email protected]>2015-09-11 16:43:00 +0300
committerAlexandr Kondrashov <[email protected]>2015-09-11 16:43:00 +0300
commitc9725926b2f30bed4e37f57c20ef8ffeb2fd233b (patch)
tree2964ad7556549dd3e0712bdfdbc5fc4ae7a9b45f /js/src
parent353e0a49a97c24d89f6cdb95014419d4137dee6e (diff)
parentb811f8cf9628dbcbfe994f71588c5a0c921a092d (diff)
downloadbootstrap-c9725926b2f30bed4e37f57c20ef8ffeb2fd233b.tar.xz
bootstrap-c9725926b2f30bed4e37f57c20ef8ffeb2fd233b.zip
Merge remote-tracking branch 'twbs/v4-dev' into patch-1
Conflicts: scss/_custom-forms.scss scss/_variables.scss
Diffstat (limited to 'js/src')
-rw-r--r--js/src/modal.js2
-rw-r--r--js/src/popover.js21
-rw-r--r--js/src/tooltip.js26
3 files changed, 26 insertions, 23 deletions
diff --git a/js/src/modal.js b/js/src/modal.js
index 128863273..f57131e7e 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -427,7 +427,7 @@ const Modal = (($) => {
if (this._isBodyOverflowing) {
document.body.style.paddingRight =
- bodyPadding + `${this._scrollbarWidth}px`
+ `${bodyPadding + this._scrollbarWidth}px`
}
}
diff --git a/js/src/popover.js b/js/src/popover.js
index 30c0e4acb..b8b24a1c4 100644
--- a/js/src/popover.js
+++ b/js/src/popover.js
@@ -34,7 +34,7 @@ const Popover = (($) => {
})
const DefaultType = $.extend({}, Tooltip.DefaultType, {
- content : '(string|function)'
+ content : '(string|element|function)'
})
const ClassName = {
@@ -113,24 +113,13 @@ const Popover = (($) => {
}
setContent() {
- let tip = this.getTipElement()
- let title = this.getTitle()
- let content = this._getContent()
- let titleElement = $(tip).find(Selector.TITLE)[0]
-
- if (titleElement) {
- titleElement[
- this.config.html ? 'innerHTML' : 'innerText'
- ] = title
- }
+ let $tip = $(this.getTipElement())
// we use append for html objects to maintain js events
- $(tip).find(Selector.CONTENT).children().detach().end()[
- this.config.html ?
- (typeof content === 'string' ? 'html' : 'append') : 'text'
- ](content)
+ this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
+ this.setElementContent($tip.find(Selector.CONTENT), this._getContent())
- $(tip)
+ $tip
.removeClass(ClassName.FADE)
.removeClass(ClassName.IN)
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index a65caf26e..151cd6f51 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -43,7 +43,7 @@ const Tooltip = (($) => {
const DefaultType = {
animation : 'boolean',
template : 'string',
- title : '(string|function)',
+ title : '(string|element|function)',
trigger : 'string',
delay : '(number|object)',
html : 'boolean',
@@ -356,19 +356,33 @@ const Tooltip = (($) => {
}
setContent() {
- let tip = this.getTipElement()
- let title = this.getTitle()
- let method = this.config.html ? 'innerHTML' : 'innerText'
+ let $tip = $(this.getTipElement())
- $(tip).find(Selector.TOOLTIP_INNER)[0][method] = title
+ this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle())
- $(tip)
+ $tip
.removeClass(ClassName.FADE)
.removeClass(ClassName.IN)
this.cleanupTether()
}
+ setElementContent($element, content) {
+ let html = this.config.html
+ if (typeof content === 'object' && (content.nodeType || content.jquery)) {
+ // content is a DOM node or a jQuery
+ if (html) {
+ if (!$(content).parent().is($element)) {
+ $element.empty().append(content)
+ }
+ } else {
+ $element.text($(content).text())
+ }
+ } else {
+ $element[html ? 'html' : 'text'](content)
+ }
+ }
+
getTitle() {
let title = this.element.getAttribute('data-original-title')