mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 17:14:04 +02:00
58
js/dist/tooltip.js
vendored
58
js/dist/tooltip.js
vendored
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Bootstrap tooltip.js v5.2.1 (https://getbootstrap.com/)
|
||||
* Bootstrap tooltip.js v5.2.2 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v5.2.1): tooltip.js
|
||||
* Bootstrap (v5.2.2): tooltip.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -135,6 +135,10 @@
|
||||
this.tip = null;
|
||||
|
||||
this._setListeners();
|
||||
|
||||
if (!this._config.selector) {
|
||||
this._fixTitle();
|
||||
}
|
||||
} // Getters
|
||||
|
||||
|
||||
@@ -163,24 +167,12 @@
|
||||
this._isEnabled = !this._isEnabled;
|
||||
}
|
||||
|
||||
toggle(event) {
|
||||
toggle() {
|
||||
if (!this._isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event) {
|
||||
const context = this._initializeOnDelegatedTarget(event);
|
||||
|
||||
context._activeTrigger.click = !context._activeTrigger.click;
|
||||
|
||||
if (context._isWithActiveTrigger()) {
|
||||
context._enter();
|
||||
} else {
|
||||
context._leave();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
this._activeTrigger.click = !this._activeTrigger.click;
|
||||
|
||||
if (this._isShown()) {
|
||||
this._leave();
|
||||
@@ -199,8 +191,8 @@
|
||||
this.tip.remove();
|
||||
}
|
||||
|
||||
if (this._config.originalTitle) {
|
||||
this._element.setAttribute('title', this._config.originalTitle);
|
||||
if (this._element.getAttribute('data-bs-original-title')) {
|
||||
this._element.setAttribute('title', this._element.getAttribute('data-bs-original-title'));
|
||||
}
|
||||
|
||||
this._disposePopper();
|
||||
@@ -393,7 +385,7 @@
|
||||
}
|
||||
|
||||
_getTitle() {
|
||||
return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle;
|
||||
return this._resolvePossibleFunction(this._config.title) || this._element.getAttribute('data-bs-original-title');
|
||||
} // Private
|
||||
|
||||
|
||||
@@ -479,7 +471,11 @@
|
||||
|
||||
for (const trigger of triggers) {
|
||||
if (trigger === 'click') {
|
||||
EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => this.toggle(event));
|
||||
EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => {
|
||||
const context = this._initializeOnDelegatedTarget(event);
|
||||
|
||||
context.toggle();
|
||||
});
|
||||
} else if (trigger !== TRIGGER_MANUAL) {
|
||||
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);
|
||||
@@ -507,19 +503,10 @@
|
||||
};
|
||||
|
||||
EventHandler__default.default.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler);
|
||||
|
||||
if (this._config.selector) {
|
||||
this._config = { ...this._config,
|
||||
trigger: 'manual',
|
||||
selector: ''
|
||||
};
|
||||
} else {
|
||||
this._fixTitle();
|
||||
}
|
||||
}
|
||||
|
||||
_fixTitle() {
|
||||
const title = this._config.originalTitle;
|
||||
const title = this._element.getAttribute('title');
|
||||
|
||||
if (!title) {
|
||||
return;
|
||||
@@ -529,6 +516,9 @@
|
||||
this._element.setAttribute('aria-label', title);
|
||||
}
|
||||
|
||||
this._element.setAttribute('data-bs-original-title', title); // DO NOT USE IT. Is only for backwards compatibility
|
||||
|
||||
|
||||
this._element.removeAttribute('title');
|
||||
}
|
||||
|
||||
@@ -600,8 +590,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
config.originalTitle = this._element.getAttribute('title') || '';
|
||||
|
||||
if (typeof config.title === 'number') {
|
||||
config.title = config.title.toString();
|
||||
}
|
||||
@@ -620,11 +608,13 @@
|
||||
if (this.constructor.Default[key] !== this._config[key]) {
|
||||
config[key] = this._config[key];
|
||||
}
|
||||
} // In the future can be replaced with:
|
||||
}
|
||||
|
||||
config.selector = false;
|
||||
config.trigger = 'manual'; // In the future can be replaced with:
|
||||
// const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]])
|
||||
// `Object.fromEntries(keysWithDifferentValues)`
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user