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