diff options
author | Johann-S <johann.servoire@gmail.com> | 2017-08-23 13:03:50 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2019-02-20 23:05:45 +0300 |
commit | 2970d14dd91bf1f5f236766c856e81c297fa1390 (patch) | |
tree | 36e6b14473bd1973e2fcf44a00badad0e645dfc3 /js/src/alert.js | |
parent | a3398fffd6e5b73a6a2cc2a1fc454ab199b2bf82 (diff) |
Remove jQuery from alert.js and add .alert only if jQuery is available
Diffstat (limited to 'js/src/alert.js')
-rw-r--r-- | js/src/alert.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/js/src/alert.js b/js/src/alert.js index 5e99f6d011..c530b2996b 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -85,8 +85,7 @@ class Alert { let parent = false if (selector) { - const tmpSelected = SelectorEngine.find(selector) - parent = tmpSelected[0] + parent = SelectorEngine.find(selector)[0] } if (!parent) { @@ -136,16 +135,6 @@ class Alert { } }) } - - static _handleDismiss(alertInstance) { - return function (event) { - if (event) { - event.preventDefault() - } - - alertInstance.close(this) - } - } } /** @@ -159,13 +148,17 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleD * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .alert to jQuery only if jQuery is present */ -$.fn[NAME] = Alert._jQueryInterface -$.fn[NAME].Constructor = Alert -$.fn[NAME].noConflict = () => { - $.fn[NAME] = JQUERY_NO_CONFLICT - return Alert._jQueryInterface +if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') { + const $ = window.$ || window.jQuery + $.fn[NAME] = Alert._jQueryInterface + $.fn[NAME].Constructor = Alert + $.fn[NAME].noConflict = () => { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Alert._jQueryInterface + } } export default Alert |