Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2017-08-23 13:03:50 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-02-20 23:05:45 +0300
commit2970d14dd91bf1f5f236766c856e81c297fa1390 (patch)
tree36e6b14473bd1973e2fcf44a00badad0e645dfc3 /js/src/alert.js
parenta3398fffd6e5b73a6a2cc2a1fc454ab199b2bf82 (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.js27
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