You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
2.0 KiB

5 months ago
  1. /*!
  2. * Bootstrap component-functions.js v5.3.3 (https://getbootstrap.com/)
  3. * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('../dom/event-handler.js'), require('../dom/selector-engine.js'), require('./index.js')) :
  8. typeof define === 'function' && define.amd ? define(['exports', '../dom/event-handler', '../dom/selector-engine', './index'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComponentFunctions = {}, global.EventHandler, global.SelectorEngine, global.Index));
  10. })(this, (function (exports, EventHandler, SelectorEngine, index_js) { 'use strict';
  11. /**
  12. * --------------------------------------------------------------------------
  13. * Bootstrap util/component-functions.js
  14. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15. * --------------------------------------------------------------------------
  16. */
  17. const enableDismissTrigger = (component, method = 'hide') => {
  18. const clickEvent = `click.dismiss${component.EVENT_KEY}`;
  19. const name = component.NAME;
  20. EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
  21. if (['A', 'AREA'].includes(this.tagName)) {
  22. event.preventDefault();
  23. }
  24. if (index_js.isDisabled(this)) {
  25. return;
  26. }
  27. const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
  28. const instance = component.getOrCreateInstance(target);
  29. // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
  30. instance[method]();
  31. });
  32. };
  33. exports.enableDismissTrigger = enableDismissTrigger;
  34. Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  35. }));
  36. //# sourceMappingURL=component-functions.js.map