1
|
{"version":3,"sources":["../src/alert.js"],"names":["Alert","$","NAME","VERSION","DATA_KEY","EVENT_KEY","DATA_API_KEY","JQUERY_NO_CONFLICT","fn","Selector","DISMISS","Event","CLOSE","CLOSED","CLICK_DATA_API","ClassName","ALERT","FADE","SHOW","element","_element","close","rootElement","_getRootElement","customEvent","_triggerCloseEvent","isDefaultPrevented","_removeElement","dispose","removeData","selector","Util","getSelectorFromElement","parent","document","querySelector","closest","closeEvent","trigger","removeClass","hasClass","_destroyElement","transitionDuration","getTransitionDurationFromElement","one","TRANSITION_END","event","emulateTransitionEnd","detach","remove","_jQueryInterface","config","each","$element","data","_handleDismiss","alertInstance","preventDefault","on","Constructor","noConflict"],"mappings":";;;;AAGA;;;;;;AAOA,IAAMA,QAAS,UAACC,CAAD,EAAO;AACpB;;;;;AAMA,MAAMC,OAAsB,OAA5B;AACA,MAAMC,UAAsB,OAA5B;AACA,MAAMC,WAAsB,UAA5B;AACA,MAAMC,kBAA0BD,QAAhC;AACA,MAAME,eAAsB,WAA5B;AACA,MAAMC,qBAAsBN,EAAEO,EAAF,CAAKN,IAAL,CAA5B;AAEA,MAAMO,WAAW;AACfC,aAAU;AADK,GAAjB;AAIA,MAAMC,QAAQ;AACZC,qBAAyBP,SADb;AAEZQ,uBAA0BR,SAFd;AAGZS,8BAAyBT,SAAzB,GAAqCC;AAHzB,GAAd;AAMA,MAAMS,YAAY;AAChBC,WAAQ,OADQ;AAEhBC,UAAQ,MAFQ;AAGhBC,UAAQ;AAGV;;;;;;AANkB,GAAlB;;AAxBoB,MAoCdlB,KApCc;AAAA;AAAA;AAqClB,mBAAYmB,OAAZ,EAAqB;AACnB,WAAKC,QAAL,GAAgBD,OAAhB;AACD,KAvCiB,CAyClB;;;AAzCkB;;AA+ClB;AA/CkB,WAiDlBE,KAjDkB,kBAiDZF,OAjDY,EAiDH;AACb,UAAIG,cAAc,KAAKF,QAAvB;;AACA,UAAID,OAAJ,EAAa;AACXG,sBAAc,KAAKC,eAAL,C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AACAjD,IAAEO,EAAF,CAAKN,IAAL,EAAWyD,WAAX,GAAyB3D,KAAzB;;AACAC,IAAEO,EAAF,CAAKN,IAAL,EAAW0D,UAAX,GAAyB,YAAY;AACnC3D,MAAEO,EAAF,CAAKN,IAAL,IAAaK,kBAAb;AACA,WAAOP,MAAMkD,gBAAb;AACD,GAHD;;AAKA,SAAOlD,KAAP;AACD,CA1Ka,CA0KXC,CA1KW,CAAd","sourcesContent":["import $ from 'jquery'\nimport Util from './util'\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.1.2): alert.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Alert = (($) => {\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'alert'\n const VERSION = '4.1.2'\n const DATA_KEY = 'bs.alert'\n const EVENT_KEY = `.${DATA_KEY}`\n const DATA_API_KEY = '.data-api'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n\n const Selector = {\n DISMISS : '[data-dismiss=\"alert\"]'\n }\n\n const Event = {\n CLOSE : `close${EVENT_KEY}`,\n CLOSED : `closed${EVENT_KEY}`,\n CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`\n }\n\n const ClassName = {\n ALERT : 'alert',\n FADE : 'fade',\n SHOW : 'show'\n }\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Alert {\n constructor(element) {\n this._element = element\n }\n\n // Getters\n\n static get VERSION() {\n return VERSION\n }\n\n // Public\n\n close(element) {\n let rootElement = this._element\n if (element) {\n rootElement = this._getRootElement(element)\n }\n\n const customEvent = this._triggerCloseEvent(rootElement)\n\n if (customEvent.isDefaultPrevented()) {\n return\n }\n\n this._removeElement(rootElement)\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n this._element = null\n }\n\n // Private\n\n _getRootElement(element) {\n const selector = Util.getSelectorFromElement(element)\n let parent = false\n\n if (selector) {\n parent = document.querySelector(selector)\n }\n\n if (!parent) {\n parent = $(element).closest(`.${ClassName.ALERT}`)[0]\n }\n\n return parent\n }\n\n _triggerCloseEvent(element) {\n const closeEvent = $.Event(Event.CLOSE)\n\n $(element).trigger(closeEvent)\n return closeEvent\n }\n\n _removeElement(element) {\n $(element).removeClass(ClassName.SHOW)\n\n if (!$(element).hasClass(ClassName.FADE)) {\n this._destroyElement(element)\n return\n }\n\n const transitionDuration = Util.getTransitionDurationFromElement(element)\n\n $(element)\n .one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))\n .emulateTransitionEnd(transitionDuration)\n }\n\n _destroyElement(element) {\n $(element)\n .detach()\n .trigger(Event.CLOSED)\n .remove()\n }\n\n // Static\n\n static _jQueryInterface(config) {\n return this.each(function () {\n const $element = $(this)\n let data = $element.data(DATA_KEY)\n\n if (!data) {\n data = new Alert(this)\n $element.data(DATA_KEY, data)\n }\n\n if (config === 'close') {\n data[config](this)\n }\n })\n }\n\n static _handleDismiss(alertInstance) {\n return function (event) {\n if (event) {\n event.preventDefault()\n }\n\n alertInstance.close(this)\n }\n }\n }\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document).on(\n Event.CLICK_DATA_API,\n Selector.DISMISS,\n Alert._handleDismiss(new Alert())\n )\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Alert._jQueryInterface\n $.fn[NAME].Constructor = Alert\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Alert._jQueryInterface\n }\n\n return Alert\n})($)\n\nexport default Alert\n"],"file":"alert.js"}
|