- md5
- e8b003090ddbc05e0b3b22f424256989
- sha1
- 9904e3200fee01e8d17e81cac0d8d4de7725aad0
- sha256
- 6fed3d98f6fcc70d19593b5bf9f4d602e6bcccdbf2d28c0111dfd6958b789196
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
import { B as BaseComponent, D as Data, E as EventHandler, o as onDOMContentLoaded, b as getjQuery } from './dom-8eef6b5f.js';
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta1): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'button';
const DATA_KEY = 'bs.button';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const CLASS_NAME_ACTIVE = 'active';
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Button extends BaseComponent {
// Getters
static get DATA_KEY() {
return DATA_KEY
}
// Public
toggle() {
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
}
// Static
static jQueryInterface(config) {
return this.each(function () {
let data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Button(this);
}
if (config === 'toggle') {
data[config]();
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
event.preventDefault();
const button = event.target.closest(SELECTOR_DATA_TOGGLE);
let data = Data.getData(button, DATA_KEY);
if (!data) {
data = new Button(button);
}
data.toggle();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
*/
onDOMContentLoaded(() => {
const $ = getjQuery();
/* istanbul ignore if */
if ($) {
const JQUERY_NO_CONFLICT = $.fn[NAME];
$.fn[NAME] = Button.jQueryInterface;
$.fn[NAME].Constructor = Button;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Button.jQueryInterface
};
}
});
window.bootstrap = window.bootstrap || {};
window.bootstrap.Button = Button;
// Ensure vanilla mode, for consistency of the events
if (!Object.prototype.hasOwnProperty.call(document.body.dataset, 'bsNoJquery')) {
document.body.dataset.bsNoJquery = '';
}
if (Joomla && Joomla.getOptions) {
// Get the elements/configurations from the PHP
const buttons = Joomla.getOptions('bootstrap.button');
// Initialise the elements
if (buttons && buttons.length) {
buttons.forEach((selector) => {
Array.from(document.querySelectorAll(selector))
.map((el) => new window.bootstrap.Button(el));
});
}
}
export { Button as B };
No other release has this exact content. See every version of this file.