diff options
| author | Alexandr Kondrashov <[email protected]> | 2015-09-11 16:43:00 +0300 |
|---|---|---|
| committer | Alexandr Kondrashov <[email protected]> | 2015-09-11 16:43:00 +0300 |
| commit | c9725926b2f30bed4e37f57c20ef8ffeb2fd233b (patch) | |
| tree | 2964ad7556549dd3e0712bdfdbc5fc4ae7a9b45f /js/src/tooltip.js | |
| parent | 353e0a49a97c24d89f6cdb95014419d4137dee6e (diff) | |
| parent | b811f8cf9628dbcbfe994f71588c5a0c921a092d (diff) | |
| download | bootstrap-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/tooltip.js')
| -rw-r--r-- | js/src/tooltip.js | 26 |
1 files changed, 20 insertions, 6 deletions
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') |
