wishthis/semantic/dist/components/tab.min.js

11 lines
12 KiB
JavaScript
Raw Normal View History

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