1 | /*! |
||
2 | * Bootstrap tab.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 | View Code Duplication | (function (global, factory) { |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
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
The variable
define seems to be never declared. If this is a global, consider adding a /** global: define */ 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. ![]() |
|||
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = 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 = 'tab'; |
||
41 | var VERSION = '4.6.2'; |
||
42 | var DATA_KEY = 'bs.tab'; |
||
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_DROPDOWN_MENU = 'dropdown-menu'; |
||
47 | var CLASS_NAME_ACTIVE = 'active'; |
||
48 | var CLASS_NAME_DISABLED = 'disabled'; |
||
49 | var CLASS_NAME_FADE = 'fade'; |
||
50 | var CLASS_NAME_SHOW = 'show'; |
||
51 | var EVENT_HIDE = "hide" + EVENT_KEY; |
||
52 | var EVENT_HIDDEN = "hidden" + EVENT_KEY; |
||
53 | var EVENT_SHOW = "show" + EVENT_KEY; |
||
54 | var EVENT_SHOWN = "shown" + EVENT_KEY; |
||
55 | var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; |
||
56 | var SELECTOR_DROPDOWN = '.dropdown'; |
||
57 | var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; |
||
58 | var SELECTOR_ACTIVE = '.active'; |
||
59 | var SELECTOR_ACTIVE_UL = '> li > .active'; |
||
60 | var SELECTOR_DATA_TOGGLE = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]'; |
||
61 | var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; |
||
62 | var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active'; |
||
63 | /** |
||
64 | * Class definition |
||
65 | */ |
||
66 | |||
67 | var Tab = /*#__PURE__*/function () { |
||
68 | function Tab(element) { |
||
69 | this._element = element; |
||
70 | } // Getters |
||
71 | |||
72 | |||
73 | var _proto = Tab.prototype; |
||
74 | |||
75 | // Public |
||
76 | _proto.show = function show() { |
||
77 | var _this = this; |
||
78 | |||
79 | if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $__default["default"](this._element).hasClass(CLASS_NAME_ACTIVE) || $__default["default"](this._element).hasClass(CLASS_NAME_DISABLED) || this._element.hasAttribute('disabled')) { |
||
0 ignored issues
–
show
The variable
Node seems to be never declared. If this is a global, consider adding a /** global: Node */ 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. ![]() |
|||
80 | return; |
||
81 | } |
||
82 | |||
83 | var target; |
||
84 | var previous; |
||
85 | var listElement = $__default["default"](this._element).closest(SELECTOR_NAV_LIST_GROUP)[0]; |
||
86 | var selector = Util__default["default"].getSelectorFromElement(this._element); |
||
87 | |||
88 | if (listElement) { |
||
89 | var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE; |
||
90 | previous = $__default["default"].makeArray($__default["default"](listElement).find(itemSelector)); |
||
91 | previous = previous[previous.length - 1]; |
||
92 | } |
||
93 | |||
94 | var hideEvent = $__default["default"].Event(EVENT_HIDE, { |
||
95 | relatedTarget: this._element |
||
96 | }); |
||
97 | var showEvent = $__default["default"].Event(EVENT_SHOW, { |
||
98 | relatedTarget: previous |
||
0 ignored issues
–
show
|
|||
99 | }); |
||
100 | |||
101 | if (previous) { |
||
102 | $__default["default"](previous).trigger(hideEvent); |
||
103 | } |
||
104 | |||
105 | $__default["default"](this._element).trigger(showEvent); |
||
106 | |||
107 | if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { |
||
108 | return; |
||
109 | } |
||
110 | |||
111 | if (selector) { |
||
112 | target = document.querySelector(selector); |
||
113 | } |
||
114 | |||
115 | this._activate(this._element, listElement); |
||
116 | |||
117 | var complete = function complete() { |
||
118 | var hiddenEvent = $__default["default"].Event(EVENT_HIDDEN, { |
||
119 | relatedTarget: _this._element |
||
120 | }); |
||
121 | var shownEvent = $__default["default"].Event(EVENT_SHOWN, { |
||
122 | relatedTarget: previous |
||
0 ignored issues
–
show
|
|||
123 | }); |
||
124 | $__default["default"](previous).trigger(hiddenEvent); |
||
125 | $__default["default"](_this._element).trigger(shownEvent); |
||
126 | }; |
||
127 | |||
128 | if (target) { |
||
129 | this._activate(target, target.parentNode, complete); |
||
130 | } else { |
||
131 | complete(); |
||
132 | } |
||
133 | }; |
||
134 | |||
135 | _proto.dispose = function dispose() { |
||
136 | $__default["default"].removeData(this._element, DATA_KEY); |
||
137 | this._element = null; |
||
138 | } // Private |
||
139 | ; |
||
140 | |||
141 | _proto._activate = function _activate(element, container, callback) { |
||
142 | var _this2 = this; |
||
143 | |||
144 | var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $__default["default"](container).find(SELECTOR_ACTIVE_UL) : $__default["default"](container).children(SELECTOR_ACTIVE); |
||
145 | var active = activeElements[0]; |
||
146 | var isTransitioning = callback && active && $__default["default"](active).hasClass(CLASS_NAME_FADE); |
||
147 | |||
148 | var complete = function complete() { |
||
149 | return _this2._transitionComplete(element, active, callback); |
||
150 | }; |
||
151 | |||
152 | if (active && isTransitioning) { |
||
153 | var transitionDuration = Util__default["default"].getTransitionDurationFromElement(active); |
||
154 | $__default["default"](active).removeClass(CLASS_NAME_SHOW).one(Util__default["default"].TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
155 | } else { |
||
156 | complete(); |
||
157 | } |
||
158 | }; |
||
159 | |||
160 | _proto._transitionComplete = function _transitionComplete(element, active, callback) { |
||
161 | if (active) { |
||
162 | $__default["default"](active).removeClass(CLASS_NAME_ACTIVE); |
||
163 | var dropdownChild = $__default["default"](active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0]; |
||
164 | |||
165 | if (dropdownChild) { |
||
166 | $__default["default"](dropdownChild).removeClass(CLASS_NAME_ACTIVE); |
||
167 | } |
||
168 | |||
169 | if (active.getAttribute('role') === 'tab') { |
||
170 | active.setAttribute('aria-selected', false); |
||
171 | } |
||
172 | } |
||
173 | |||
174 | $__default["default"](element).addClass(CLASS_NAME_ACTIVE); |
||
175 | |||
176 | if (element.getAttribute('role') === 'tab') { |
||
177 | element.setAttribute('aria-selected', true); |
||
178 | } |
||
179 | |||
180 | Util__default["default"].reflow(element); |
||
181 | |||
182 | if (element.classList.contains(CLASS_NAME_FADE)) { |
||
183 | element.classList.add(CLASS_NAME_SHOW); |
||
184 | } |
||
185 | |||
186 | var parent = element.parentNode; |
||
187 | |||
188 | if (parent && parent.nodeName === 'LI') { |
||
189 | parent = parent.parentNode; |
||
190 | } |
||
191 | |||
192 | if (parent && $__default["default"](parent).hasClass(CLASS_NAME_DROPDOWN_MENU)) { |
||
193 | var dropdownElement = $__default["default"](element).closest(SELECTOR_DROPDOWN)[0]; |
||
194 | |||
195 | if (dropdownElement) { |
||
196 | var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE)); |
||
197 | $__default["default"](dropdownToggleList).addClass(CLASS_NAME_ACTIVE); |
||
198 | } |
||
199 | |||
200 | element.setAttribute('aria-expanded', true); |
||
201 | } |
||
202 | |||
203 | if (callback) { |
||
204 | callback(); |
||
205 | } |
||
206 | } // Static |
||
207 | ; |
||
208 | |||
209 | Tab._jQueryInterface = function _jQueryInterface(config) { |
||
210 | return this.each(function () { |
||
211 | var $this = $__default["default"](this); |
||
212 | var data = $this.data(DATA_KEY); |
||
213 | |||
214 | if (!data) { |
||
215 | data = new Tab(this); |
||
216 | $this.data(DATA_KEY, data); |
||
217 | } |
||
218 | |||
219 | if (typeof config === 'string') { |
||
220 | if (typeof data[config] === 'undefined') { |
||
221 | throw new TypeError("No method named \"" + config + "\""); |
||
222 | } |
||
223 | |||
224 | data[config](); |
||
225 | } |
||
226 | }); |
||
227 | }; |
||
228 | |||
229 | _createClass(Tab, null, [{ |
||
230 | key: "VERSION", |
||
231 | get: function get() { |
||
232 | return VERSION; |
||
233 | } |
||
234 | }]); |
||
235 | |||
236 | return Tab; |
||
237 | }(); |
||
238 | /** |
||
239 | * Data API implementation |
||
240 | */ |
||
241 | |||
242 | |||
243 | $__default["default"](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { |
||
244 | event.preventDefault(); |
||
245 | |||
246 | Tab._jQueryInterface.call($__default["default"](this), 'show'); |
||
247 | }); |
||
248 | /** |
||
249 | * jQuery |
||
250 | */ |
||
251 | |||
252 | $__default["default"].fn[NAME] = Tab._jQueryInterface; |
||
253 | $__default["default"].fn[NAME].Constructor = Tab; |
||
254 | |||
255 | $__default["default"].fn[NAME].noConflict = function () { |
||
256 | $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT; |
||
257 | return Tab._jQueryInterface; |
||
258 | }; |
||
259 | |||
260 | return Tab; |
||
261 | |||
262 | })); |
||
263 | //# sourceMappingURL=tab.js.map |
||
264 |