1 | /*! |
||
2 | * Bootstrap alert.js v4.6.2 (https://getbootstrap.com/) |
||
3 | * Copyright 2011-2022 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' ? module.exports = factory(require('jquery'), require('./util.js')) : |
||
8 | typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) : |
||
0 ignored issues
–
show
|
|||
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.jQuery, global.Util)); |
||
0 ignored issues
–
show
The variable
globalThis seems to be never declared. If this is a global, consider adding a /** global: globalThis */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() Usage of the sequence operator is discouraged, since it may lead to obfuscated code.
The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression. This operator is most often used in Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator. This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements. var a,b,c;
a = 1, b = 1, c= 3;
could just as well be written as: var a,b,c;
a = 1;
b = 1;
c = 3;
To learn more about the sequence operator, please refer to the MDN. ![]() |
|||
10 | })(this, (function ($, Util) { 'use strict'; |
||
11 | |||
12 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } |
||
13 | |||
14 | var $__default = /*#__PURE__*/_interopDefaultLegacy($); |
||
15 | var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util); |
||
16 | |||
17 | function _defineProperties(target, props) { |
||
18 | for (var i = 0; i < props.length; i++) { |
||
19 | var descriptor = props[i]; |
||
20 | descriptor.enumerable = descriptor.enumerable || false; |
||
21 | descriptor.configurable = true; |
||
22 | if ("value" in descriptor) descriptor.writable = true; |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
23 | Object.defineProperty(target, descriptor.key, descriptor); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | function _createClass(Constructor, protoProps, staticProps) { |
||
28 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
29 | if (staticProps) _defineProperties(Constructor, staticProps); |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed. ![]() |
|||
30 | Object.defineProperty(Constructor, "prototype", { |
||
31 | writable: false |
||
32 | }); |
||
33 | return Constructor; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Constants |
||
38 | */ |
||
39 | |||
40 | var NAME = 'alert'; |
||
41 | var VERSION = '4.6.2'; |
||
42 | var DATA_KEY = 'bs.alert'; |
||
43 | var EVENT_KEY = "." + DATA_KEY; |
||
44 | var DATA_API_KEY = '.data-api'; |
||
45 | var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME]; |
||
46 | var CLASS_NAME_ALERT = 'alert'; |
||
47 | var CLASS_NAME_FADE = 'fade'; |
||
48 | var CLASS_NAME_SHOW = 'show'; |
||
49 | var EVENT_CLOSE = "close" + EVENT_KEY; |
||
50 | var EVENT_CLOSED = "closed" + EVENT_KEY; |
||
51 | var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; |
||
52 | var SELECTOR_DISMISS = '[data-dismiss="alert"]'; |
||
53 | /** |
||
54 | * Class definition |
||
55 | */ |
||
56 | |||
57 | var Alert = /*#__PURE__*/function () { |
||
58 | function Alert(element) { |
||
59 | this._element = element; |
||
60 | } // Getters |
||
61 | |||
62 | |||
63 | var _proto = Alert.prototype; |
||
64 | |||
65 | // Public |
||
66 | _proto.close = function close(element) { |
||
67 | var rootElement = this._element; |
||
68 | |||
69 | if (element) { |
||
70 | rootElement = this._getRootElement(element); |
||
71 | } |
||
72 | |||
73 | var customEvent = this._triggerCloseEvent(rootElement); |
||
74 | |||
75 | if (customEvent.isDefaultPrevented()) { |
||
76 | return; |
||
77 | } |
||
78 | |||
79 | this._removeElement(rootElement); |
||
80 | }; |
||
81 | |||
82 | _proto.dispose = function dispose() { |
||
83 | $__default["default"].removeData(this._element, DATA_KEY); |
||
84 | this._element = null; |
||
85 | } // Private |
||
86 | ; |
||
87 | |||
88 | _proto._getRootElement = function _getRootElement(element) { |
||
89 | var selector = Util__default["default"].getSelectorFromElement(element); |
||
90 | var parent = false; |
||
91 | |||
92 | if (selector) { |
||
93 | parent = document.querySelector(selector); |
||
94 | } |
||
95 | |||
96 | if (!parent) { |
||
97 | parent = $__default["default"](element).closest("." + CLASS_NAME_ALERT)[0]; |
||
98 | } |
||
99 | |||
100 | return parent; |
||
101 | }; |
||
102 | |||
103 | _proto._triggerCloseEvent = function _triggerCloseEvent(element) { |
||
104 | var closeEvent = $__default["default"].Event(EVENT_CLOSE); |
||
105 | $__default["default"](element).trigger(closeEvent); |
||
106 | return closeEvent; |
||
107 | }; |
||
108 | |||
109 | _proto._removeElement = function _removeElement(element) { |
||
110 | var _this = this; |
||
111 | |||
112 | $__default["default"](element).removeClass(CLASS_NAME_SHOW); |
||
113 | |||
114 | if (!$__default["default"](element).hasClass(CLASS_NAME_FADE)) { |
||
115 | this._destroyElement(element); |
||
116 | |||
117 | return; |
||
118 | } |
||
119 | |||
120 | var transitionDuration = Util__default["default"].getTransitionDurationFromElement(element); |
||
121 | $__default["default"](element).one(Util__default["default"].TRANSITION_END, function (event) { |
||
122 | return _this._destroyElement(element, event); |
||
123 | }).emulateTransitionEnd(transitionDuration); |
||
124 | }; |
||
125 | |||
126 | _proto._destroyElement = function _destroyElement(element) { |
||
127 | $__default["default"](element).detach().trigger(EVENT_CLOSED).remove(); |
||
128 | } // Static |
||
129 | ; |
||
130 | |||
131 | Alert._jQueryInterface = function _jQueryInterface(config) { |
||
132 | return this.each(function () { |
||
133 | var $element = $__default["default"](this); |
||
134 | var data = $element.data(DATA_KEY); |
||
135 | |||
136 | if (!data) { |
||
137 | data = new Alert(this); |
||
138 | $element.data(DATA_KEY, data); |
||
139 | } |
||
140 | |||
141 | if (config === 'close') { |
||
142 | data[config](this); |
||
143 | } |
||
144 | }); |
||
145 | }; |
||
146 | |||
147 | Alert._handleDismiss = function _handleDismiss(alertInstance) { |
||
148 | return function (event) { |
||
149 | if (event) { |
||
150 | event.preventDefault(); |
||
151 | } |
||
152 | |||
153 | alertInstance.close(this); |
||
154 | }; |
||
155 | }; |
||
156 | |||
157 | _createClass(Alert, null, [{ |
||
158 | key: "VERSION", |
||
159 | get: function get() { |
||
160 | return VERSION; |
||
161 | } |
||
162 | }]); |
||
163 | |||
164 | return Alert; |
||
165 | }(); |
||
166 | /** |
||
167 | * Data API implementation |
||
168 | */ |
||
169 | |||
170 | |||
171 | $__default["default"](document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert())); |
||
172 | /** |
||
173 | * jQuery |
||
174 | */ |
||
175 | |||
176 | $__default["default"].fn[NAME] = Alert._jQueryInterface; |
||
177 | $__default["default"].fn[NAME].Constructor = Alert; |
||
178 | |||
179 | $__default["default"].fn[NAME].noConflict = function () { |
||
180 | $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT; |
||
181 | return Alert._jQueryInterface; |
||
182 | }; |
||
183 | |||
184 | return Alert; |
||
185 | |||
186 | })); |
||
187 | //# sourceMappingURL=alert.js.map |
||
188 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.