diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/tooltip.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/tooltip.js | 298 |
1 files changed, 124 insertions, 174 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/tooltip.js b/vendor/twbs/bootstrap/js/dist/tooltip.js index 2351fe6e0..5d1713611 100644 --- a/vendor/twbs/bootstrap/js/dist/tooltip.js +++ b/vendor/twbs/bootstrap/js/dist/tooltip.js @@ -1,72 +1,22 @@ /*! - * Bootstrap tooltip.js v4.3.1 (https://getbootstrap.com/) - * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Bootstrap tooltip.js v4.5.2 (https://getbootstrap.com/) + * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('popper.js'), require('./util.js')) : typeof define === 'function' && define.amd ? define(['jquery', 'popper.js', './util.js'], factory) : - (global = global || self, global.Tooltip = factory(global.jQuery, global.Popper, global.Util)); -}(this, function ($, Popper, Util) { 'use strict'; - - $ = $ && $.hasOwnProperty('default') ? $['default'] : $; - Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper; - Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util; - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; - } - - function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); - - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.jQuery, global.Popper, global.Util)); +}(this, (function ($, Popper, Util) { 'use strict'; - return target; - } + $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $; + Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper; + Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util; /** * -------------------------------------------------------------------------- - * Bootstrap (v4.3.1): tools/sanitizer.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Bootstrap (v4.5.2): tools/sanitizer.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; @@ -90,7 +40,7 @@ h5: [], h6: [], i: [], - img: ['src', 'alt', 'title', 'width', 'height'], + img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], li: [], ol: [], p: [], @@ -103,21 +53,21 @@ strong: [], u: [], ul: [] - /** - * A pattern that recognizes a commonly useful subset of URLs that are safe. - * - * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts - */ - }; - var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; + /** + * A pattern that recognizes a commonly useful subset of URLs that are safe. + * + * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts + */ + + var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi; /** * A pattern that matches safe data URLs. Only matches image, video and audio types. * * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts */ - var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; + var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; function allowedAttribute(attr, allowedAttributeList) { var attrName = attr.nodeName.toLowerCase(); @@ -134,7 +84,7 @@ return attrRegex instanceof RegExp; }); // Check if a regular expression validates the attribute. - for (var i = 0, l = regExp.length; i < l; i++) { + for (var i = 0, len = regExp.length; i < len; i++) { if (attrName.match(regExp[i])) { return true; } @@ -176,7 +126,7 @@ }; for (var i = 0, len = elements.length; i < len; i++) { - var _ret = _loop(i, len); + var _ret = _loop(i); if (_ret === "continue") continue; } @@ -184,6 +134,11 @@ return createdDocument.body.innerHTML; } + function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * ------------------------------------------------------------------------ * Constants @@ -191,7 +146,7 @@ */ var NAME = 'tooltip'; - var VERSION = '4.3.1'; + var VERSION = '4.5.2'; var DATA_KEY = 'bs.tooltip'; var EVENT_KEY = "." + DATA_KEY; var JQUERY_NO_CONFLICT = $.fn[NAME]; @@ -213,7 +168,8 @@ boundary: '(string|element)', sanitize: 'boolean', sanitizeFn: '(null|function)', - whiteList: 'object' + whiteList: 'object', + popperConfig: '(null|object)' }; var AttachmentMap = { AUTO: 'auto', @@ -237,12 +193,11 @@ boundary: 'scrollParent', sanitize: true, sanitizeFn: null, - whiteList: DefaultWhitelist - }; - var HoverState = { - SHOW: 'show', - OUT: 'out' + whiteList: DefaultWhitelist, + popperConfig: null }; + var HOVER_STATE_SHOW = 'show'; + var HOVER_STATE_OUT = 'out'; var Event = { HIDE: "hide" + EVENT_KEY, HIDDEN: "hidden" + EVENT_KEY, @@ -255,36 +210,22 @@ MOUSEENTER: "mouseenter" + EVENT_KEY, MOUSELEAVE: "mouseleave" + EVENT_KEY }; - var ClassName = { - FADE: 'fade', - SHOW: 'show' - }; - var Selector = { - TOOLTIP: '.tooltip', - TOOLTIP_INNER: '.tooltip-inner', - ARROW: '.arrow' - }; - var Trigger = { - HOVER: 'hover', - FOCUS: 'focus', - CLICK: 'click', - MANUAL: 'manual' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var CLASS_NAME_FADE = 'fade'; + var CLASS_NAME_SHOW = 'show'; + var SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; + var SELECTOR_ARROW = '.arrow'; + var TRIGGER_HOVER = 'hover'; + var TRIGGER_FOCUS = 'focus'; + var TRIGGER_CLICK = 'click'; + var TRIGGER_MANUAL = 'manual'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Tooltip = - /*#__PURE__*/ - function () { + var Tooltip = /*#__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 @@ -341,7 +282,7 @@ context._leave(null, context); } } else { - if ($(this.getTipElement()).hasClass(ClassName.SHOW)) { + if ($(this.getTipElement()).hasClass(CLASS_NAME_SHOW)) { this._leave(null, this); return; @@ -355,7 +296,7 @@ clearTimeout(this._timeout); $.removeData(this.element, this.constructor.DATA_KEY); $(this.element).off(this.constructor.EVENT_KEY); - $(this.element).closest('.modal').off('hide.bs.modal'); + $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler); if (this.tip) { $(this.tip).remove(); @@ -366,7 +307,7 @@ this._hoverState = null; this._activeTrigger = null; - if (this._popper !== null) { + if (this._popper) { this._popper.destroy(); } @@ -401,7 +342,7 @@ this.setContent(); if (this.config.animation) { - $(tip).addClass(ClassName.FADE); + $(tip).addClass(CLASS_NAME_FADE); } var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; @@ -419,30 +360,8 @@ } $(this.element).trigger(this.constructor.Event.INSERTED); - this._popper = new Popper(this.element, tip, { - placement: attachment, - modifiers: { - offset: this._getOffset(), - flip: { - behavior: this.config.fallbackPlacement - }, - arrow: { - element: Selector.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); - } - }); - $(tip).addClass(ClassName.SHOW); // If this is a touch-enabled device we add extra + this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment)); + $(tip).addClass(CLASS_NAME_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 // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html @@ -460,12 +379,12 @@ _this._hoverState = null; $(_this.element).trigger(_this.constructor.Event.SHOWN); - if (prevHoverState === HoverState.OUT) { + if (prevHoverState === HOVER_STATE_OUT) { _this._leave(null, _this); } }; - if ($(this.tip).hasClass(ClassName.FADE)) { + if ($(this.tip).hasClass(CLASS_NAME_FADE)) { var transitionDuration = Util.getTransitionDurationFromElement(this.tip); $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); } else { @@ -481,7 +400,7 @@ var hideEvent = $.Event(this.constructor.Event.HIDE); var complete = function complete() { - if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) { + if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) { tip.parentNode.removeChild(tip); } @@ -506,18 +425,18 @@ return; } - $(tip).removeClass(ClassName.SHOW); // If this is a touch-enabled device we remove the extra + $(tip).removeClass(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { $(document.body).children().off('mouseover', null, $.noop); } - this._activeTrigger[Trigger.CLICK] = false; - this._activeTrigger[Trigger.FOCUS] = false; - this._activeTrigger[Trigger.HOVER] = false; + this._activeTrigger[TRIGGER_CLICK] = false; + this._activeTrigger[TRIGGER_FOCUS] = false; + this._activeTrigger[TRIGGER_HOVER] = false; - if ($(this.tip).hasClass(ClassName.FADE)) { + if ($(this.tip).hasClass(CLASS_NAME_FADE)) { var transitionDuration = Util.getTransitionDurationFromElement(tip); $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); } else { @@ -549,8 +468,8 @@ _proto.setContent = function setContent() { var tip = this.getTipElement(); - this.setElementContent($(tip.querySelectorAll(Selector.TOOLTIP_INNER)), this.getTitle()); - $(tip).removeClass(ClassName.FADE + " " + ClassName.SHOW); + this.setElementContent($(tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle()); + $(tip).removeClass(CLASS_NAME_FADE + " " + CLASS_NAME_SHOW); }; _proto.setElementContent = function setElementContent($element, content) { @@ -589,14 +508,43 @@ } // Private ; - _proto._getOffset = function _getOffset() { + _proto._getPopperConfig = function _getPopperConfig(attachment) { var _this3 = this; + var defaultBsConfig = { + placement: attachment, + modifiers: { + offset: this._getOffset(), + flip: { + behavior: this.config.fallbackPlacement + }, + arrow: { + element: SELECTOR_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 _extends({}, defaultBsConfig, this.config.popperConfig); + }; + + _proto._getOffset = function _getOffset() { + var _this4 = this; + var offset = {}; if (typeof this.config.offset === 'function') { offset.fn = function (data) { - data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {}); + data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {}); return data; }; } else { @@ -623,32 +571,35 @@ }; _proto._setListeners = function _setListeners() { - var _this4 = this; + var _this5 = this; var triggers = this.config.trigger.split(' '); triggers.forEach(function (trigger) { if (trigger === 'click') { - $(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) { - return _this4.toggle(event); + $(_this5.element).on(_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; - $(_this4.element).on(eventIn, _this4.config.selector, function (event) { - return _this4._enter(event); - }).on(eventOut, _this4.config.selector, function (event) { - return _this4._leave(event); + } else if (trigger !== TRIGGER_MANUAL) { + 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; + $(_this5.element).on(eventIn, _this5.config.selector, function (event) { + return _this5._enter(event); + }).on(eventOut, _this5.config.selector, function (event) { + return _this5._leave(event); }); } }); - $(this.element).closest('.modal').on('hide.bs.modal', function () { - if (_this4.element) { - _this4.hide(); + + this._hideModalHandler = function () { + if (_this5.element) { + _this5.hide(); } - }); + }; + + $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler); if (this.config.selector) { - this.config = _objectSpread({}, this.config, { + this.config = _extends({}, this.config, { trigger: 'manual', selector: '' }); @@ -676,16 +627,16 @@ } if (event) { - context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true; + context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; } - if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) { - context._hoverState = HoverState.SHOW; + if ($(context.getTipElement()).hasClass(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) { + context._hoverState = HOVER_STATE_SHOW; return; } clearTimeout(context._timeout); - context._hoverState = HoverState.SHOW; + context._hoverState = HOVER_STATE_SHOW; if (!context.config.delay || !context.config.delay.show) { context.show(); @@ -693,7 +644,7 @@ } context._timeout = setTimeout(function () { - if (context._hoverState === HoverState.SHOW) { + if (context._hoverState === HOVER_STATE_SHOW) { context.show(); } }, context.config.delay.show); @@ -709,7 +660,7 @@ } if (event) { - context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false; + context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false; } if (context._isWithActiveTrigger()) { @@ -717,7 +668,7 @@ } clearTimeout(context._timeout); - context._hoverState = HoverState.OUT; + context._hoverState = HOVER_STATE_OUT; if (!context.config.delay || !context.config.delay.hide) { context.hide(); @@ -725,7 +676,7 @@ } context._timeout = setTimeout(function () { - if (context._hoverState === HoverState.OUT) { + if (context._hoverState === HOVER_STATE_OUT) { context.hide(); } }, context.config.delay.hide); @@ -748,7 +699,7 @@ delete dataAttributes[dataAttr]; } }); - config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); + config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); if (typeof config.delay === 'number') { config.delay = { @@ -798,8 +749,7 @@ }; _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { - var popperInstance = popperData.instance; - this.tip = popperInstance.popper; + this.tip = popperData.instance.popper; this._cleanTipClass(); @@ -814,7 +764,7 @@ return; } - $(tip).removeClass(ClassName.FADE); + $(tip).removeClass(CLASS_NAME_FADE); this.config.animation = false; this.hide(); this.show(); @@ -903,5 +853,5 @@ return Tooltip; -})); +}))); //# sourceMappingURL=tooltip.js.map |