11 lines
12 KiB
JavaScript
11 lines
12 KiB
JavaScript
|
/*
|
||
|
* # Fomantic UI - 2.8.8
|
||
|
* https://github.com/fomantic/Fomantic-UI
|
||
|
* http://fomantic-ui.com/
|
||
|
*
|
||
|
* Copyright 2021 Contributors
|
||
|
* Released under the MIT license
|
||
|
* http://opensource.org/licenses/MIT
|
||
|
*
|
||
|
*/
|
||
|
!function(j,O,k,I){"use strict";j.isWindow=j.isWindow||function(e){return null!=e&&e===e.window},j.isFunction=j.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},O=void 0!==O&&O.Math==Math?O:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),j.fn.tab=function(l){var d,u=j.isFunction(this)?j(O):j(this),b=u.selector||"",g=(new Date).getTime(),f=[],F=l,w="string"==typeof F,S=[].slice.call(arguments,1),E=!1;return u.each(function(){var h,o,p,v,m,y,T=j.isPlainObject(l)?j.extend(!0,{},j.fn.tab.settings,l):j.extend({},j.fn.tab.settings),L=T.className,A=T.metadata,t=T.selector,x=T.error,a=T.regExp,e="."+T.namespace,n="module-"+T.namespace,P=j(this),i={},C=!0,r=0,s=this,c=P.data(n);m={initialize:function(){m.debug("Initializing tab menu item",P),m.fix.callbacks(),m.determineTabs(),m.debug("Determining tabs",T.context,o),T.auto&&m.set.auto(),m.bind.events(),T.history&&!E&&(m.initializeHistory(),E=!0),T.autoTabActivation&&c===I&&null==m.determine.activeTab()&&(m.debug("No active tab detected, setting first tab active",m.get.initialPath()),m.changeTab(!0===T.autoTabActivation?m.get.initialPath():T.autoTabActivation)),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),c=m,P.data(n,m)},destroy:function(){m.debug("Destroying tabs",P),P.removeData(n).off(e)},bind:{events:function(){j.isWindow(s)||(m.debug("Attaching tab activation events to element",P),P.on("click"+e,m.event.click))}},determineTabs:function(){var e;"parent"===T.context?(0<P.closest(t.ui).length?(e=P.closest(t.ui),m.verbose("Using closest UI element as parent",e)):e=P,h=e.parent(),m.verbose("Determined parent element for creating context",h)):T.context?(h=j(T.context),m.verbose("Using selector for tab context",T.context,h)):h=j("body"),T.childrenOnly?(o=h.children(t.tabs),m.debug("Searching tab context children for tabs",h,o)):(o=h.find(t.tabs),m.debug("Searching tab context for tabs",h,o))},fix:{callbacks:function(){j.isPlainObject(l)&&(l.onTabLoad||l.onTabInit)&&(l.onTabLoad&&(l.onLoad=l.onTabLoad,delete l.onTabLoad,m.error(x.legacyLoad,l.onLoad)),l.onTabInit&&(l.onFirstLoad=l.onTabInit,delete l.onTabInit,m.error(x.legacyInit,l.onFirstLoad)),T=j.extend(!0,{},j.fn.tab.settings,l))}},initializeHistory:function(){if(m.debug("Initializing page state"),j.address===I)return m.error(x.state),!1;if("state"==T.historyType){if(m.debug("Using HTML5 to manage state"),!1===T.path)return m.error(x.path),!1;j.address.history(!0).state(T.path)}j.address.bind("change",m.event.history.change)},event:{click:function(e){var t=j(this).data(A.tab);t!==I?(T.history?(m.verbose("Updating page state",e),j.address.value(t)):(m.verbose("Changing tab",e),m.changeTab(t)),e.preventDefault()):m.debug("No tab specified")},history:{change:function(e){var t=e.pathNames.join("/")||m.get.initialPath(),a=T.templates.determineTitle(t)||!1;m.performance.display(),m.debug("History change event",t,e),y=e,t!==I&&m.changeTab(t),a&&j.address.title(a)}}},refresh:function(){p&&(m.debug("Refreshing tab",p),m.changeTab(p))},cache:{read:function(e){return e!==I&&i[e]},add:function(e,t){e=e||p,m.debug("Adding cached content for",e),i[e]=t},remove:function(e){e=e||p,m.debug("Removing cached content for",e),delete i[e]}},escape:{string:function(e){return(e=String(e)).replace(a.escape,"\\$&")}},set:{auto:function(){var e="string"==typeof T.path?T.path.replace(/\/$/,"")+"/{$tab}":"/{$tab}";m.verbose("Setting up automatic tab retrieval from server",e),j.isPlainObject(T.apiSettings)?T.apiSettings.url=e:T.apiSettings={url:e}},loading:function(e){var t=m.get.tabElement(e);t.hasClass(L.loading)||(m.verbose("Setting loading state for",t),t.addClass(L.loading).siblings(o).removeClass(L.active+" "+L.loading),0<t.length&&T.onRequest.call(t[0],e))},state:function(e){j.address.value(e)}},changeTab:function(u){var b=O.history&&O.history.pushState&&T.ignoreFirstLoad&&C,g=T.auto||j.isPlainObject(T.apiSettings),f=g&&!b?m.utilities.pathToArray(u):m.get.defaultPathArray(u);u=m.utilities.arrayToPath(f),j.each(f,function(e,t){var a,n,i,o,r=f.slice(0,e+1),s=m
|