[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/bootstrap/js/ -> alert.js (source)

   1  import { e as enableDismissTrigger, d as defineJQueryPlugin, B as BaseComponent, E as EventHandler } from './dom.js?5.1.3';
   2  
   3  /**
   4   * --------------------------------------------------------------------------
   5   * Bootstrap (v5.1.3): alert.js
   6   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
   7   * --------------------------------------------------------------------------
   8   */
   9  /**
  10   * ------------------------------------------------------------------------
  11   * Constants
  12   * ------------------------------------------------------------------------
  13   */
  14  
  15  const NAME = 'alert';
  16  const DATA_KEY = 'bs.alert';
  17  const EVENT_KEY = `.$DATA_KEY}`;
  18  const EVENT_CLOSE = `close$EVENT_KEY}`;
  19  const EVENT_CLOSED = `closed$EVENT_KEY}`;
  20  const CLASS_NAME_FADE = 'fade';
  21  const CLASS_NAME_SHOW = 'show';
  22  /**
  23   * ------------------------------------------------------------------------
  24   * Class Definition
  25   * ------------------------------------------------------------------------
  26   */
  27  
  28  class Alert extends BaseComponent {
  29    // Getters
  30    static get NAME() {
  31      return NAME;
  32    } // Public
  33  
  34  
  35    close() {
  36      const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  37  
  38      if (closeEvent.defaultPrevented) {
  39        return;
  40      }
  41  
  42      this._element.classList.remove(CLASS_NAME_SHOW);
  43  
  44      const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
  45  
  46      this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  47    } // Private
  48  
  49  
  50    _destroyElement() {
  51      this._element.remove();
  52  
  53      EventHandler.trigger(this._element, EVENT_CLOSED);
  54      this.dispose();
  55    } // Static
  56  
  57  
  58    static jQueryInterface(config) {
  59      return this.each(function () {
  60        const data = Alert.getOrCreateInstance(this);
  61  
  62        if (typeof config !== 'string') {
  63          return;
  64        }
  65  
  66        if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  67          throw new TypeError(`No method named "$config}"`);
  68        }
  69  
  70        data[config](this);
  71      });
  72    }
  73  
  74  }
  75  /**
  76   * ------------------------------------------------------------------------
  77   * Data Api implementation
  78   * ------------------------------------------------------------------------
  79   */
  80  
  81  
  82  enableDismissTrigger(Alert, 'close');
  83  /**
  84   * ------------------------------------------------------------------------
  85   * jQuery
  86   * ------------------------------------------------------------------------
  87   * add .Alert to jQuery only if jQuery is present
  88   */
  89  
  90  defineJQueryPlugin(Alert);
  91  
  92  window.bootstrap = window.bootstrap || {};
  93  window.bootstrap.Alert = Alert;
  94  
  95  if (Joomla && Joomla.getOptions) {
  96    // Get the elements/configurations from the PHP
  97    const alerts = Joomla.getOptions('bootstrap.alert'); // Initialise the elements
  98  
  99    if (alerts && alerts.length) {
 100      alerts.forEach(selector => {
 101        Array.from(document.querySelectorAll(selector)).map(el => new window.bootstrap.Alert(el));
 102      });
 103    }
 104  }
 105  
 106  export { Alert as A };


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer