diff options
author | XhmikosR <xhmikosr@gmail.com> | 2019-08-27 16:03:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-27 16:03:21 +0300 |
commit | bf57274fb51fd59f8d680590ead92cb631cf8ea1 (patch) | |
tree | 63aec9b1415470f399e1cbab0ae0d404d1389923 /js/dist/tooltip.js | |
parent | cad3d1098a2340299e88d05d7da190aac08ca319 (diff) |
Dist (#29263)
Diffstat (limited to 'js/dist/tooltip.js')
-rw-r--r-- | js/dist/tooltip.js | 127 |
1 files changed, 71 insertions, 56 deletions
diff --git a/js/dist/tooltip.js b/js/dist/tooltip.js index 786daa466f..6fdd44a028 100644 --- a/js/dist/tooltip.js +++ b/js/dist/tooltip.js @@ -88,9 +88,7 @@ */ var MAX_UID = 1000000; var MILLISECONDS_MULTIPLIER = 1000; - var TRANSITION_END = 'transitionend'; - var _window = window, - jQuery = _window.jQuery; // Shoutout AngusCroll (https://goo.gl/pxwQGp) + var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) var toType = function toType(obj) { return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); @@ -210,6 +208,17 @@ return function () {}; }; + var getjQuery = function getjQuery() { + var _window = window, + jQuery = _window.jQuery; + + if (jQuery && !document.body.hasAttribute('data-no-jquery')) { + return jQuery; + } + + return null; + }; + /** * -------------------------------------------------------------------------- * Bootstrap (v4.3.1): util/sanitizer.js @@ -359,7 +368,8 @@ boundary: '(string|element)', sanitize: 'boolean', sanitizeFn: '(null|function)', - whiteList: 'object' + whiteList: 'object', + popperConfig: '(null|object)' }; var AttachmentMap = { AUTO: 'auto', @@ -383,7 +393,8 @@ boundary: 'scrollParent', sanitize: true, sanitizeFn: null, - whiteList: DefaultWhitelist + whiteList: DefaultWhitelist, + popperConfig: null }; var HoverState = { SHOW: 'show', @@ -425,10 +436,6 @@ /*#__PURE__*/ function () { function Tooltip(element, config) { - /** - * Check for Popper dependency - * Popper - https://popper.js.org - */ if (typeof Popper === 'undefined') { throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org)'); } // private @@ -512,7 +519,7 @@ this._hoverState = null; this._activeTrigger = null; - if (this._popper !== null) { + if (this._popper) { this._popper.destroy(); } @@ -563,29 +570,7 @@ } EventHandler.trigger(this.element, this.constructor.Event.INSERTED); - this._popper = new Popper(this.element, tip, { - placement: attachment, - modifiers: { - offset: this._getOffset(), - flip: { - behavior: this.config.fallbackPlacement - }, - arrow: { - element: "." + this.constructor.NAME + "-arrow" - }, - preventOverflow: { - boundariesElement: this.config.boundary - } - }, - onCreate: function onCreate(data) { - if (data.originalPlacement !== data.placement) { - _this._handlePopperPlacementChange(data); - } - }, - onUpdate: function onUpdate(data) { - return _this._handlePopperPlacementChange(data); - } - }); + this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment)); tip.classList.add(ClassName.SHOW); // If this is a touch-enabled device we add extra // empty mouseover listeners to the body's immediate children; // only needed because of broken event delegation on iOS @@ -744,18 +729,47 @@ } // Private ; + _proto._getPopperConfig = function _getPopperConfig(attachment) { + var _this3 = this; + + var defaultBsConfig = { + placement: attachment, + modifiers: { + offset: this._getOffset(), + flip: { + behavior: this.config.fallbackPlacement + }, + arrow: { + element: "." + this.constructor.NAME + "-arrow" + }, + preventOverflow: { + boundariesElement: this.config.boundary + } + }, + onCreate: function onCreate(data) { + if (data.originalPlacement !== data.placement) { + _this3._handlePopperPlacementChange(data); + } + }, + onUpdate: function onUpdate(data) { + return _this3._handlePopperPlacementChange(data); + } + }; + return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig); + }; + _proto._addAttachmentClass = function _addAttachmentClass(attachment) { this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment); }; _proto._getOffset = function _getOffset() { - var _this3 = this; + var _this4 = this; var offset = {}; if (typeof this.config.offset === 'function') { offset.fn = function (data) { - data.offsets = _objectSpread2({}, data.offsets, {}, _this3.config.offset(data.offsets, _this3.element) || {}); + data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {}); return data; }; } else { @@ -782,29 +796,29 @@ }; _proto._setListeners = function _setListeners() { - var _this4 = this; + var _this5 = this; var triggers = this.config.trigger.split(' '); triggers.forEach(function (trigger) { if (trigger === 'click') { - EventHandler.on(_this4.element, _this4.constructor.Event.CLICK, _this4.config.selector, function (event) { - return _this4.toggle(event); + EventHandler.on(_this5.element, _this5.constructor.Event.CLICK, _this5.config.selector, function (event) { + return _this5.toggle(event); }); } else if (trigger !== Trigger.MANUAL) { - var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN; - var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT; - EventHandler.on(_this4.element, eventIn, _this4.config.selector, function (event) { - return _this4._enter(event); + var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN; + var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT; + EventHandler.on(_this5.element, eventIn, _this5.config.selector, function (event) { + return _this5._enter(event); }); - EventHandler.on(_this4.element, eventOut, _this4.config.selector, function (event) { - return _this4._leave(event); + EventHandler.on(_this5.element, eventOut, _this5.config.selector, function (event) { + return _this5._leave(event); }); } }); this._hideModalHandler = function () { - if (_this4.element) { - _this4.hide(); + if (_this5.element) { + _this5.hide(); } }; @@ -994,7 +1008,7 @@ } // Static ; - Tooltip._jQueryInterface = function _jQueryInterface(config) { + Tooltip.jQueryInterface = function jQueryInterface(config) { return this.each(function () { var data = Data.getData(this, DATA_KEY); @@ -1018,7 +1032,7 @@ }); }; - Tooltip._getInstance = function _getInstance(element) { + Tooltip.getInstance = function getInstance(element) { return Data.getData(element, DATA_KEY); }; @@ -1061,6 +1075,8 @@ return Tooltip; }(); + + var $ = getjQuery(); /** * ------------------------------------------------------------------------ * jQuery @@ -1070,15 +1086,14 @@ /* istanbul ignore if */ + if ($) { + var JQUERY_NO_CONFLICT = $.fn[NAME]; + $.fn[NAME] = Tooltip.jQueryInterface; + $.fn[NAME].Constructor = Tooltip; - if (typeof jQuery !== 'undefined') { - var JQUERY_NO_CONFLICT = jQuery.fn[NAME]; - jQuery.fn[NAME] = Tooltip._jQueryInterface; - jQuery.fn[NAME].Constructor = Tooltip; - - jQuery.fn[NAME].noConflict = function () { - jQuery.fn[NAME] = JQUERY_NO_CONFLICT; - return Tooltip._jQueryInterface; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tooltip.jQueryInterface; }; } |