You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
9.0 KiB

  1. !function(a,b,c,d){"use strict";a.tab=a.fn.tab=function(c){var e,f,g=a(a.isFunction(this)?b:this),h=a.isPlainObject(c)?a.extend(!0,{},a.fn.tab.settings,c):a.extend({},a.fn.tab.settings),i=g.selector||"",j=(new Date).getTime(),k=[],l=arguments[0],m="string"==typeof l,n=[].slice.call(arguments,1);return g.each(function(){var c,o,p,q,r=h.className,s=h.metadata,t=h.selector,u=h.error,v="."+h.namespace,w="module-"+h.namespace,x=a(this),y=a(t.tabs),z={},A=!0,B=0,C=this,D=x.data(w);e={initialize:function(){e.debug("Initializing tab menu item",x),h.context&&(e.determineTabs(),e.debug("Using only tabs inside context",h.context,y)),h.auto&&(e.verbose("Setting up automatic tab retrieval from server"),h.apiSettings={url:h.path+"/{$tab}"}),a.isWindow(C)||(e.debug("Attaching tab activation events to element",x),x.on("click"+v,e.event.click)),e.instantiate()},determineTabs:function(){var b;"parent"===h.context?(x.closest("."+r.ui).size()>0?(b=x.closest("."+r.ui),e.verbose("Using closest UI element for determining parent",b)):b=x,c=b.parent(),e.verbose("Determining parent element for creating context",c)):(c=a(h.context),e.verbose("Using selector for tab context",h.context,c)),h.childrenOnly?(y=c.children(t.tabs),e.debug("Searching tab context children for tabs",c,y)):(y=c.find(t.tabs),e.debug("Searching tab context for tabs",c,y))},initializeHistory:function(){if(h.history){if(e.debug("Initializing page state"),a.address===d)return e.error(u.state),!1;if("state"==h.historyType){if(e.debug("Using HTML5 to manage state"),h.path===!1)return e.error(u.path),!1;a.address.history(!0).state(h.path)}a.address.bind("change",e.event.history.change)}},instantiate:function(){e.verbose("Storing instance of module",e),x.data(w,e)},destroy:function(){e.debug("Destroying tabs",x),x.removeData(w).off(v)},event:{click:function(b){var c=a(this).data(s.tab);c!==d?(h.history?(e.verbose("Updating page state",b),a.address.value(c)):(e.verbose("Changing tab",b),e.changeTab(c)),b.preventDefault()):e.debug("No tab specified")},history:{change:function(b){var c=b.pathNames.join("/")||e.get.initialPath(),f=h.templates.determineTitle(c)||!1;e.performance.display(),e.debug("History change event",c,b),q=b,c!==d&&e.changeTab(c),f&&a.address.title(f)}}},refresh:function(){o&&(e.debug("Refreshing tab",o),e.changeTab(o))},cache:{read:function(a){return a!==d?z[a]:!1},add:function(a,b){a=a||o,e.debug("Adding cached content for",a),z[a]=b},remove:function(a){a=a||o,e.debug("Removing cached content for",a),delete z[a]}},set:{state:function(b){a.address.value(b)}},changeTab:function(c){var d=b.history&&b.history.pushState,f=d&&h.ignoreFirstLoad&&A,g=h.auto||a.isPlainObject(h.apiSettings),i=g&&!f?e.utilities.pathToArray(c):e.get.defaultPathArray(c);c=e.utilities.arrayToPath(i),a.each(i,function(b,d){var j,k,l,m,n=i.slice(0,b+1),r=e.utilities.arrayToPath(n),s=e.is.tab(r),t=b+1==i.length,v=e.get.tabElement(r);return e.verbose("Looking for tab",d),s?(e.verbose("Tab was found",d),o=r,p=e.utilities.filterArray(i,n),t?m=!0:(k=i.slice(0,b+2),l=e.utilities.arrayToPath(k),m=!e.is.tab(l),m&&e.verbose("Tab parameters found",k)),m&&g?(f?(e.debug("Ignoring remote content on first tab load",r),A=!1,e.cache.add(c,v.html()),e.activate.all(r),a.proxy(h.onTabInit,v)(r,p,q),a.proxy(h.onTabLoad,v)(r,p,q)):(e.activate.navigation(r),e.content.fetch(r,c)),!1):(e.debug("Opened local tab",r),e.activate.all(r),e.cache.read(r)||(e.cache.add(r,!0),e.debug("First time tab loaded calling tab init"),a.proxy(h.onTabInit,v)(r,p,q)),a.proxy(h.onTabLoad,v)(r,p,q),void 0)):(j=a("#"+c+', a[name="'+c+'"]'),r=j.closest("[data-tab]").data("tab"),v=e.get.tabElement(r),j.size()>0&&r?(e.debug("No tab found, but deep anchor link present, opening parent tab"),e.activate.all(r),e.cache.read(r)||(e.cache.add(r,!0),e.debug("First time tab loaded calling tab init"),a.proxy(h.onTabInit,v)(r,p,q))):e.error(u.missingTab,x,r),!1)})},content:{fetch:function(b,c){var f,g,i=e.get.tabElement(b),j={dataType:"html",stateContext:i,onSuccess:function(d){e.cache.add(c,d),e.content.update(b,d),b==o?(e.debug("Content loaded",b),e.activa