|
|
!function(a,b,c,d){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=i.slice(0,b+1),n=e.utilities.arrayToPath(m),r=e.is.tab(n),s=b+1==i.length,t=e.get.tabElement(n);return e.verbose("Looking for tab",d),r?(e.verbose("Tab was found",d),o=n,p=e.utilities.filterArray(i,m),s?l=!0:(j=i.slice(0,b+2),k=e.utilities.arrayToPath(j),l=!e.is.tab(k),l&&e.verbose("Tab parameters found",j)),l&&g?(f?(e.debug("Ignoring remote content on first tab load",n),A=!1,e.cache.add(c,t.html()),e.activate.all(n),a.proxy(h.onTabInit,t)(n,p,q),a.proxy(h.onTabLoad,t)(n,p,q)):(e.activate.navigation(n),e.content.fetch(n,c)),!1):(e.debug("Opened local tab",n),e.activate.all(n),e.cache.read(n)||(e.cache.add(n,!0),e.debug("First time tab loaded calling tab init"),a.proxy(h.onTabInit,t)(n,p,q)),a.proxy(h.onTabLoad,t)(n,p,q),void 0)):(h.history||e.error(u.missingTab,x,n),!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.activate.tab(b)):e.debug("Content loaded in background",b),a.proxy(h.onTabInit,i)(b,p,q),a.proxy(h.onTabLoad,i)(b,p,q)},urlData:{tab:c}},k=i.data(s.promise)||!1,l=k&&"pending"===k.state();c=c||b,g=e.cache.read(c),h.cache&&g?(e.debug("Showing existing content",c),e.content.update(b,g),e.activate.tab(b),a.proxy(h.onTabLoad,i)(
|