2018-11-13 01:41:12 -05:00
|
|
|
/*!
|
2022-10-03 03:44:02 -04:00
|
|
|
* Bootstrap tooltip.js v5.2.2 (https://getbootstrap.com/)
|
2022-05-13 02:07:23 -04:00
|
|
|
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2020-06-16 14:50:01 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2018-11-13 01:41:12 -05:00
|
|
|
*/
|
2018-07-23 20:51:14 -04:00
|
|
|
(function (global, factory) {
|
2022-05-13 02:07:23 -04:00
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./util/index'), require('./util/sanitizer'), require('./dom/event-handler'), require('./dom/manipulator'), require('./base-component'), require('./util/template-factory')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['@popperjs/core', './util/index', './util/sanitizer', './dom/event-handler', './dom/manipulator', './base-component', './util/template-factory'], factory) :
|
|
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global["@popperjs/core"], global.Index, global.Sanitizer, global.EventHandler, global.Manipulator, global.BaseComponent, global.TemplateFactory));
|
|
|
|
})(this, (function (Popper, index, sanitizer, EventHandler, Manipulator, BaseComponent, TemplateFactory) { 'use strict';
|
2019-03-01 11:31:34 -05:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
2020-09-14 11:12:06 -04:00
|
|
|
|
2020-12-07 10:50:24 -05:00
|
|
|
function _interopNamespace(e) {
|
|
|
|
if (e && e.__esModule) return e;
|
2022-05-13 02:07:23 -04:00
|
|
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
2020-12-07 10:50:24 -05:00
|
|
|
if (e) {
|
2021-10-05 11:50:18 -04:00
|
|
|
for (const k in e) {
|
2020-12-07 10:50:24 -05:00
|
|
|
if (k !== 'default') {
|
2021-10-05 11:50:18 -04:00
|
|
|
const d = Object.getOwnPropertyDescriptor(e, k);
|
2020-12-07 10:50:24 -05:00
|
|
|
Object.defineProperty(n, k, d.get ? d : {
|
|
|
|
enumerable: true,
|
2021-10-05 11:50:18 -04:00
|
|
|
get: () => e[k]
|
2020-12-07 10:50:24 -05:00
|
|
|
});
|
|
|
|
}
|
2021-10-05 11:50:18 -04:00
|
|
|
}
|
2020-12-07 10:50:24 -05:00
|
|
|
}
|
2021-10-05 11:50:18 -04:00
|
|
|
n.default = e;
|
2020-12-07 10:50:24 -05:00
|
|
|
return Object.freeze(n);
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
|
|
|
|
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
|
|
|
const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
|
|
|
const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
2022-05-13 02:07:23 -04:00
|
|
|
const TemplateFactory__default = /*#__PURE__*/_interopDefaultLegacy(TemplateFactory);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2019-02-13 11:01:40 -05:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2022-10-03 03:44:02 -04:00
|
|
|
* Bootstrap (v5.2.2): tooltip.js
|
2020-06-16 14:50:01 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2019-03-01 11:31:34 -05:00
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
/**
|
2020-12-03 09:18:59 -05:00
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const NAME = 'tooltip';
|
|
|
|
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']);
|
2022-05-13 02:07:23 -04:00
|
|
|
const CLASS_NAME_FADE = 'fade';
|
|
|
|
const CLASS_NAME_MODAL = 'modal';
|
|
|
|
const CLASS_NAME_SHOW = 'show';
|
|
|
|
const SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
|
|
|
|
const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`;
|
|
|
|
const EVENT_MODAL_HIDE = 'hide.bs.modal';
|
|
|
|
const TRIGGER_HOVER = 'hover';
|
|
|
|
const TRIGGER_FOCUS = 'focus';
|
|
|
|
const TRIGGER_CLICK = 'click';
|
|
|
|
const TRIGGER_MANUAL = 'manual';
|
|
|
|
const EVENT_HIDE = 'hide';
|
|
|
|
const EVENT_HIDDEN = 'hidden';
|
|
|
|
const EVENT_SHOW = 'show';
|
|
|
|
const EVENT_SHOWN = 'shown';
|
|
|
|
const EVENT_INSERTED = 'inserted';
|
|
|
|
const EVENT_CLICK = 'click';
|
|
|
|
const EVENT_FOCUSIN = 'focusin';
|
|
|
|
const EVENT_FOCUSOUT = 'focusout';
|
|
|
|
const EVENT_MOUSEENTER = 'mouseenter';
|
|
|
|
const EVENT_MOUSELEAVE = 'mouseleave';
|
2021-03-23 12:26:54 -04:00
|
|
|
const AttachmentMap = {
|
2018-11-13 01:41:12 -05:00
|
|
|
AUTO: 'auto',
|
|
|
|
TOP: 'top',
|
2022-05-13 02:07:23 -04:00
|
|
|
RIGHT: index.isRTL() ? 'left' : 'right',
|
2018-11-13 01:41:12 -05:00
|
|
|
BOTTOM: 'bottom',
|
2022-05-13 02:07:23 -04:00
|
|
|
LEFT: index.isRTL() ? 'right' : 'left'
|
2018-11-13 01:41:12 -05:00
|
|
|
};
|
2021-03-23 12:26:54 -04:00
|
|
|
const Default = {
|
2022-07-19 11:43:58 -04:00
|
|
|
allowList: sanitizer.DefaultAllowlist,
|
2018-11-13 01:41:12 -05:00
|
|
|
animation: true,
|
2022-07-19 11:43:58 -04:00
|
|
|
boundary: 'clippingParents',
|
|
|
|
container: false,
|
|
|
|
customClass: '',
|
2018-11-13 01:41:12 -05:00
|
|
|
delay: 0,
|
2022-07-19 11:43:58 -04:00
|
|
|
fallbackPlacements: ['top', 'right', 'bottom', 'left'],
|
2018-11-13 01:41:12 -05:00
|
|
|
html: false,
|
2021-02-10 11:14:51 -05:00
|
|
|
offset: [0, 0],
|
2022-07-19 11:43:58 -04:00
|
|
|
placement: 'top',
|
|
|
|
popperConfig: null,
|
2019-02-13 11:01:40 -05:00
|
|
|
sanitize: true,
|
|
|
|
sanitizeFn: null,
|
2022-07-19 11:43:58 -04:00
|
|
|
selector: false,
|
|
|
|
template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>',
|
|
|
|
title: '',
|
|
|
|
trigger: 'hover focus'
|
2018-11-13 01:41:12 -05:00
|
|
|
};
|
2022-05-13 02:07:23 -04:00
|
|
|
const DefaultType = {
|
2022-07-19 11:43:58 -04:00
|
|
|
allowList: 'object',
|
2022-05-13 02:07:23 -04:00
|
|
|
animation: 'boolean',
|
2022-07-19 11:43:58 -04:00
|
|
|
boundary: '(string|element)',
|
|
|
|
container: '(string|element|boolean)',
|
|
|
|
customClass: '(string|function)',
|
2022-05-13 02:07:23 -04:00
|
|
|
delay: '(number|object)',
|
2022-07-19 11:43:58 -04:00
|
|
|
fallbackPlacements: 'array',
|
2022-05-13 02:07:23 -04:00
|
|
|
html: 'boolean',
|
|
|
|
offset: '(array|string|function)',
|
2022-07-19 11:43:58 -04:00
|
|
|
placement: '(string|function)',
|
|
|
|
popperConfig: '(null|object|function)',
|
2022-05-13 02:07:23 -04:00
|
|
|
sanitize: 'boolean',
|
|
|
|
sanitizeFn: '(null|function)',
|
2022-07-19 11:43:58 -04:00
|
|
|
selector: '(string|boolean)',
|
|
|
|
template: 'string',
|
|
|
|
title: '(string|element|function)',
|
|
|
|
trigger: 'string'
|
2018-11-13 01:41:12 -05:00
|
|
|
};
|
2019-10-08 02:39:10 -04:00
|
|
|
/**
|
2022-05-13 02:07:23 -04:00
|
|
|
* Class definition
|
2019-10-08 02:39:10 -04:00
|
|
|
*/
|
2018-11-13 01:41:12 -05:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
class Tooltip extends BaseComponent__default.default {
|
2021-03-23 12:26:54 -04:00
|
|
|
constructor(element, config) {
|
2020-12-07 10:50:24 -05:00
|
|
|
if (typeof Popper__namespace === 'undefined') {
|
2020-11-23 08:17:16 -05:00
|
|
|
throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)');
|
2020-12-03 09:18:59 -05:00
|
|
|
}
|
2017-10-29 19:19:14 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
super(element, config); // Private
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
this._isEnabled = true;
|
|
|
|
this._timeout = 0;
|
2022-09-07 11:31:39 -04:00
|
|
|
this._isHovered = null;
|
2021-03-23 12:26:54 -04:00
|
|
|
this._activeTrigger = {};
|
2022-05-13 02:07:23 -04:00
|
|
|
this._popper = null;
|
2022-07-19 11:43:58 -04:00
|
|
|
this._templateFactory = null;
|
|
|
|
this._newContent = null; // Protected
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
this.tip = null;
|
2019-03-01 11:31:34 -05:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
this._setListeners();
|
2022-10-03 03:44:02 -04:00
|
|
|
|
|
|
|
if (!this._config.selector) {
|
|
|
|
this._fixTitle();
|
|
|
|
}
|
2018-11-13 01:41:12 -05:00
|
|
|
} // Getters
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2015-08-13 00:12:03 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
static get Default() {
|
|
|
|
return Default;
|
|
|
|
}
|
|
|
|
|
|
|
|
static get DefaultType() {
|
|
|
|
return DefaultType;
|
2022-05-13 02:07:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static get NAME() {
|
|
|
|
return NAME;
|
2021-03-23 12:26:54 -04:00
|
|
|
} // Public
|
|
|
|
|
|
|
|
|
|
|
|
enable() {
|
2018-11-13 01:41:12 -05:00
|
|
|
this._isEnabled = true;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
disable() {
|
2018-11-13 01:41:12 -05:00
|
|
|
this._isEnabled = false;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
toggleEnabled() {
|
2018-11-13 01:41:12 -05:00
|
|
|
this._isEnabled = !this._isEnabled;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-10-03 03:44:02 -04:00
|
|
|
toggle() {
|
2018-11-13 01:41:12 -05:00
|
|
|
if (!this._isEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
2015-08-18 23:28:28 -04:00
|
|
|
|
2022-10-03 03:44:02 -04:00
|
|
|
this._activeTrigger.click = !this._activeTrigger.click;
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
if (this._isShown()) {
|
|
|
|
this._leave();
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
return;
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
this._enter();
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2018-11-13 01:41:12 -05:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
dispose() {
|
2018-11-13 01:41:12 -05:00
|
|
|
clearTimeout(this._timeout);
|
2021-10-05 11:50:18 -04:00
|
|
|
EventHandler__default.default.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-06-22 14:29:16 -04:00
|
|
|
if (this.tip) {
|
|
|
|
this.tip.remove();
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-10-03 03:44:02 -04:00
|
|
|
if (this._element.getAttribute('data-bs-original-title')) {
|
|
|
|
this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
|
2022-09-07 11:31:39 -04:00
|
|
|
}
|
|
|
|
|
2021-09-07 11:37:44 -04:00
|
|
|
this._disposePopper();
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
super.dispose();
|
|
|
|
}
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
show() {
|
2020-12-03 09:18:59 -05:00
|
|
|
if (this._element.style.display === 'none') {
|
2018-11-13 01:41:12 -05:00
|
|
|
throw new Error('Please use show on visible elements');
|
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (!(this._isWithContent() && this._isEnabled)) {
|
2021-02-10 11:14:51 -05:00
|
|
|
return;
|
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
const showEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOW));
|
|
|
|
const shadowRoot = index.findShadowRoot(this._element);
|
|
|
|
|
|
|
|
const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element);
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if (showEvent.defaultPrevented || !isInTheDom) {
|
|
|
|
return;
|
2022-07-19 11:43:58 -04:00
|
|
|
} // todo v6 remove this OR make it optional
|
|
|
|
|
|
|
|
|
|
|
|
if (this.tip) {
|
|
|
|
this.tip.remove();
|
|
|
|
this.tip = null;
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
2016-11-26 22:17:23 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
const tip = this._getTipElement();
|
2018-12-15 18:13:22 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._element.setAttribute('aria-describedby', tip.getAttribute('id'));
|
2018-12-15 18:13:22 -05:00
|
|
|
|
2021-05-13 12:22:20 -04:00
|
|
|
const {
|
|
|
|
container
|
|
|
|
} = this._config;
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if (!this._element.ownerDocument.documentElement.contains(this.tip)) {
|
2021-08-04 11:41:51 -04:00
|
|
|
container.append(tip);
|
2022-05-13 02:07:23 -04:00
|
|
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_INSERTED));
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this._popper) {
|
|
|
|
this._popper.update();
|
|
|
|
} else {
|
2022-07-19 11:43:58 -04:00
|
|
|
this._popper = this._createPopper(tip);
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
tip.classList.add(CLASS_NAME_SHOW); // If this is a touch-enabled device we add extra
|
2021-02-10 11:14:51 -05:00
|
|
|
// 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
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if ('ontouchstart' in document.documentElement) {
|
2022-05-13 02:07:23 -04:00
|
|
|
for (const element of [].concat(...document.body.children)) {
|
|
|
|
EventHandler__default.default.on(element, 'mouseover', index.noop);
|
|
|
|
}
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const complete = () => {
|
2022-05-13 02:07:23 -04:00
|
|
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOWN));
|
2018-11-13 01:41:12 -05:00
|
|
|
|
2022-09-07 11:31:39 -04:00
|
|
|
if (this._isHovered === false) {
|
2022-05-13 02:07:23 -04:00
|
|
|
this._leave();
|
2015-05-12 02:32:37 -04:00
|
|
|
}
|
2022-09-07 11:31:39 -04:00
|
|
|
|
|
|
|
this._isHovered = false;
|
2021-02-10 11:14:51 -05:00
|
|
|
};
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._queueCallback(complete, this.tip, this._isAnimated());
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
hide() {
|
2022-05-13 02:07:23 -04:00
|
|
|
if (!this._isShown()) {
|
2020-09-29 11:33:00 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
const hideEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDE));
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2019-03-01 11:31:34 -05:00
|
|
|
if (hideEvent.defaultPrevented) {
|
2018-11-13 01:41:12 -05:00
|
|
|
return;
|
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
const tip = this._getTipElement();
|
|
|
|
|
2020-03-28 06:29:08 -04:00
|
|
|
tip.classList.remove(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra
|
2018-11-13 01:41:12 -05:00
|
|
|
// empty mouseover listeners we added for iOS support
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if ('ontouchstart' in document.documentElement) {
|
2022-05-13 02:07:23 -04:00
|
|
|
for (const element of [].concat(...document.body.children)) {
|
|
|
|
EventHandler__default.default.off(element, 'mouseover', index.noop);
|
|
|
|
}
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2020-03-28 06:29:08 -04:00
|
|
|
this._activeTrigger[TRIGGER_CLICK] = false;
|
|
|
|
this._activeTrigger[TRIGGER_FOCUS] = false;
|
|
|
|
this._activeTrigger[TRIGGER_HOVER] = false;
|
2022-09-07 11:31:39 -04:00
|
|
|
this._isHovered = null; // it is a trick to support manual triggering
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
const complete = () => {
|
|
|
|
if (this._isWithActiveTrigger()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (!this._isHovered) {
|
|
|
|
tip.remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
this._element.removeAttribute('aria-describedby');
|
|
|
|
|
|
|
|
EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN));
|
|
|
|
|
|
|
|
this._disposePopper();
|
|
|
|
};
|
|
|
|
|
|
|
|
this._queueCallback(complete, this.tip, this._isAnimated());
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
update() {
|
2022-05-13 02:07:23 -04:00
|
|
|
if (this._popper) {
|
2020-12-07 10:50:24 -05:00
|
|
|
this._popper.update();
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2019-01-04 11:29:45 -05:00
|
|
|
} // Protected
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_isWithContent() {
|
|
|
|
return Boolean(this._getTitle());
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_getTipElement() {
|
|
|
|
if (!this.tip) {
|
2022-07-19 11:43:58 -04:00
|
|
|
this.tip = this._createTipElement(this._newContent || this._getContentForTemplate());
|
2019-03-01 11:31:34 -05:00
|
|
|
}
|
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return this.tip;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_createTipElement(content) {
|
|
|
|
const tip = this._getTemplateFactory(content).toHtml(); // todo: remove this check on v6
|
2021-08-04 11:41:51 -04:00
|
|
|
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (!tip) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-08-04 11:41:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW); // todo: on v6 the following can be achieved with CSS only
|
2021-08-04 11:41:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
tip.classList.add(`bs-${this.constructor.NAME}-auto`);
|
|
|
|
const tipId = index.getUID(this.constructor.NAME).toString();
|
|
|
|
tip.setAttribute('id', tipId);
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (this._isAnimated()) {
|
|
|
|
tip.classList.add(CLASS_NAME_FADE);
|
2019-03-01 11:31:34 -05:00
|
|
|
}
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
return tip;
|
|
|
|
}
|
2019-03-01 11:31:34 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
setContent(content) {
|
2022-07-19 11:43:58 -04:00
|
|
|
this._newContent = content;
|
2019-02-13 11:01:40 -05:00
|
|
|
|
2022-07-19 11:43:58 -04:00
|
|
|
if (this._isShown()) {
|
|
|
|
this._disposePopper();
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
this.show();
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_getTemplateFactory(content) {
|
|
|
|
if (this._templateFactory) {
|
|
|
|
this._templateFactory.changeContent(content);
|
|
|
|
} else {
|
|
|
|
this._templateFactory = new TemplateFactory__default.default({ ...this._config,
|
|
|
|
// the `content` var has to be after `this._config`
|
|
|
|
// to override config.content in case of popover
|
|
|
|
content,
|
|
|
|
extraClass: this._resolvePossibleFunction(this._config.customClass)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return this._templateFactory;
|
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_getContentForTemplate() {
|
|
|
|
return {
|
|
|
|
[SELECTOR_TOOLTIP_INNER]: this._getTitle()
|
|
|
|
};
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2020-12-03 08:08:31 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_getTitle() {
|
2022-10-03 03:44:02 -04:00
|
|
|
return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
|
2022-05-13 02:07:23 -04:00
|
|
|
} // Private
|
2020-12-03 08:08:31 -05:00
|
|
|
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_initializeOnDelegatedTarget(event) {
|
|
|
|
return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig());
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_isAnimated() {
|
|
|
|
return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE);
|
|
|
|
}
|
2021-03-23 12:26:54 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_isShown() {
|
|
|
|
return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createPopper(tip) {
|
|
|
|
const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement;
|
|
|
|
const attachment = AttachmentMap[placement.toUpperCase()];
|
2022-07-19 11:43:58 -04:00
|
|
|
return Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment));
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2019-08-27 09:03:21 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_getOffset() {
|
|
|
|
const {
|
|
|
|
offset
|
2021-05-13 12:22:20 -04:00
|
|
|
} = this._config;
|
2020-12-07 10:50:24 -05:00
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if (typeof offset === 'string') {
|
2022-05-13 02:07:23 -04:00
|
|
|
return offset.split(',').map(value => Number.parseInt(value, 10));
|
2020-12-07 10:50:24 -05:00
|
|
|
}
|
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if (typeof offset === 'function') {
|
2021-03-23 12:26:54 -04:00
|
|
|
return popperData => offset(popperData, this._element);
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_resolvePossibleFunction(arg) {
|
|
|
|
return typeof arg === 'function' ? arg.call(this._element) : arg;
|
2021-08-04 11:41:51 -04:00
|
|
|
}
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_getPopperConfig(attachment) {
|
|
|
|
const defaultBsPopperConfig = {
|
2019-08-27 09:03:21 -04:00
|
|
|
placement: attachment,
|
2021-02-10 11:14:51 -05:00
|
|
|
modifiers: [{
|
|
|
|
name: 'flip',
|
|
|
|
options: {
|
2021-05-13 12:22:20 -04:00
|
|
|
fallbackPlacements: this._config.fallbackPlacements
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
name: 'offset',
|
|
|
|
options: {
|
|
|
|
offset: this._getOffset()
|
|
|
|
}
|
|
|
|
}, {
|
2020-12-07 10:50:24 -05:00
|
|
|
name: 'preventOverflow',
|
|
|
|
options: {
|
2021-05-13 12:22:20 -04:00
|
|
|
boundary: this._config.boundary
|
2020-12-07 10:50:24 -05:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
name: 'arrow',
|
|
|
|
options: {
|
2021-03-23 12:26:54 -04:00
|
|
|
element: `.${this.constructor.NAME}-arrow`
|
2019-08-27 09:03:21 -04:00
|
|
|
}
|
2020-12-07 10:50:24 -05:00
|
|
|
}, {
|
2022-05-13 02:07:23 -04:00
|
|
|
name: 'preSetPlacement',
|
2020-12-07 10:50:24 -05:00
|
|
|
enabled: true,
|
2022-05-13 02:07:23 -04:00
|
|
|
phase: 'beforeMain',
|
|
|
|
fn: data => {
|
|
|
|
// Pre-set Popper's placement attribute in order to read the arrow sizes properly.
|
|
|
|
// Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement
|
|
|
|
this._getTipElement().setAttribute('data-popper-placement', data.state.placement);
|
2019-08-27 09:03:21 -04:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
}]
|
2019-08-27 09:03:21 -04:00
|
|
|
};
|
2021-03-23 12:26:54 -04:00
|
|
|
return { ...defaultBsPopperConfig,
|
2021-05-13 12:22:20 -04:00
|
|
|
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
|
2021-03-23 12:26:54 -04:00
|
|
|
};
|
|
|
|
}
|
2019-08-27 09:03:21 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_setListeners() {
|
2021-05-13 12:22:20 -04:00
|
|
|
const triggers = this._config.trigger.split(' ');
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
for (const trigger of triggers) {
|
2018-11-13 01:41:12 -05:00
|
|
|
if (trigger === 'click') {
|
2022-10-03 03:44:02 -04:00
|
|
|
EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {
|
|
|
|
const context = this._initializeOnDelegatedTarget(event);
|
|
|
|
|
|
|
|
context.toggle();
|
|
|
|
});
|
2020-03-28 06:29:08 -04:00
|
|
|
} else if (trigger !== TRIGGER_MANUAL) {
|
2022-05-13 02:07:23 -04:00
|
|
|
const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN);
|
|
|
|
const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT);
|
|
|
|
EventHandler__default.default.on(this._element, eventIn, this._config.selector, event => {
|
|
|
|
const context = this._initializeOnDelegatedTarget(event);
|
|
|
|
|
|
|
|
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
|
|
|
|
|
|
|
|
context._enter();
|
|
|
|
});
|
|
|
|
EventHandler__default.default.on(this._element, eventOut, this._config.selector, event => {
|
|
|
|
const context = this._initializeOnDelegatedTarget(event);
|
|
|
|
|
|
|
|
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget);
|
|
|
|
|
|
|
|
context._leave();
|
|
|
|
});
|
2017-09-06 00:05:12 -04:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
}
|
2019-07-12 17:56:26 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
this._hideModalHandler = () => {
|
|
|
|
if (this._element) {
|
|
|
|
this.hide();
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2019-07-12 17:56:26 -04:00
|
|
|
};
|
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
EventHandler__default.default.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_fixTitle() {
|
2022-10-03 03:44:02 -04:00
|
|
|
const title = this._element.getAttribute('title');
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (!title) {
|
|
|
|
return;
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-07-19 11:43:58 -04:00
|
|
|
if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) {
|
2022-05-13 02:07:23 -04:00
|
|
|
this._element.setAttribute('aria-label', title);
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
|
|
|
|
2022-10-03 03:44:02 -04:00
|
|
|
this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
|
|
|
|
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._element.removeAttribute('title');
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_enter() {
|
|
|
|
if (this._isShown() || this._isHovered) {
|
|
|
|
this._isHovered = true;
|
2018-11-13 01:41:12 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._isHovered = true;
|
|
|
|
|
|
|
|
this._setTimeout(() => {
|
|
|
|
if (this._isHovered) {
|
|
|
|
this.show();
|
2015-05-12 02:32:37 -04:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
}, this._config.delay.show);
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_leave() {
|
|
|
|
if (this._isWithActiveTrigger()) {
|
2018-11-13 01:41:12 -05:00
|
|
|
return;
|
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._isHovered = false;
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
this._setTimeout(() => {
|
|
|
|
if (!this._isHovered) {
|
|
|
|
this.hide();
|
2015-05-12 02:32:37 -04:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
}, this._config.delay.hide);
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_setTimeout(handler, timeout) {
|
|
|
|
clearTimeout(this._timeout);
|
|
|
|
this._timeout = setTimeout(handler, timeout);
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
_isWithActiveTrigger() {
|
|
|
|
return Object.values(this._activeTrigger).includes(true);
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-13 17:46:50 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_getConfig(config) {
|
2021-10-05 11:50:18 -04:00
|
|
|
const dataAttributes = Manipulator__default.default.getDataAttributes(this._element);
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
for (const dataAttribute of Object.keys(dataAttributes)) {
|
|
|
|
if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) {
|
|
|
|
delete dataAttributes[dataAttribute];
|
2019-02-13 11:01:40 -05:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
config = { ...dataAttributes,
|
2021-03-23 12:26:54 -04:00
|
|
|
...(typeof config === 'object' && config ? config : {})
|
|
|
|
};
|
2022-05-13 02:07:23 -04:00
|
|
|
config = this._mergeConfigObj(config);
|
|
|
|
config = this._configAfterMerge(config);
|
|
|
|
|
|
|
|
this._typeCheckConfig(config);
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
_configAfterMerge(config) {
|
|
|
|
config.container = config.container === false ? document.body : index.getElement(config.container);
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (typeof config.delay === 'number') {
|
|
|
|
config.delay = {
|
|
|
|
show: config.delay,
|
|
|
|
hide: config.delay
|
|
|
|
};
|
|
|
|
}
|
2017-04-01 22:18:29 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (typeof config.title === 'number') {
|
|
|
|
config.title = config.title.toString();
|
|
|
|
}
|
2017-04-01 22:18:29 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
if (typeof config.content === 'number') {
|
|
|
|
config.content = config.content.toString();
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return config;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
_getDelegateConfig() {
|
|
|
|
const config = {};
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
for (const key in this._config) {
|
|
|
|
if (this.constructor.Default[key] !== this._config[key]) {
|
|
|
|
config[key] = this._config[key];
|
2015-05-12 02:32:37 -04:00
|
|
|
}
|
2022-10-03 03:44:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
config.selector = false;
|
|
|
|
config.trigger = 'manual'; // In the future can be replaced with:
|
2021-08-04 11:41:51 -04:00
|
|
|
// const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
|
|
|
|
// `Object.fromEntries(keysWithDifferentValues)`
|
|
|
|
|
2018-11-13 01:41:12 -05:00
|
|
|
return config;
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-09-07 11:37:44 -04:00
|
|
|
_disposePopper() {
|
|
|
|
if (this._popper) {
|
|
|
|
this._popper.destroy();
|
|
|
|
|
|
|
|
this._popper = null;
|
|
|
|
}
|
2019-01-04 11:29:45 -05:00
|
|
|
} // Static
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
|
|
|
|
static jQueryInterface(config) {
|
2018-11-13 01:41:12 -05:00
|
|
|
return this.each(function () {
|
2021-06-22 14:29:16 -04:00
|
|
|
const data = Tooltip.getOrCreateInstance(this, config);
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (typeof config !== 'string') {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-06 00:05:12 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
if (typeof data[config] === 'undefined') {
|
|
|
|
throw new TypeError(`No method named "${config}"`);
|
2018-07-23 20:51:14 -04:00
|
|
|
}
|
2022-05-13 02:07:23 -04:00
|
|
|
|
|
|
|
data[config]();
|
2018-11-13 01:41:12 -05:00
|
|
|
});
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2018-11-13 01:41:12 -05:00
|
|
|
/**
|
|
|
|
* jQuery
|
|
|
|
*/
|
2015-05-12 02:32:37 -04:00
|
|
|
|
2019-07-24 02:13:50 -04:00
|
|
|
|
2022-05-13 02:07:23 -04:00
|
|
|
index.defineJQueryPlugin(Tooltip);
|
2015-05-12 02:32:37 -04:00
|
|
|
|
|
|
|
return Tooltip;
|
2018-07-23 20:51:14 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
}));
|
2018-07-23 20:51:14 -04:00
|
|
|
//# sourceMappingURL=tooltip.js.map
|