1import { E as EventHandler, d as defineJQueryPlugin, B as BaseComponent } from './dom.js?5.3.8'; 2 3/** 4 * -------------------------------------------------------------------------- 5 * Bootstrap button.js 6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 7 * -------------------------------------------------------------------------- 8 */ 9 10 11/** 12 * Constants 13 */ 14 15const NAME = 'button'; 16const DATA_KEY = 'bs.button'; 17const EVENT_KEY = `.${DATA_KEY}`; 18const DATA_API_KEY = '.data-api'; 19const CLASS_NAME_ACTIVE = 'active'; 20const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]'; 21const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`; 22 23/** 24 * Class definition 25 */ 26 27class Button extends BaseComponent { 28 // Getters 29 static get NAME() { 30 return NAME; 31 } 32 33 // Public 34 toggle() { 35 // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method 36 this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE)); 37 } 38 39 // Static 40 static jQueryInterface(config) { 41 return this.each(function () { 42 const data = Button.getOrCreateInstance(this); 43 if (config === 'toggle') { 44 data[config](); 45 } 46 }); 47 } 48} 49 50/** 51 * Data API implementation 52 */ 53 54EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => { 55 event.preventDefault(); 56 const button = event.target.closest(SELECTOR_DATA_TOGGLE); 57 const data = Button.getOrCreateInstance(button); 58 data.toggle(); 59}); 60 61/** 62 * jQuery 63 */ 64 65defineJQueryPlugin(Button); 66 67window.bootstrap = window.bootstrap || {}; 68window.bootstrap.Button = Button; 69if (Joomla && Joomla.getOptions) { 70 // Get the elements/configurations from the PHP 71 const buttons = Joomla.getOptions('bootstrap.button'); 72 // Initialise the elements 73 if (buttons && buttons.length) { 74 buttons.forEach(selector => { 75 document.querySelectorAll(selector).forEach(el => new window.bootstrap.Button(el)); 76 }); 77 } 78} 79 80export { Button as B };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.