[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/bootstrap/js/ -> tab.min.js (source)

   1  import{E as EventHandler,j as isDisabled,d as defineJQueryPlugin,B as BaseComponent,c as getElementFromSelector,S as SelectorEngine,r as reflow}from"./dom.min.js?5.1.3";const NAME="tab",DATA_KEY="bs.tab",EVENT_KEY=".bs.tab",DATA_API_KEY=".data-api",EVENT_HIDE="hide.bs.tab",EVENT_HIDDEN="hidden.bs.tab",EVENT_SHOW="show.bs.tab",EVENT_SHOWN="shown.bs.tab",EVENT_CLICK_DATA_API="click.bs.tab.data-api",CLASS_NAME_DROPDOWN_MENU="dropdown-menu",CLASS_NAME_ACTIVE="active",CLASS_NAME_FADE="fade",CLASS_NAME_SHOW="show",SELECTOR_DROPDOWN=".dropdown",SELECTOR_NAV_LIST_GROUP=".nav, .list-group",SELECTOR_ACTIVE=".active",SELECTOR_ACTIVE_UL=":scope > li > .active",SELECTOR_DATA_TOGGLE='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',SELECTOR_DROPDOWN_TOGGLE=".dropdown-toggle",SELECTOR_DROPDOWN_ACTIVE_CHILD=":scope > .dropdown-menu .active";class Tab extends BaseComponent{static get NAME(){return NAME}show(){if(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&this._element.classList.contains("active"))return;let e;const t=getElementFromSelector(this._element),a=this._element.closest(".nav, .list-group");if(a){const t="UL"===a.nodeName||"OL"===a.nodeName?SELECTOR_ACTIVE_UL:".active";e=SelectorEngine.find(t,a),e=e[e.length-1]}const n=e?EventHandler.trigger(e,EVENT_HIDE,{relatedTarget:this._element}):null;if(EventHandler.trigger(this._element,EVENT_SHOW,{relatedTarget:e}).defaultPrevented||null!==n&&n.defaultPrevented)return;this._activate(this._element,a);const s=()=>{EventHandler.trigger(e,EVENT_HIDDEN,{relatedTarget:this._element}),EventHandler.trigger(this._element,EVENT_SHOWN,{relatedTarget:e})};t?this._activate(t,t.parentNode,s):s()}_activate(e,t,a){const n=(!t||"UL"!==t.nodeName&&"OL"!==t.nodeName?SelectorEngine.children(t,".active"):SelectorEngine.find(SELECTOR_ACTIVE_UL,t))[0],s=a&&n&&n.classList.contains("fade"),o=()=>this._transitionComplete(e,n,a);n&&s?(n.classList.remove("show"),this._queueCallback(o,e,!0)):o()}_transitionComplete(e,t,a){if(t){t.classList.remove("active");const e=SelectorEngine.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD,t.parentNode);e&&e.classList.remove("active"),"tab"===t.getAttribute("role")&&t.setAttribute("aria-selected",!1)}e.classList.add("active"),"tab"===e.getAttribute("role")&&e.setAttribute("aria-selected",!0),reflow(e),e.classList.contains("fade")&&e.classList.add("show");let n=e.parentNode;if(n&&"LI"===n.nodeName&&(n=n.parentNode),n&&n.classList.contains("dropdown-menu")){const t=e.closest(".dropdown");t&&SelectorEngine.find(".dropdown-toggle",t).forEach((e=>e.classList.add("active"))),e.setAttribute("aria-expanded",!0)}a&&a()}static jQueryInterface(e){return this.each((function(){const t=Tab.getOrCreateInstance(this);if("string"==typeof e){if(void 0===t[e])throw new TypeError(`No method named "$e}"`);t[e]()}}))}}if(EventHandler.on(document,EVENT_CLICK_DATA_API,SELECTOR_DATA_TOGGLE,(function(e){if(["A","AREA"].includes(this.tagName)&&e.preventDefault(),isDisabled(this))return;Tab.getOrCreateInstance(this).show()})),defineJQueryPlugin(Tab),window.Joomla=window.Joomla||{},window.bootstrap=window.bootstrap||{},window.bootstrap.Tab=Tab,Joomla.initialiseTabs=(e,t)=>{if(e instanceof Element||!t.isJoomla)Array.from(document.querySelectorAll(`$e} a`)).map((e=>new window.bootstrap.Tab(e,t)));else{const t=document.querySelector(`$e}Content`);if(t){const a=Array.from(t.children);a.length&&a.forEach((t=>{if(!t.classList.contains("tab-pane"))return;const a=""!==t.dataset.active,n=document.querySelector(`$e}Tabs`);if(n){const e=document.createElement("a");e.href=`#$t.dataset.id}`,e.classList.add("nav-link"),a&&e.classList.add("active"),e.dataset.bsToggle="tab",e.setAttribute("role","tab"),e.setAttribute("aria-controls",t.dataset.id),e.setAttribute("aria-selected",t.dataset.id),e.innerHTML=Joomla.sanitizeHtml(t.dataset.title);const s=document.createElement("li");s.classList.add("nav-item"),s.setAttribute("role","presentation"),s.appendChild(e),n.appendChild(s),new window.bootstrap.Tab(s)}}))}}},Joomla&&Joomla.getOptions){const e=Joomla.getOptions("bootstrap.tabs");"object"==typeof e&&null!==e&&Object.keys(e).map((t=>Joomla.initialiseTabs(t,e[t])))}export{Tab as T};


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer