diff --git a/build/minified/modules/tab.js b/build/minified/modules/tab.js index 00cf72eea..fc97617f6 100644 --- a/build/minified/modules/tab.js +++ b/build/minified/modules/tab.js @@ -30,7 +30,7 @@ moduleSelector = $module.selector || '', eventNamespace = '.' + settings.namespace, - moduleNamespace = settings.namespace + '-module', + moduleNamespace = settings.namespace + '-module', className = settings.className, metadata = settings.metadata, @@ -62,7 +62,7 @@ return false; } else { - if(!settings.apiSettings) { + if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) { module.debug('No API url found, using current url'); settings.apiSettings = { url: settings.path + '/{$tab}' @@ -71,7 +71,8 @@ module.verbose('Address library found adding state change event'); $.address .state(settings.path) - .change(module.event.history.change) + .unbind('change') + .bind('change', module.event.history.change) ; } } @@ -160,7 +161,14 @@ change: function(tabPath) { var - pathArray = module.get.defaultPathArray(tabPath) + pushStateAvailable = (window.history && window.history.pushState), + shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), + remoteContent = $.isPlainObject(settings.apiSettings), + // only get default path if not remote content + pathArray = (remoteContent && !shouldIgnoreLoad) + ? module.utils.pathToArray(tabPath) + : module.get.defaultPathArray(tabPath), + tabPath = module.utils.arrayToPath(pathArray) ; module.deactivate.all(); $.each(pathArray, function(index, tab) { @@ -170,10 +178,6 @@ isTab = module.is.tab(currentPath), isLastIndex = (index + 1 == pathArray.length), - - pushStateAvailable = (window.history && window.history.pushState), - shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), - remoteContent = $.isPlainObject(settings.apiSettings), $tab = module.get.tabElement(currentPath), nextPathArray, @@ -195,7 +199,9 @@ nextPathArray = pathArray.slice(0, index + 2); nextPath = module.utils.arrayToPath(nextPathArray); isLastTab = ( !module.is.tab(nextPath) ); - module.verbose('Tab parameters found', nextPathArray); + if(isLastTab) { + module.verbose('Tab parameters found', nextPathArray); + } } if(isLastTab && remoteContent) { if(!shouldIgnoreLoad) { @@ -208,14 +214,15 @@ module.cache.add(tabPath, $tab.html()); module.activate.all(currentPath); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } + return false; } else { module.debug('Opened local tab', currentPath); module.activate.all(currentPath); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } - return false; } else { module.error(errors.missingTab, tab); @@ -245,6 +252,7 @@ module.debug('Content loaded in background', tabPath); } $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); }, urlData: { tab: fullTabPath } }, @@ -255,7 +263,7 @@ module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); module.activate.tab(tabPath); - $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); } else if(existingRequest) { module.debug('Content is already loading', fullTabPath); @@ -297,10 +305,10 @@ }, navigation: function(tabPath) { var - $nav = module.get.navElement(tabPath) + $navigation = module.get.navElement(tabPath) ; - module.verbose('Activating tab navigation for', $nav); - $nav.addClass(className.active); + module.verbose('Activating tab navigation for', $navigation, tabPath); + $navigation.addClass(className.active); } }, @@ -354,6 +362,9 @@ } module.error(errors.recursion); } + else { + module.debug('No default tabs found for', tabPath); + } recursionDepth = 0; return tabPath; }, @@ -626,4 +637,4 @@ }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document ); diff --git a/build/minified/modules/tab.min.js b/build/minified/modules/tab.min.js index 5862aca42..5093a123f 100644 --- a/build/minified/modules/tab.min.js +++ b/build/minified/modules/tab.min.js @@ -1 +1 @@ -!function(a,b,c,d){a.fn.tabNavigation=function(c){var e,f,g,h,i,j=a.extend(!0,{},a.fn.tabNavigation.settings,c),k=a(this),l=a(j.context).find(j.selector.tabs),m={},n=!0,o=0,p=this,q=(new Date).getTime(),r=[],s=k.selector||"",t="."+j.namespace,u=j.namespace+"-module",v=j.className,w=j.metadata,x=j.namespace,y=j.errors,z=k.data(u),A=arguments[0],B=z!==d&&"string"==typeof A,C=[].slice.call(arguments,1);return h={initialize:function(){if(h.debug("Initializing Tabs",k),j.history){if(a.address===d)return h.error(y.state),!1;if(j.path===!1)return h.error(y.path),!1;j.apiSettings||(h.debug("No API url found, using current url"),j.apiSettings={url:j.path+"/{$tab}"}),h.verbose("Address library found adding state change event"),a.address.state(j.path).change(h.event.history.change)}a.isWindow(p)||k.on("click."+t,h.event.click),k.data(u,h)},destroy:function(){h.debug("Destroying tabs",k),k.off("."+x)},event:{click:function(){h.debug("Navigation clicked");var b=a(this).data(w.tab);b!==d?b!==e&&(j.history?a.address.value(b):h.change(b)):h.debug("No tab specified")},history:{change:function(b){var c=b.pathNames.join("/")||h.get.initialPath(),e=j.templates.determineTitle(c)||!1;h.debug("History change event",c,b),g=b,c!==d&&h.change(c),e&&a.address.title(e)}}},refresh:function(){e&&(h.debug("Refreshing tab",e),h.change(e))},cache:{read:function(a){return a!==d?m[a]:!1},add:function(a,b){a=a||e,h.debug("Adding cached content for",a),m[a]=b},remove:function(a){a=a||e,h.debug("Removing cached content for",a),delete m[a]}},change:function(c){var d=h.get.defaultPathArray(c);h.deactivate.all(),a.each(d,function(i,k){var l,m,o,p=d.slice(0,i+1),q=h.utils.arrayToPath(p),r=h.is.tab(q),s=i+1==d.length,t=b.history&&b.history.pushState,u=t&&j.ignoreFirstLoad&&n,v=a.isPlainObject(j.apiSettings),w=h.get.tabElement(q);return h.verbose("Looking for tab",k),r?(h.verbose("Tab was found",k),e=q,f=h.utils.filterArray(d,p),s?o=!0:(l=d.slice(0,i+2),m=h.utils.arrayToPath(l),o=!h.is.tab(m),h.verbose("Tab parameters found",l)),o&&v?u?(h.debug("Ignoring remote content on first tab load",q),n=!1,h.cache.add(c,w.html()),h.activate.all(q),a.proxy(j.onTabInit,w)(q,f,g)):(h.activate.navigation(q),h.content.fetch(q,c)):(h.debug("Opened local tab",q),h.activate.all(q),a.proxy(j.onTabLoad,w)(q,f,g)),!1):(h.error(y.missingTab,k),!1)})},content:{fetch:function(b,c){var i=h.get.tabElement(b),c=c||b,k=h.cache.read(c),l={dataType:"html",stateContext:i,success:function(d){h.cache.add(c,d),h.content.update(b,d),b==e?(h.debug("Content loaded",b),h.activate.tab(b)):h.debug("Content loaded in background",b),a.proxy(j.onTabInit,i)(b,f,g)},urlData:{tab:c}},m=i.data(w.promise)||!1,n=m&&"pending"===m.state();j.cache&&k?(h.debug("Showing existing content",c),h.content.update(b,k),h.activate.tab(b),a.proxy(j.onTabInit,i)(b,f,g)):n?(h.debug("Content is already loading",c),i.addClass(v.loading)):a.api!==d?(h.debug("Retrieving remote content",c),a.api(a.extend(!0,{headers:{"X-Remote":!0}},j.apiSettings,l))):h.error(y.api)},update:function(a,b){h.debug("Updating html for",a);var c=h.get.tabElement(a);c.html(b)}},activate:{all:function(a){h.activate.tab(a),h.activate.navigation(a)},tab:function(a){var b=h.get.tabElement(a);h.verbose("Showing tab content for",b),b.addClass(v.active)},navigation:function(a){var b=h.get.navElement(a);h.verbose("Activating tab navigation for",b),b.addClass(v.active)}},deactivate:{all:function(){h.deactivate.navigation(),h.deactivate.tabs()},navigation:function(){k.removeClass(v.active)},tabs:function(){l.removeClass(v.active+" "+v.loading)}},is:{tab:function(a){return a!==d?h.get.tabElement(a).size()>0:!1}},get:{initialPath:function(){return k.eq(0).data(w.tab)||l.eq(0).data(w.tab)},path:function(){return a.address.value()},defaultPathArray:function(a){return h.utils.pathToArray(h.get.defaultPath(a))},defaultPath:function(a){var b=k.filter("[data-"+w.tab+'^="'+a+'/"]').eq(0),c=b.data(w.tab)||!1;if(c){if(h.debug("Found default tab",c),o0?b:c},tab:function(){return e}},utils:{filterArray:function(b,c){return a.grep(b,function(b){return-1==a.inArray(b,c)})},last:function(b){return a.isArray(b)?b[b.length-1]:!1},pathToArray:function(a){return a===d&&(a=e),"string"==typeof a?a.split("/"):[a]},arrayToPath:function(b){return a.isArray(b)?b.join("/"):!1}},setting:function(b,c){return c===d?j[b]:(a.isPlainObject(b)?a.extend(!0,j,b):j[b]=c,void 0)},internal:function(b,c){return c===d?h[b]:(a.isPlainObject(b)?a.extend(!0,h,b):h[b]=c,void 0)},debug:function(){j.debug&&(j.performance?h.performance.log(arguments):h.debug=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},verbose:function(){j.verbose&&j.debug&&(j.performance?h.performance.log(arguments):h.verbose=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},error:function(){h.error=Function.prototype.bind.call(console.error,console,j.moduleName+":")},performance:{log:function(a){var b,c,d;j.performance&&(b=(new Date).getTime(),d=q||b,c=b-d,q=b,r.push({Element:p,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(h.performance.timer),h.performance.timer=setTimeout(h.performance.display,100)},display:function(){var b=j.moduleName+":",c=0;q=!1,a.each(r,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",s&&(b+=" '"+s+"'"),(console.group!==d||console.table!==d)&&r.length>0&&(console.groupCollapsed(b),console.table?console.table(r):a.each(r,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),r=[]}},invoke:function(b,c,e){var f,g;return c=c||C,e=p||e,"string"==typeof b&&z!==d&&(b=b.split("."),f=b.length-1,a.each(b,function(b,c){a.isPlainObject(z[c])&&b!=f?z=z[c]:z[c]!==d?g=z[c]:h.error(y.method)})),a.isFunction(g)?(h.verbose("Executing invoked function",g),g.apply(e,c)):g||!1}},B?(z===d&&h.initialize(),i=h.invoke(A)):(z!==d&&h.destroy(),h.initialize()),i!==d?i:this},a.tabNavigation=function(c){a(b).tabNavigation(c)},a.fn.tabNavigation.settings={moduleName:"Tab Module",verbose:!0,debug:!0,performance:!0,namespace:"tab",onTabInit:function(){},onTabLoad:function(){},templates:{determineTitle:function(){}},history:!1,path:!1,context:"body",maxDepth:25,ignoreFirstLoad:!0,alwaysRefresh:!1,cache:!0,apiSettings:!1,errors:{api:"You attempted to load content without API module",noContent:"The tab you specified is missing a content url.",method:"The method you called is not defined",state:"The state library has not been initialized",missingTab:"Tab cannot be found",path:"History enabled, but no path was specified",recursion:"Max recursive depth reached"},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".tab"}}}(jQuery,window,document); \ No newline at end of file +!function(a,b,c,d){a.fn.tabNavigation=function(c){var e,f,g,h,i,j=a.extend(!0,{},a.fn.tabNavigation.settings,c),k=a(this),l=a(j.context).find(j.selector.tabs),m={},n=!0,o=0,p=this,q=(new Date).getTime(),r=[],s=k.selector||"",t="."+j.namespace,u=j.namespace+"-module",v=j.className,w=j.metadata,x=j.namespace,y=j.errors,z=k.data(u),A=arguments[0],B=z!==d&&"string"==typeof A,C=[].slice.call(arguments,1);return h={initialize:function(){if(h.debug("Initializing Tabs",k),j.history){if(a.address===d)return h.error(y.state),!1;if(j.path===!1)return h.error(y.path),!1;a.isPlainObject(j.apiSettings)&&j.action===d&&j.url===d&&(h.debug("No API url found, using current url"),j.apiSettings={url:j.path+"/{$tab}"}),h.verbose("Address library found adding state change event"),a.address.state(j.path).unbind("change").bind("change",h.event.history.change)}a.isWindow(p)||k.on("click."+t,h.event.click),k.data(u,h)},destroy:function(){h.debug("Destroying tabs",k),k.off("."+x)},event:{click:function(){h.debug("Navigation clicked");var b=a(this).data(w.tab);b!==d?b!==e&&(j.history?a.address.value(b):h.change(b)):h.debug("No tab specified")},history:{change:function(b){var c=b.pathNames.join("/")||h.get.initialPath(),e=j.templates.determineTitle(c)||!1;h.debug("History change event",c,b),g=b,c!==d&&h.change(c),e&&a.address.title(e)}}},refresh:function(){e&&(h.debug("Refreshing tab",e),h.change(e))},cache:{read:function(a){return a!==d?m[a]:!1},add:function(a,b){a=a||e,h.debug("Adding cached content for",a),m[a]=b},remove:function(a){a=a||e,h.debug("Removing cached content for",a),delete m[a]}},change:function(c){var d=b.history&&b.history.pushState,i=d&&j.ignoreFirstLoad&&n,k=a.isPlainObject(j.apiSettings),l=k&&!i?h.utils.pathToArray(c):h.get.defaultPathArray(c),c=h.utils.arrayToPath(l);h.deactivate.all(),a.each(l,function(b,d){var m,o,p,q=l.slice(0,b+1),r=h.utils.arrayToPath(q),s=h.is.tab(r),t=b+1==l.length,u=h.get.tabElement(r);return h.verbose("Looking for tab",d),s?(h.verbose("Tab was found",d),e=r,f=h.utils.filterArray(l,q),t?p=!0:(m=l.slice(0,b+2),o=h.utils.arrayToPath(m),p=!h.is.tab(o),p&&h.verbose("Tab parameters found",m)),p&&k?(i?(h.debug("Ignoring remote content on first tab load",r),n=!1,h.cache.add(c,u.html()),h.activate.all(r),a.proxy(j.onTabInit,u)(r,f,g),a.proxy(j.onTabLoad,u)(r,f,g)):(h.activate.navigation(r),h.content.fetch(r,c)),!1):(h.debug("Opened local tab",r),h.activate.all(r),a.proxy(j.onTabLoad,u)(r,f,g),void 0)):(h.error(y.missingTab,d),!1)})},content:{fetch:function(b,c){var i=h.get.tabElement(b),c=c||b,k=h.cache.read(c),l={dataType:"html",stateContext:i,success:function(d){h.cache.add(c,d),h.content.update(b,d),b==e?(h.debug("Content loaded",b),h.activate.tab(b)):h.debug("Content loaded in background",b),a.proxy(j.onTabInit,i)(b,f,g),a.proxy(j.onTabLoad,i)(b,f,g)},urlData:{tab:c}},m=i.data(w.promise)||!1,n=m&&"pending"===m.state();j.cache&&k?(h.debug("Showing existing content",c),h.content.update(b,k),h.activate.tab(b),a.proxy(j.onTabLoad,i)(b,f,g)):n?(h.debug("Content is already loading",c),i.addClass(v.loading)):a.api!==d?(h.debug("Retrieving remote content",c),a.api(a.extend(!0,{headers:{"X-Remote":!0}},j.apiSettings,l))):h.error(y.api)},update:function(a,b){h.debug("Updating html for",a);var c=h.get.tabElement(a);c.html(b)}},activate:{all:function(a){h.activate.tab(a),h.activate.navigation(a)},tab:function(a){var b=h.get.tabElement(a);h.verbose("Showing tab content for",b),b.addClass(v.active)},navigation:function(a){var b=h.get.navElement(a);h.verbose("Activating tab navigation for",b,a),b.addClass(v.active)}},deactivate:{all:function(){h.deactivate.navigation(),h.deactivate.tabs()},navigation:function(){k.removeClass(v.active)},tabs:function(){l.removeClass(v.active+" "+v.loading)}},is:{tab:function(a){return a!==d?h.get.tabElement(a).size()>0:!1}},get:{initialPath:function(){return k.eq(0).data(w.tab)||l.eq(0).data(w.tab)},path:function(){return a.address.value()},defaultPathArray:function(a){return h.utils.pathToArray(h.get.defaultPath(a))},defaultPath:function(a){var b=k.filter("[data-"+w.tab+'^="'+a+'/"]').eq(0),c=b.data(w.tab)||!1;if(c){if(h.debug("Found default tab",c),o0?b:c},tab:function(){return e}},utils:{filterArray:function(b,c){return a.grep(b,function(b){return-1==a.inArray(b,c)})},last:function(b){return a.isArray(b)?b[b.length-1]:!1},pathToArray:function(a){return a===d&&(a=e),"string"==typeof a?a.split("/"):[a]},arrayToPath:function(b){return a.isArray(b)?b.join("/"):!1}},setting:function(b,c){return c===d?j[b]:(a.isPlainObject(b)?a.extend(!0,j,b):j[b]=c,void 0)},internal:function(b,c){return c===d?h[b]:(a.isPlainObject(b)?a.extend(!0,h,b):h[b]=c,void 0)},debug:function(){j.debug&&(j.performance?h.performance.log(arguments):h.debug=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},verbose:function(){j.verbose&&j.debug&&(j.performance?h.performance.log(arguments):h.verbose=Function.prototype.bind.call(console.info,console,j.moduleName+":"))},error:function(){h.error=Function.prototype.bind.call(console.error,console,j.moduleName+":")},performance:{log:function(a){var b,c,d;j.performance&&(b=(new Date).getTime(),d=q||b,c=b-d,q=b,r.push({Element:p,Name:a[0],Arguments:[].slice.call(a,1)||"","Execution Time":c})),clearTimeout(h.performance.timer),h.performance.timer=setTimeout(h.performance.display,100)},display:function(){var b=j.moduleName+":",c=0;q=!1,a.each(r,function(a,b){c+=b["Execution Time"]}),b+=" "+c+"ms",s&&(b+=" '"+s+"'"),(console.group!==d||console.table!==d)&&r.length>0&&(console.groupCollapsed(b),console.table?console.table(r):a.each(r,function(a,b){console.log(b.Name+": "+b["Execution Time"]+"ms")}),console.groupEnd()),r=[]}},invoke:function(b,c,e){var f,g;return c=c||C,e=p||e,"string"==typeof b&&z!==d&&(b=b.split("."),f=b.length-1,a.each(b,function(b,c){a.isPlainObject(z[c])&&b!=f?z=z[c]:z[c]!==d?g=z[c]:h.error(y.method)})),a.isFunction(g)?(h.verbose("Executing invoked function",g),g.apply(e,c)):g||!1}},B?(z===d&&h.initialize(),i=h.invoke(A)):(z!==d&&h.destroy(),h.initialize()),i!==d?i:this},a.tabNavigation=function(c){a(b).tabNavigation(c)},a.fn.tabNavigation.settings={moduleName:"Tab Module",verbose:!0,debug:!0,performance:!0,namespace:"tab",onTabInit:function(){},onTabLoad:function(){},templates:{determineTitle:function(){}},history:!1,path:!1,context:"body",maxDepth:25,ignoreFirstLoad:!0,alwaysRefresh:!1,cache:!0,apiSettings:!1,errors:{api:"You attempted to load content without API module",noContent:"The tab you specified is missing a content url.",method:"The method you called is not defined",state:"The state library has not been initialized",missingTab:"Tab cannot be found",path:"History enabled, but no path was specified",recursion:"Max recursive depth reached"},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".tab"}}}(jQuery,window,document); \ No newline at end of file diff --git a/build/packaged/modules/tab.js b/build/packaged/modules/tab.js index 00cf72eea..fc97617f6 100644 --- a/build/packaged/modules/tab.js +++ b/build/packaged/modules/tab.js @@ -30,7 +30,7 @@ moduleSelector = $module.selector || '', eventNamespace = '.' + settings.namespace, - moduleNamespace = settings.namespace + '-module', + moduleNamespace = settings.namespace + '-module', className = settings.className, metadata = settings.metadata, @@ -62,7 +62,7 @@ return false; } else { - if(!settings.apiSettings) { + if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) { module.debug('No API url found, using current url'); settings.apiSettings = { url: settings.path + '/{$tab}' @@ -71,7 +71,8 @@ module.verbose('Address library found adding state change event'); $.address .state(settings.path) - .change(module.event.history.change) + .unbind('change') + .bind('change', module.event.history.change) ; } } @@ -160,7 +161,14 @@ change: function(tabPath) { var - pathArray = module.get.defaultPathArray(tabPath) + pushStateAvailable = (window.history && window.history.pushState), + shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), + remoteContent = $.isPlainObject(settings.apiSettings), + // only get default path if not remote content + pathArray = (remoteContent && !shouldIgnoreLoad) + ? module.utils.pathToArray(tabPath) + : module.get.defaultPathArray(tabPath), + tabPath = module.utils.arrayToPath(pathArray) ; module.deactivate.all(); $.each(pathArray, function(index, tab) { @@ -170,10 +178,6 @@ isTab = module.is.tab(currentPath), isLastIndex = (index + 1 == pathArray.length), - - pushStateAvailable = (window.history && window.history.pushState), - shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), - remoteContent = $.isPlainObject(settings.apiSettings), $tab = module.get.tabElement(currentPath), nextPathArray, @@ -195,7 +199,9 @@ nextPathArray = pathArray.slice(0, index + 2); nextPath = module.utils.arrayToPath(nextPathArray); isLastTab = ( !module.is.tab(nextPath) ); - module.verbose('Tab parameters found', nextPathArray); + if(isLastTab) { + module.verbose('Tab parameters found', nextPathArray); + } } if(isLastTab && remoteContent) { if(!shouldIgnoreLoad) { @@ -208,14 +214,15 @@ module.cache.add(tabPath, $tab.html()); module.activate.all(currentPath); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } + return false; } else { module.debug('Opened local tab', currentPath); module.activate.all(currentPath); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } - return false; } else { module.error(errors.missingTab, tab); @@ -245,6 +252,7 @@ module.debug('Content loaded in background', tabPath); } $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); }, urlData: { tab: fullTabPath } }, @@ -255,7 +263,7 @@ module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); module.activate.tab(tabPath); - $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); } else if(existingRequest) { module.debug('Content is already loading', fullTabPath); @@ -297,10 +305,10 @@ }, navigation: function(tabPath) { var - $nav = module.get.navElement(tabPath) + $navigation = module.get.navElement(tabPath) ; - module.verbose('Activating tab navigation for', $nav); - $nav.addClass(className.active); + module.verbose('Activating tab navigation for', $navigation, tabPath); + $navigation.addClass(className.active); } }, @@ -354,6 +362,9 @@ } module.error(errors.recursion); } + else { + module.debug('No default tabs found for', tabPath); + } recursionDepth = 0; return tabPath; }, @@ -626,4 +637,4 @@ }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document ); diff --git a/build/packaged/semantic.min.js.REMOVED.git-id b/build/packaged/semantic.min.js.REMOVED.git-id index bc0a09241..0f58795f7 100644 --- a/build/packaged/semantic.min.js.REMOVED.git-id +++ b/build/packaged/semantic.min.js.REMOVED.git-id @@ -1 +1 @@ -961672b84f3f52255c73991920d39065c129dc63 \ No newline at end of file +cdb6cb010bf7ebc91a85709b7065a1eda3bdf842 \ No newline at end of file diff --git a/build/uncompressed/modules/tab.js b/build/uncompressed/modules/tab.js index 00cf72eea..fc97617f6 100644 --- a/build/uncompressed/modules/tab.js +++ b/build/uncompressed/modules/tab.js @@ -30,7 +30,7 @@ moduleSelector = $module.selector || '', eventNamespace = '.' + settings.namespace, - moduleNamespace = settings.namespace + '-module', + moduleNamespace = settings.namespace + '-module', className = settings.className, metadata = settings.metadata, @@ -62,7 +62,7 @@ return false; } else { - if(!settings.apiSettings) { + if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) { module.debug('No API url found, using current url'); settings.apiSettings = { url: settings.path + '/{$tab}' @@ -71,7 +71,8 @@ module.verbose('Address library found adding state change event'); $.address .state(settings.path) - .change(module.event.history.change) + .unbind('change') + .bind('change', module.event.history.change) ; } } @@ -160,7 +161,14 @@ change: function(tabPath) { var - pathArray = module.get.defaultPathArray(tabPath) + pushStateAvailable = (window.history && window.history.pushState), + shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), + remoteContent = $.isPlainObject(settings.apiSettings), + // only get default path if not remote content + pathArray = (remoteContent && !shouldIgnoreLoad) + ? module.utils.pathToArray(tabPath) + : module.get.defaultPathArray(tabPath), + tabPath = module.utils.arrayToPath(pathArray) ; module.deactivate.all(); $.each(pathArray, function(index, tab) { @@ -170,10 +178,6 @@ isTab = module.is.tab(currentPath), isLastIndex = (index + 1 == pathArray.length), - - pushStateAvailable = (window.history && window.history.pushState), - shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), - remoteContent = $.isPlainObject(settings.apiSettings), $tab = module.get.tabElement(currentPath), nextPathArray, @@ -195,7 +199,9 @@ nextPathArray = pathArray.slice(0, index + 2); nextPath = module.utils.arrayToPath(nextPathArray); isLastTab = ( !module.is.tab(nextPath) ); - module.verbose('Tab parameters found', nextPathArray); + if(isLastTab) { + module.verbose('Tab parameters found', nextPathArray); + } } if(isLastTab && remoteContent) { if(!shouldIgnoreLoad) { @@ -208,14 +214,15 @@ module.cache.add(tabPath, $tab.html()); module.activate.all(currentPath); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } + return false; } else { module.debug('Opened local tab', currentPath); module.activate.all(currentPath); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } - return false; } else { module.error(errors.missingTab, tab); @@ -245,6 +252,7 @@ module.debug('Content loaded in background', tabPath); } $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); }, urlData: { tab: fullTabPath } }, @@ -255,7 +263,7 @@ module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); module.activate.tab(tabPath); - $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); } else if(existingRequest) { module.debug('Content is already loading', fullTabPath); @@ -297,10 +305,10 @@ }, navigation: function(tabPath) { var - $nav = module.get.navElement(tabPath) + $navigation = module.get.navElement(tabPath) ; - module.verbose('Activating tab navigation for', $nav); - $nav.addClass(className.active); + module.verbose('Activating tab navigation for', $navigation, tabPath); + $navigation.addClass(className.active); } }, @@ -354,6 +362,9 @@ } module.error(errors.recursion); } + else { + module.debug('No default tabs found for', tabPath); + } recursionDepth = 0; return tabPath; }, @@ -626,4 +637,4 @@ }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document ); diff --git a/node/src/files/components/semantic/modules/tab.js b/node/src/files/components/semantic/modules/tab.js index 00cf72eea..fc97617f6 100644 --- a/node/src/files/components/semantic/modules/tab.js +++ b/node/src/files/components/semantic/modules/tab.js @@ -30,7 +30,7 @@ moduleSelector = $module.selector || '', eventNamespace = '.' + settings.namespace, - moduleNamespace = settings.namespace + '-module', + moduleNamespace = settings.namespace + '-module', className = settings.className, metadata = settings.metadata, @@ -62,7 +62,7 @@ return false; } else { - if(!settings.apiSettings) { + if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) { module.debug('No API url found, using current url'); settings.apiSettings = { url: settings.path + '/{$tab}' @@ -71,7 +71,8 @@ module.verbose('Address library found adding state change event'); $.address .state(settings.path) - .change(module.event.history.change) + .unbind('change') + .bind('change', module.event.history.change) ; } } @@ -160,7 +161,14 @@ change: function(tabPath) { var - pathArray = module.get.defaultPathArray(tabPath) + pushStateAvailable = (window.history && window.history.pushState), + shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), + remoteContent = $.isPlainObject(settings.apiSettings), + // only get default path if not remote content + pathArray = (remoteContent && !shouldIgnoreLoad) + ? module.utils.pathToArray(tabPath) + : module.get.defaultPathArray(tabPath), + tabPath = module.utils.arrayToPath(pathArray) ; module.deactivate.all(); $.each(pathArray, function(index, tab) { @@ -170,10 +178,6 @@ isTab = module.is.tab(currentPath), isLastIndex = (index + 1 == pathArray.length), - - pushStateAvailable = (window.history && window.history.pushState), - shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), - remoteContent = $.isPlainObject(settings.apiSettings), $tab = module.get.tabElement(currentPath), nextPathArray, @@ -195,7 +199,9 @@ nextPathArray = pathArray.slice(0, index + 2); nextPath = module.utils.arrayToPath(nextPathArray); isLastTab = ( !module.is.tab(nextPath) ); - module.verbose('Tab parameters found', nextPathArray); + if(isLastTab) { + module.verbose('Tab parameters found', nextPathArray); + } } if(isLastTab && remoteContent) { if(!shouldIgnoreLoad) { @@ -208,14 +214,15 @@ module.cache.add(tabPath, $tab.html()); module.activate.all(currentPath); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } + return false; } else { module.debug('Opened local tab', currentPath); module.activate.all(currentPath); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } - return false; } else { module.error(errors.missingTab, tab); @@ -245,6 +252,7 @@ module.debug('Content loaded in background', tabPath); } $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); }, urlData: { tab: fullTabPath } }, @@ -255,7 +263,7 @@ module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); module.activate.tab(tabPath); - $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); } else if(existingRequest) { module.debug('Content is already loading', fullTabPath); @@ -297,10 +305,10 @@ }, navigation: function(tabPath) { var - $nav = module.get.navElement(tabPath) + $navigation = module.get.navElement(tabPath) ; - module.verbose('Activating tab navigation for', $nav); - $nav.addClass(className.active); + module.verbose('Activating tab navigation for', $navigation, tabPath); + $navigation.addClass(className.active); } }, @@ -354,6 +362,9 @@ } module.error(errors.recursion); } + else { + module.debug('No default tabs found for', tabPath); + } recursionDepth = 0; return tabPath; }, @@ -626,4 +637,4 @@ }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document ); diff --git a/node/src/files/stylesheets/semantic.css b/node/src/files/stylesheets/semantic.css index 1cc10fbdf..f9192f24c 100755 --- a/node/src/files/stylesheets/semantic.css +++ b/node/src/files/stylesheets/semantic.css @@ -236,7 +236,9 @@ a:hover { -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; - font-size: 0.85em; +} +#example #menu .item .item { + font-size: 0.875rem; } #example .sidr .ui.menu { diff --git a/src/modules/tab.js b/src/modules/tab.js index 00cf72eea..fc97617f6 100755 --- a/src/modules/tab.js +++ b/src/modules/tab.js @@ -30,7 +30,7 @@ moduleSelector = $module.selector || '', eventNamespace = '.' + settings.namespace, - moduleNamespace = settings.namespace + '-module', + moduleNamespace = settings.namespace + '-module', className = settings.className, metadata = settings.metadata, @@ -62,7 +62,7 @@ return false; } else { - if(!settings.apiSettings) { + if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) { module.debug('No API url found, using current url'); settings.apiSettings = { url: settings.path + '/{$tab}' @@ -71,7 +71,8 @@ module.verbose('Address library found adding state change event'); $.address .state(settings.path) - .change(module.event.history.change) + .unbind('change') + .bind('change', module.event.history.change) ; } } @@ -160,7 +161,14 @@ change: function(tabPath) { var - pathArray = module.get.defaultPathArray(tabPath) + pushStateAvailable = (window.history && window.history.pushState), + shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), + remoteContent = $.isPlainObject(settings.apiSettings), + // only get default path if not remote content + pathArray = (remoteContent && !shouldIgnoreLoad) + ? module.utils.pathToArray(tabPath) + : module.get.defaultPathArray(tabPath), + tabPath = module.utils.arrayToPath(pathArray) ; module.deactivate.all(); $.each(pathArray, function(index, tab) { @@ -170,10 +178,6 @@ isTab = module.is.tab(currentPath), isLastIndex = (index + 1 == pathArray.length), - - pushStateAvailable = (window.history && window.history.pushState), - shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad), - remoteContent = $.isPlainObject(settings.apiSettings), $tab = module.get.tabElement(currentPath), nextPathArray, @@ -195,7 +199,9 @@ nextPathArray = pathArray.slice(0, index + 2); nextPath = module.utils.arrayToPath(nextPathArray); isLastTab = ( !module.is.tab(nextPath) ); - module.verbose('Tab parameters found', nextPathArray); + if(isLastTab) { + module.verbose('Tab parameters found', nextPathArray); + } } if(isLastTab && remoteContent) { if(!shouldIgnoreLoad) { @@ -208,14 +214,15 @@ module.cache.add(tabPath, $tab.html()); module.activate.all(currentPath); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } + return false; } else { module.debug('Opened local tab', currentPath); module.activate.all(currentPath); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); } - return false; } else { module.error(errors.missingTab, tab); @@ -245,6 +252,7 @@ module.debug('Content loaded in background', tabPath); } $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); }, urlData: { tab: fullTabPath } }, @@ -255,7 +263,7 @@ module.debug('Showing existing content', fullTabPath); module.content.update(tabPath, cachedContent); module.activate.tab(tabPath); - $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); + $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent); } else if(existingRequest) { module.debug('Content is already loading', fullTabPath); @@ -297,10 +305,10 @@ }, navigation: function(tabPath) { var - $nav = module.get.navElement(tabPath) + $navigation = module.get.navElement(tabPath) ; - module.verbose('Activating tab navigation for', $nav); - $nav.addClass(className.active); + module.verbose('Activating tab navigation for', $navigation, tabPath); + $navigation.addClass(className.active); } }, @@ -354,6 +362,9 @@ } module.error(errors.recursion); } + else { + module.debug('No default tabs found for', tabPath); + } recursionDepth = 0; return tabPath; }, @@ -626,4 +637,4 @@ }; -})( jQuery, window , document ); \ No newline at end of file +})( jQuery, window , document );