diff options
author | XhmikosR <xhmikosr@gmail.com> | 2019-02-26 14:20:34 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2019-03-11 18:01:28 +0300 |
commit | 46c037410b8c7eaab3cf50a5cf44093aa2fd41f4 (patch) | |
tree | cb8c857562c4d3f819a5a8fcc563bc8f2c126e4e /js/src/popover.js | |
parent | 44e6abcba50309df4fae56a9c7ef79145b64a356 (diff) |
Comply to the new rules.
Diffstat (limited to 'js/src/popover.js')
-rw-r--r-- | js/src/popover.js | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/js/src/popover.js b/js/src/popover.js index 958beaa3d0..bee07d5e29 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -18,19 +18,19 @@ import Tooltip from './tooltip' * ------------------------------------------------------------------------ */ -const NAME = 'popover' -const VERSION = '4.3.1' -const DATA_KEY = 'bs.popover' -const EVENT_KEY = `.${DATA_KEY}` -const CLASS_PREFIX = 'bs-popover' -const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') +const NAME = 'popover' +const VERSION = '4.3.1' +const DATA_KEY = 'bs.popover' +const EVENT_KEY = `.${DATA_KEY}` +const CLASS_PREFIX = 'bs-popover' +const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') const Default = { ...Tooltip.Default, - placement : 'right', - trigger : 'click', - content : '', - template : '<div class="popover" role="tooltip">' + + placement: 'right', + trigger: 'click', + content: '', + template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>' @@ -38,30 +38,30 @@ const Default = { const DefaultType = { ...Tooltip.DefaultType, - content : '(string|element|function)' + content: '(string|element|function)' } const ClassName = { - FADE : 'fade', - SHOW : 'show' + FADE: 'fade', + SHOW: 'show' } const Selector = { - TITLE : '.popover-header', - CONTENT : '.popover-body' + TITLE: '.popover-header', + CONTENT: '.popover-body' } const Event = { - HIDE : `hide${EVENT_KEY}`, - HIDDEN : `hidden${EVENT_KEY}`, - SHOW : `show${EVENT_KEY}`, - SHOWN : `shown${EVENT_KEY}`, - INSERTED : `inserted${EVENT_KEY}`, - CLICK : `click${EVENT_KEY}`, - FOCUSIN : `focusin${EVENT_KEY}`, - FOCUSOUT : `focusout${EVENT_KEY}`, - MOUSEENTER : `mouseenter${EVENT_KEY}`, - MOUSELEAVE : `mouseleave${EVENT_KEY}` + HIDE: `hide${EVENT_KEY}`, + HIDDEN: `hidden${EVENT_KEY}`, + SHOW: `show${EVENT_KEY}`, + SHOWN: `shown${EVENT_KEY}`, + INSERTED: `inserted${EVENT_KEY}`, + CLICK: `click${EVENT_KEY}`, + FOCUSIN: `focusin${EVENT_KEY}`, + FOCUSOUT: `focusout${EVENT_KEY}`, + MOUSEENTER: `mouseenter${EVENT_KEY}`, + MOUSELEAVE: `mouseleave${EVENT_KEY}` } /** @@ -120,6 +120,7 @@ class Popover extends Tooltip { if (typeof content === 'function') { content = content.call(this.element) } + this.setElementContent(SelectorEngine.findOne(Selector.CONTENT, tip), content) tip.classList.remove(ClassName.FADE) @@ -138,8 +139,8 @@ class Popover extends Tooltip { const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX) if (tabClass !== null && tabClass.length > 0) { - tabClass.map((token) => token.trim()) - .forEach((tClass) => tip.classList.remove(tClass)) + tabClass.map(token => token.trim()) + .forEach(tClass => tip.classList.remove(tClass)) } } @@ -147,7 +148,7 @@ class Popover extends Tooltip { static _jQueryInterface(config) { return this.each(function () { - let data = Data.getData(this, DATA_KEY) + let data = Data.getData(this, DATA_KEY) const _config = typeof config === 'object' ? config : null if (!data && /dispose|hide/.test(config)) { @@ -163,6 +164,7 @@ class Popover extends Tooltip { if (typeof data[config] === 'undefined') { throw new TypeError(`No method named "${config}"`) } + data[config]() } }) @@ -181,9 +183,9 @@ class Popover extends Tooltip { if (typeof $ !== 'undefined') { const JQUERY_NO_CONFLICT = $.fn[NAME] - $.fn[NAME] = Popover._jQueryInterface - $.fn[NAME].Constructor = Popover - $.fn[NAME].noConflict = () => { + $.fn[NAME] = Popover._jQueryInterface + $.fn[NAME].Constructor = Popover + $.fn[NAME].noConflict = () => { $.fn[NAME] = JQUERY_NO_CONFLICT return Popover._jQueryInterface } |