PageSourceSearch

https://sathmarerschwaben.de/media/vendor/bootstrap/js/dropdown.js?5.3.8

js sathmarerschwaben.de collected 2026-10-02 19:51:07 UTC 13,909 bytes, 393 lines download raw bytes

vendor: 11,455 bytes, lines 1-323
1import { P as Popper, c as createPopper } from './popper.js?5.3.8';
2import { c as isRTL, E as EventHandler, d as defineJQueryPlugin, B as BaseComponent, S as SelectorEngine, f as isDisabled, n as noop, M as Manipulator, h as isElement, g as getElement, j as execute, i as isVisible, b as getNextActiveElement } from './dom.js?5.3.8';
3
4/**
5 * --------------------------------------------------------------------------
6 * Bootstrap dropdown.js
7 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
8 * --------------------------------------------------------------------------
9 */
10
11
12/**
13 * Constants
14 */
15
16const NAME = 'dropdown';
17const DATA_KEY = 'bs.dropdown';
18const EVENT_KEY = `.${DATA_KEY}`;
19const DATA_API_KEY = '.data-api';
20const ESCAPE_KEY = 'Escape';
21const TAB_KEY = 'Tab';
22const ARROW_UP_KEY = 'ArrowUp';
23const ARROW_DOWN_KEY = 'ArrowDown';
24const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
25
26const EVENT_HIDE = `hide${EVENT_KEY}`;
27const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
28const EVENT_SHOW = `show${EVENT_KEY}`;
29const EVENT_SHOWN = `shown${EVENT_KEY}`;
30const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
31const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
32const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
33const CLASS_NAME_SHOW = 'show';
34const CLASS_NAME_DROPUP = 'dropup';
35const CLASS_NAME_DROPEND = 'dropend';
36const CLASS_NAME_DROPSTART = 'dropstart';
37const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
38const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
39const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
40const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`;
41const SELECTOR_MENU = '.dropdown-menu';
42const SELECTOR_NAVBAR = '.navbar';
43const SELECTOR_NAVBAR_NAV = '.navbar-nav';
44const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
45const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start';
46const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end';
47const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start';
48const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end';
49const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start';
50const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start';
51const PLACEMENT_TOPCENTER = 'top';
52const PLACEMENT_BOTTOMCENTER = 'bottom';
53const Default = {
54  autoClose: true,
55  boundary: 'clippingParents',
56  display: 'dynamic',
57  offset: [0, 2],
58  popperConfig: null,
59  reference: 'toggle'
60};
61const DefaultType = {
62  autoClose: '(boolean|string)',
63  boundary: '(string|element)',
64  display: 'string',
65  offset: '(array|string|function)',
66  popperConfig: '(null|object|function)',
67  reference: '(string|element|object)'
68};
69
70/**
71 * Class definition
72 */
73
74class Dropdown extends BaseComponent {
75  constructor(element, config) {
76    super(element, config);
77    this._popper = null;
78    this._parent = this._element.parentNode; // dropdown wrapper
79    // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
80    this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
81    this._inNavbar = this._detectNavbar();
82  }
83
84  // Getters
85  static get Default() {
86    return Default;
87  }
88  static get DefaultType() {
89    return DefaultType;
90  }
91  static get NAME() {
92    return NAME;
93  }
94
95  // Public
96  toggle() {
97    return this._isShown() ? this.hide() : this.show();
98  }
99  show() {
100    if (isDisabled(this._element) || this._isShown()) {
101      return;
102    }
103    const relatedTarget = {
104      relatedTarget: this._element
105    };
106    const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget);
107    if (showEvent.defaultPrevented) {
108      return;
109    }
110    this._createPopper();
111
112    // If this is a touch-enabled device we add extra
113    // empty mouseover listeners to the body's immediate children;
114    // only needed because of broken event delegation on iOS
115    // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
116    if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
117      for (const element of [].concat(...document.body.children)) {
118        EventHandler.on(element, 'mouseover', noop);
119      }
120    }
121    this._element.focus();
122    this._element.setAttribute('aria-expanded', true);
123    this._menu.classList.add(CLASS_NAME_SHOW);
124    this._element.classList.add(CLASS_NAME_SHOW);
125    EventHandler.trigger(this._element, EVENT_SHOWN, relatedTarget);
126  }
127  hide() {
128    if (isDisabled(this._element) || !this._isShown()) {
129      return;
130    }
131    const relatedTarget = {
132      relatedTarget: this._element
133    };
134    this._completeHide(relatedTarget);
135  }
136  dispose() {
137    if (this._popper) {
138      this._popper.destroy();
139    }
140    super.dispose();
141  }
142  update() {
143    this._inNavbar = this._detectNavbar();
144    if (this._popper) {
145      this._popper.update();
146    }
147  }
148
149  // Private
150  _completeHide(relatedTarget) {
151    const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget);
152    if (hideEvent.defaultPrevented) {
153      return;
154    }
155
156    // If this is a touch-enabled device we remove the extra
157    // empty mouseover listeners we added for iOS support
158    if ('ontouchstart' in document.documentElement) {
159      for (const element of [].concat(...document.body.children)) {
160        EventHandler.off(element, 'mouseover', noop);
161      }
162    }
163    if (this._popper) {
164      this._popper.destroy();
165    }
166    this._menu.classList.remove(CLASS_NAME_SHOW);
167    this._element.classList.remove(CLASS_NAME_SHOW);
168    this._element.setAttribute('aria-expanded', 'false');
169    Manipulator.removeDataAttribute(this._menu, 'popper');
170    EventHandler.trigger(this._element, EVENT_HIDDEN, relatedTarget);
171  }
172  _getConfig(config) {
173    config = super._getConfig(config);
174    if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
175      // Popper virtual elements require a getBoundingClientRect method
176      throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
177    }
178    return config;
179  }
180  _createPopper() {
181    if (typeof Popper === 'undefined') {
182      throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org/docs/v2/)');
183    }
184    let referenceElement = this._element;
185    if (this._config.reference === 'parent') {
186      referenceElement = this._parent;
187    } else if (isElement(this._config.reference)) {
188      referenceElement = getElement(this._config.reference);
189    } else if (typeof this._config.reference === 'object') {
190      referenceElement = this._config.reference;
191    }
192    const popperConfig = this._getPopperConfig();
193    this._popper = createPopper(referenceElement, this._menu, popperConfig);
194  }
195  _isShown() {
196    return this._menu.classList.contains(CLASS_NAME_SHOW);
197  }
198  _getPlacement() {
199    const parentDropdown = this._parent;
200    if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
201      return PLACEMENT_RIGHT;
202    }
203    if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
204      return PLACEMENT_LEFT;
205    }
206    if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
207      return PLACEMENT_TOPCENTER;
208    }
209    if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
210      return PLACEMENT_BOTTOMCENTER;
211    }
212
213    // We need to trim the value because custom properties can also include spaces
214    const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
215    if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
216      return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
217    }
218    return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
219  }
220  _detectNavbar() {
221    return this._element.closest(SELECTOR_NAVBAR) !== null;
222  }
223  _getOffset() {
224    const {
225      offset
226    } = this._config;
227    if (typeof offset === 'string') {
228      return offset.split(',').map(value => Number.parseInt(value, 10));
229    }
230    if (typeof offset === 'function') {
231      return popperData => offset(popperData, this._element);
232    }
233    return offset;
234  }
235  _getPopperConfig() {
236    const defaultBsPopperConfig = {
237      placement: this._getPlacement(),
238      modifiers: [{
239        name: 'preventOverflow',
240        options: {
241          boundary: this._config.boundary
242        }
243      }, {
244        name: 'offset',
245        options: {
246          offset: this._getOffset()
247        }
248      }]
249    };
250
251    // Disable Popper if we have a static display or Dropdown is in Navbar
252    if (this._inNavbar || this._config.display === 'static') {
253      Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
254      defaultBsPopperConfig.modifiers = [{
255        name: 'applyStyles',
256        enabled: false
257      }];
258    }
259    return {
260      ...defaultBsPopperConfig,
261      ...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
262    };
263  }
264  _selectMenuItem({
265    key,
266    target
267  }) {
268    const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element));
269    if (!items.length) {
270      return;
271    }
272
273    // if target isn't included in items (e.g. when expanding the dropdown)
274    // allow cycling to get the last item in case key equals ARROW_UP_KEY
275    getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
276  }
277
278  // Static
279  static jQueryInterface(config) {
280    return this.each(function () {
281      const data = Dropdown.getOrCreateInstance(this, config);
282      if (typeof config !== 'string') {
283        return;
284      }
285      if (typeof data[config] === 'undefined') {
286        throw new TypeError(`No method named "${config}"`);
287      }
288      data[config]();
289    });
290  }
291  static clearMenus(event) {
292    if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY) {
293      return;
294    }
295    const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
296    for (const toggle of openToggles) {
297      const context = Dropdown.getInstance(toggle);
298      if (!context || context._config.autoClose === false) {
299        continue;
300      }
301      const composedPath = event.composedPath();
302      const isMenuTarget = composedPath.includes(context._menu);
303      if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
304        continue;
305      }
306
307      // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
308      if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) {
309        continue;
310      }
311      const relatedTarget = {
312        relatedTarget: context._element
313      };
314      if (event.type === 'click') {
315        relatedTarget.clickEvent = event;
316      }
317      context._completeHide(relatedTarget);
318    }
319  }
320  static dataApiKeydownHandler(event) {
321    // If not an UP | DOWN | ESCAPE key => not a dropdown command
322    // If input/textarea && if key is other than ESCAPE => not a dropdown command
323
324    const isInput = /input|textarea/i.test(event.target.tagName);
325    const isEscapeEvent = event.key === ESCAPE_KEY;
326    const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key);
327    if (!isUpOrDownEvent && !isEscapeEvent) {
328      return;
329    }
330    if (isInput && !isEscapeEvent) {
331      return;
332    }
333    event.preventDefault();
334
335    // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
336    const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode);
337    const instance = Dropdown.getOrCreateInstance(getToggleButton);
338    if (isUpOrDownEvent) {
339      event.stopPropagation();
340      instance.show();
341      instance._selectMenuItem(event);
342      return;
343    }
344    if (instance._isShown()) {
345      // else is escape and we check if it is shown
346      event.stopPropagation();
347      instance.hide();
348      getToggleButton.focus();
349    }
350  }
351}
352
353/**
354 * Data API implementation
355 */
356
357EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
358EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
359EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
360EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
361EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
362  event.preventDefault();
363  Dropdown.getOrCreateInstance(this).toggle();
364});
365
366/**
367 * jQuery
368 */
369
370defineJQueryPlugin(Dropdown);
371
372window.bootstrap = window.bootstrap || {};
373window.bootstrap.Dropdown = Dropdown;
374if (Joomla && Joomla.getOptions) {
375  // Get the elements/configurations from the PHP
376  const dropdowns = Joomla.getOptions('bootstrap.dropdown');
377  // Initialise the elements
378  if (typeof dropdowns === 'object' && dropdowns !== null) {
379    Object.keys(dropdowns).forEach(dropdown => {
380      const opt = dropdowns[dropdown];
381      const options = {
382        interval: opt.interval ? opt.interval : 5000,
383        pause: opt.pause ? opt.pause : 'hover'
384      };
385      const elements = Array.from(document.querySelectorAll(dropdown));
386      if (elements.length) {
387        elements.map(el => new window.bootstrap.Dropdown(el, options));
388      }
389    });
390  }
391}
392
393export { Dropdown as D };

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.