| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  | /*! | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   * Bootstrap tab.js v5.3.0-alpha1 (https://getbootstrap.com/)
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
 | 
					
						
							| 
									
										
										
										
											2020-06-17 02:50:01 +08:00
										 |  |  |   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |   */ | 
					
						
							| 
									
										
										
										
											2018-07-24 08:51:14 +08:00
										 |  |  | (function (global, factory) { | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index.js'), require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './base-component'], factory) : | 
					
						
							|  |  |  |   (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.Index, global.EventHandler, global.SelectorEngine, global.BaseComponent)); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  | })(this, (function (index_js, EventHandler, SelectorEngine, BaseComponent) { 'use strict'; | 
					
						
							| 
									
										
										
										
											2021-02-11 00:14:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 23:41:51 +08:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * -------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |    * Bootstrap (v5.3.0-alpha1): tab.js | 
					
						
							| 
									
										
										
										
											2021-08-04 23:41:51 +08:00
										 |  |  |    * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 | 
					
						
							|  |  |  |    * -------------------------------------------------------------------------- | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 23:41:51 +08:00
										 |  |  |   /** | 
					
						
							| 
									
										
										
										
											2020-12-03 22:18:59 +08:00
										 |  |  |    * Constants | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |   const NAME = 'tab'; | 
					
						
							|  |  |  |   const DATA_KEY = 'bs.tab'; | 
					
						
							|  |  |  |   const EVENT_KEY = `.${DATA_KEY}`; | 
					
						
							|  |  |  |   const EVENT_HIDE = `hide${EVENT_KEY}`; | 
					
						
							|  |  |  |   const EVENT_HIDDEN = `hidden${EVENT_KEY}`; | 
					
						
							|  |  |  |   const EVENT_SHOW = `show${EVENT_KEY}`; | 
					
						
							|  |  |  |   const EVENT_SHOWN = `shown${EVENT_KEY}`; | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   const EVENT_CLICK_DATA_API = `click${EVENT_KEY}`; | 
					
						
							|  |  |  |   const EVENT_KEYDOWN = `keydown${EVENT_KEY}`; | 
					
						
							|  |  |  |   const EVENT_LOAD_DATA_API = `load${EVENT_KEY}`; | 
					
						
							|  |  |  |   const ARROW_LEFT_KEY = 'ArrowLeft'; | 
					
						
							|  |  |  |   const ARROW_RIGHT_KEY = 'ArrowRight'; | 
					
						
							|  |  |  |   const ARROW_UP_KEY = 'ArrowUp'; | 
					
						
							|  |  |  |   const ARROW_DOWN_KEY = 'ArrowDown'; | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |   const CLASS_NAME_ACTIVE = 'active'; | 
					
						
							|  |  |  |   const CLASS_NAME_FADE = 'fade'; | 
					
						
							|  |  |  |   const CLASS_NAME_SHOW = 'show'; | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   const CLASS_DROPDOWN = 'dropdown'; | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |   const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   const SELECTOR_DROPDOWN_MENU = '.dropdown-menu'; | 
					
						
							|  |  |  |   const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)'; | 
					
						
							|  |  |  |   const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]'; | 
					
						
							|  |  |  |   const SELECTOR_OUTER = '.nav-item, .list-group-item'; | 
					
						
							|  |  |  |   const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`; | 
					
						
							|  |  |  |   const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab`
 | 
					
						
							|  |  |  |   const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`; | 
					
						
							|  |  |  |   const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`; | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-08 14:39:10 +08:00
										 |  |  |   /** | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |    * Class definition | 
					
						
							| 
									
										
										
										
											2019-10-08 14:39:10 +08:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   class Tab extends BaseComponent { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     constructor(element) { | 
					
						
							|  |  |  |       super(element); | 
					
						
							|  |  |  |       this._parent = this._element.closest(SELECTOR_TAB_PANEL); | 
					
						
							|  |  |  |       if (!this._parent) { | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |         return; | 
					
						
							|  |  |  |         // todo: should Throw exception on v6
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       // Set up initial aria attributes
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       this._setInitialAttributes(this._parent, this._getChildren()); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Getters
 | 
					
						
							| 
									
										
										
										
											2021-05-14 00:22:20 +08:00
										 |  |  |     static get NAME() { | 
					
						
							|  |  |  |       return NAME; | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Public
 | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |     show() { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       // Shows this elem and deactivate the active sibling if exists
 | 
					
						
							|  |  |  |       const innerElem = this._element; | 
					
						
							|  |  |  |       if (this._elemIsActive(innerElem)) { | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       // Search for active tab on same parent to deactivate it
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       const active = this._getActiveElem(); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE, { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         relatedTarget: innerElem | 
					
						
							| 
									
										
										
										
											2021-02-11 00:14:51 +08:00
										 |  |  |       }) : null; | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW, { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         relatedTarget: active | 
					
						
							| 
									
										
										
										
											2019-03-02 00:31:34 +08:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) { | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       this._deactivate(active, innerElem); | 
					
						
							|  |  |  |       this._activate(innerElem, active); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Private
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     _activate(element, relatedElem) { | 
					
						
							|  |  |  |       if (!element) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       element.classList.add(CLASS_NAME_ACTIVE); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |       const complete = () => { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         if (element.getAttribute('role') !== 'tab') { | 
					
						
							| 
									
										
										
										
											2022-07-19 23:43:58 +08:00
										 |  |  |           element.classList.add(CLASS_NAME_SHOW); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |           return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         element.removeAttribute('tabindex'); | 
					
						
							|  |  |  |         element.setAttribute('aria-selected', true); | 
					
						
							|  |  |  |         this._toggleDropDown(element, true); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |         EventHandler.trigger(element, EVENT_SHOWN, { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |           relatedTarget: relatedElem | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2022-07-19 23:43:58 +08:00
										 |  |  |       this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     _deactivate(element, relatedElem) { | 
					
						
							|  |  |  |       if (!element) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       element.classList.remove(CLASS_NAME_ACTIVE); | 
					
						
							|  |  |  |       element.blur(); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       const complete = () => { | 
					
						
							|  |  |  |         if (element.getAttribute('role') !== 'tab') { | 
					
						
							| 
									
										
										
										
											2022-07-19 23:43:58 +08:00
										 |  |  |           element.classList.remove(CLASS_NAME_SHOW); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |           return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         element.setAttribute('aria-selected', false); | 
					
						
							|  |  |  |         element.setAttribute('tabindex', '-1'); | 
					
						
							|  |  |  |         this._toggleDropDown(element, false); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |         EventHandler.trigger(element, EVENT_HIDDEN, { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |           relatedTarget: relatedElem | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2017-10-01 05:28:03 +08:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2022-07-19 23:43:58 +08:00
										 |  |  |       this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     _keydown(event) { | 
					
						
							|  |  |  |       if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) { | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
 | 
					
						
							|  |  |  |       event.preventDefault(); | 
					
						
							|  |  |  |       const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       const nextActiveElement = index_js.getNextActiveElement(this._getChildren().filter(element => !index_js.isDisabled(element)), event.target, isNext, true); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       if (nextActiveElement) { | 
					
						
							| 
									
										
										
										
											2022-10-03 15:44:02 +08:00
										 |  |  |         nextActiveElement.focus({ | 
					
						
							|  |  |  |           preventScroll: true | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         Tab.getOrCreateInstance(nextActiveElement).show(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     _getChildren() { | 
					
						
							|  |  |  |       // collection of inner elements
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     _getActiveElem() { | 
					
						
							|  |  |  |       return this._getChildren().find(child => this._elemIsActive(child)) || null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     _setInitialAttributes(parent, children) { | 
					
						
							|  |  |  |       this._setAttributeIfNotExists(parent, 'role', 'tablist'); | 
					
						
							|  |  |  |       for (const child of children) { | 
					
						
							|  |  |  |         this._setInitialAttributesOnChild(child); | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     _setInitialAttributesOnChild(child) { | 
					
						
							|  |  |  |       child = this._getInnerElement(child); | 
					
						
							|  |  |  |       const isActive = this._elemIsActive(child); | 
					
						
							|  |  |  |       const outerElem = this._getOuterElement(child); | 
					
						
							|  |  |  |       child.setAttribute('aria-selected', isActive); | 
					
						
							|  |  |  |       if (outerElem !== child) { | 
					
						
							|  |  |  |         this._setAttributeIfNotExists(outerElem, 'role', 'presentation'); | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       if (!isActive) { | 
					
						
							|  |  |  |         child.setAttribute('tabindex', '-1'); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       this._setAttributeIfNotExists(child, 'role', 'tab'); | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       // set attributes to the related panel too
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       this._setInitialAttributesOnTargetPanel(child); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     _setInitialAttributesOnTargetPanel(child) { | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       const target = SelectorEngine.getElementFromSelector(child); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       if (!target) { | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       this._setAttributeIfNotExists(target, 'role', 'tabpanel'); | 
					
						
							|  |  |  |       if (child.id) { | 
					
						
							|  |  |  |         this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`); | 
					
						
							| 
									
										
										
										
											2019-02-12 03:15:34 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     _toggleDropDown(element, open) { | 
					
						
							|  |  |  |       const outerElem = this._getOuterElement(element); | 
					
						
							|  |  |  |       if (!outerElem.classList.contains(CLASS_DROPDOWN)) { | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2021-05-06 03:32:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       const toggle = (selector, className) => { | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |         const element = SelectorEngine.findOne(selector, outerElem); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         if (element) { | 
					
						
							|  |  |  |           element.classList.toggle(className, open); | 
					
						
							| 
									
										
										
										
											2018-07-24 08:51:14 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       }; | 
					
						
							|  |  |  |       toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE); | 
					
						
							|  |  |  |       toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW); | 
					
						
							|  |  |  |       outerElem.setAttribute('aria-expanded', open); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     _setAttributeIfNotExists(element, attribute, value) { | 
					
						
							|  |  |  |       if (!element.hasAttribute(attribute)) { | 
					
						
							|  |  |  |         element.setAttribute(attribute, value); | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     _elemIsActive(elem) { | 
					
						
							|  |  |  |       return elem.classList.contains(CLASS_NAME_ACTIVE); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Try to get the inner element (usually the .nav-link)
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     _getInnerElement(elem) { | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |       return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Try to get the outer element (usually the .nav-item)
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     _getOuterElement(elem) { | 
					
						
							|  |  |  |       return elem.closest(SELECTOR_OUTER) || elem; | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     // Static
 | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |     static jQueryInterface(config) { | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       return this.each(function () { | 
					
						
							| 
									
										
										
										
											2021-06-23 02:29:16 +08:00
										 |  |  |         const data = Tab.getOrCreateInstance(this); | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         if (typeof config !== 'string') { | 
					
						
							|  |  |  |           return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { | 
					
						
							|  |  |  |           throw new TypeError(`No method named "${config}"`); | 
					
						
							| 
									
										
										
										
											2017-10-01 05:28:03 +08:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |         data[config](); | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2021-03-24 00:26:54 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |   /** | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |    * Data API implementation | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { | 
					
						
							| 
									
										
										
										
											2021-05-06 03:32:12 +08:00
										 |  |  |     if (['A', 'AREA'].includes(this.tagName)) { | 
					
						
							|  |  |  |       event.preventDefault(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |     if (index_js.isDisabled(this)) { | 
					
						
							| 
									
										
										
										
											2021-05-06 03:32:12 +08:00
										 |  |  |       return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |     Tab.getOrCreateInstance(this).show(); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * Initialize on focus | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   EventHandler.on(window, EVENT_LOAD_DATA_API, () => { | 
					
						
							|  |  |  |     for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) { | 
					
						
							| 
									
										
										
										
											2022-05-13 14:07:23 +08:00
										 |  |  |       Tab.getOrCreateInstance(element); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-11-13 14:41:12 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * jQuery | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-25 00:37:22 +08:00
										 |  |  |   index_js.defineJQueryPlugin(Tab); | 
					
						
							| 
									
										
										
										
											2015-05-12 03:29:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return Tab; | 
					
						
							| 
									
										
										
										
											2018-07-24 08:51:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 23:50:18 +08:00
										 |  |  | })); | 
					
						
							| 
									
										
										
										
											2018-07-24 08:51:14 +08:00
										 |  |  | //# sourceMappingURL=tab.js.map
 |