Browse Source

Updates tab module

Former-commit-id: 0dc64c8a0c7df5621af0ce560a79aafcf4145e9b
Former-commit-id: 08e58b90ba32c9096f8dc30c07dcfb6837c787a0
beta
Jack Lukic 11 years ago
parent
commit
5ee24561bb
  1. 41
      build/minified/modules/tab.js
  2. 2
      build/minified/modules/tab.min.js
  3. 41
      build/packaged/modules/tab.js
  4. 2
      build/packaged/semantic.min.js.REMOVED.git-id
  5. 41
      build/uncompressed/modules/tab.js
  6. 41
      node/src/files/components/semantic/modules/tab.js
  7. 4
      node/src/files/stylesheets/semantic.css
  8. 41
      src/modules/tab.js

41
build/minified/modules/tab.js

@ -30,7 +30,7 @@
moduleSelector = $module.selector || '', moduleSelector = $module.selector || '',
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module', moduleNamespace = settings.namespace + '-module',
className = settings.className, className = settings.className,
metadata = settings.metadata, metadata = settings.metadata,
@ -62,7 +62,7 @@
return false; return false;
} }
else { else {
if(!settings.apiSettings) { if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) {
module.debug('No API url found, using current url'); module.debug('No API url found, using current url');
settings.apiSettings = { settings.apiSettings = {
url: settings.path + '/{$tab}' url: settings.path + '/{$tab}'
@ -71,7 +71,8 @@
module.verbose('Address library found adding state change event'); module.verbose('Address library found adding state change event');
$.address $.address
.state(settings.path) .state(settings.path)
.change(module.event.history.change) .unbind('change')
.bind('change', module.event.history.change)
; ;
} }
} }
@ -160,7 +161,14 @@
change: function(tabPath) { change: function(tabPath) {
var 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(); module.deactivate.all();
$.each(pathArray, function(index, tab) { $.each(pathArray, function(index, tab) {
@ -170,10 +178,6 @@
isTab = module.is.tab(currentPath), isTab = module.is.tab(currentPath),
isLastIndex = (index + 1 == pathArray.length), 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), $tab = module.get.tabElement(currentPath),
nextPathArray, nextPathArray,
@ -195,7 +199,9 @@
nextPathArray = pathArray.slice(0, index + 2); nextPathArray = pathArray.slice(0, index + 2);
nextPath = module.utils.arrayToPath(nextPathArray); nextPath = module.utils.arrayToPath(nextPathArray);
isLastTab = ( !module.is.tab(nextPath) ); isLastTab = ( !module.is.tab(nextPath) );
module.verbose('Tab parameters found', nextPathArray); if(isLastTab) {
module.verbose('Tab parameters found', nextPathArray);
}
} }
if(isLastTab && remoteContent) { if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) { if(!shouldIgnoreLoad) {
@ -208,14 +214,15 @@
module.cache.add(tabPath, $tab.html()); module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.debug('Opened local tab', currentPath); module.debug('Opened local tab', currentPath);
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.error(errors.missingTab, tab); module.error(errors.missingTab, tab);
@ -245,6 +252,7 @@
module.debug('Content loaded in background', tabPath); module.debug('Content loaded in background', tabPath);
} }
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
}, },
urlData: { tab: fullTabPath } urlData: { tab: fullTabPath }
}, },
@ -255,7 +263,7 @@
module.debug('Showing existing content', fullTabPath); module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent); module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath); module.activate.tab(tabPath);
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
} }
else if(existingRequest) { else if(existingRequest) {
module.debug('Content is already loading', fullTabPath); module.debug('Content is already loading', fullTabPath);
@ -297,10 +305,10 @@
}, },
navigation: function(tabPath) { navigation: function(tabPath) {
var var
$nav = module.get.navElement(tabPath) $navigation = module.get.navElement(tabPath)
; ;
module.verbose('Activating tab navigation for', $nav); module.verbose('Activating tab navigation for', $navigation, tabPath);
$nav.addClass(className.active); $navigation.addClass(className.active);
} }
}, },
@ -354,6 +362,9 @@
} }
module.error(errors.recursion); module.error(errors.recursion);
} }
else {
module.debug('No default tabs found for', tabPath);
}
recursionDepth = 0; recursionDepth = 0;
return tabPath; return tabPath;
}, },
@ -626,4 +637,4 @@
}; };
})( jQuery, window , document ); })( jQuery, window , document );

2
build/minified/modules/tab.min.js

File diff suppressed because one or more lines are too long

41
build/packaged/modules/tab.js

@ -30,7 +30,7 @@
moduleSelector = $module.selector || '', moduleSelector = $module.selector || '',
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module', moduleNamespace = settings.namespace + '-module',
className = settings.className, className = settings.className,
metadata = settings.metadata, metadata = settings.metadata,
@ -62,7 +62,7 @@
return false; return false;
} }
else { else {
if(!settings.apiSettings) { if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) {
module.debug('No API url found, using current url'); module.debug('No API url found, using current url');
settings.apiSettings = { settings.apiSettings = {
url: settings.path + '/{$tab}' url: settings.path + '/{$tab}'
@ -71,7 +71,8 @@
module.verbose('Address library found adding state change event'); module.verbose('Address library found adding state change event');
$.address $.address
.state(settings.path) .state(settings.path)
.change(module.event.history.change) .unbind('change')
.bind('change', module.event.history.change)
; ;
} }
} }
@ -160,7 +161,14 @@
change: function(tabPath) { change: function(tabPath) {
var 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(); module.deactivate.all();
$.each(pathArray, function(index, tab) { $.each(pathArray, function(index, tab) {
@ -170,10 +178,6 @@
isTab = module.is.tab(currentPath), isTab = module.is.tab(currentPath),
isLastIndex = (index + 1 == pathArray.length), 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), $tab = module.get.tabElement(currentPath),
nextPathArray, nextPathArray,
@ -195,7 +199,9 @@
nextPathArray = pathArray.slice(0, index + 2); nextPathArray = pathArray.slice(0, index + 2);
nextPath = module.utils.arrayToPath(nextPathArray); nextPath = module.utils.arrayToPath(nextPathArray);
isLastTab = ( !module.is.tab(nextPath) ); isLastTab = ( !module.is.tab(nextPath) );
module.verbose('Tab parameters found', nextPathArray); if(isLastTab) {
module.verbose('Tab parameters found', nextPathArray);
}
} }
if(isLastTab && remoteContent) { if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) { if(!shouldIgnoreLoad) {
@ -208,14 +214,15 @@
module.cache.add(tabPath, $tab.html()); module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.debug('Opened local tab', currentPath); module.debug('Opened local tab', currentPath);
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.error(errors.missingTab, tab); module.error(errors.missingTab, tab);
@ -245,6 +252,7 @@
module.debug('Content loaded in background', tabPath); module.debug('Content loaded in background', tabPath);
} }
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
}, },
urlData: { tab: fullTabPath } urlData: { tab: fullTabPath }
}, },
@ -255,7 +263,7 @@
module.debug('Showing existing content', fullTabPath); module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent); module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath); module.activate.tab(tabPath);
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
} }
else if(existingRequest) { else if(existingRequest) {
module.debug('Content is already loading', fullTabPath); module.debug('Content is already loading', fullTabPath);
@ -297,10 +305,10 @@
}, },
navigation: function(tabPath) { navigation: function(tabPath) {
var var
$nav = module.get.navElement(tabPath) $navigation = module.get.navElement(tabPath)
; ;
module.verbose('Activating tab navigation for', $nav); module.verbose('Activating tab navigation for', $navigation, tabPath);
$nav.addClass(className.active); $navigation.addClass(className.active);
} }
}, },
@ -354,6 +362,9 @@
} }
module.error(errors.recursion); module.error(errors.recursion);
} }
else {
module.debug('No default tabs found for', tabPath);
}
recursionDepth = 0; recursionDepth = 0;
return tabPath; return tabPath;
}, },
@ -626,4 +637,4 @@
}; };
})( jQuery, window , document ); })( jQuery, window , document );

2
build/packaged/semantic.min.js.REMOVED.git-id

@ -1 +1 @@
961672b84f3f52255c73991920d39065c129dc63 cdb6cb010bf7ebc91a85709b7065a1eda3bdf842

41
build/uncompressed/modules/tab.js

@ -30,7 +30,7 @@
moduleSelector = $module.selector || '', moduleSelector = $module.selector || '',
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module', moduleNamespace = settings.namespace + '-module',
className = settings.className, className = settings.className,
metadata = settings.metadata, metadata = settings.metadata,
@ -62,7 +62,7 @@
return false; return false;
} }
else { else {
if(!settings.apiSettings) { if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) {
module.debug('No API url found, using current url'); module.debug('No API url found, using current url');
settings.apiSettings = { settings.apiSettings = {
url: settings.path + '/{$tab}' url: settings.path + '/{$tab}'
@ -71,7 +71,8 @@
module.verbose('Address library found adding state change event'); module.verbose('Address library found adding state change event');
$.address $.address
.state(settings.path) .state(settings.path)
.change(module.event.history.change) .unbind('change')
.bind('change', module.event.history.change)
; ;
} }
} }
@ -160,7 +161,14 @@
change: function(tabPath) { change: function(tabPath) {
var 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(); module.deactivate.all();
$.each(pathArray, function(index, tab) { $.each(pathArray, function(index, tab) {
@ -170,10 +178,6 @@
isTab = module.is.tab(currentPath), isTab = module.is.tab(currentPath),
isLastIndex = (index + 1 == pathArray.length), 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), $tab = module.get.tabElement(currentPath),
nextPathArray, nextPathArray,
@ -195,7 +199,9 @@
nextPathArray = pathArray.slice(0, index + 2); nextPathArray = pathArray.slice(0, index + 2);
nextPath = module.utils.arrayToPath(nextPathArray); nextPath = module.utils.arrayToPath(nextPathArray);
isLastTab = ( !module.is.tab(nextPath) ); isLastTab = ( !module.is.tab(nextPath) );
module.verbose('Tab parameters found', nextPathArray); if(isLastTab) {
module.verbose('Tab parameters found', nextPathArray);
}
} }
if(isLastTab && remoteContent) { if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) { if(!shouldIgnoreLoad) {
@ -208,14 +214,15 @@
module.cache.add(tabPath, $tab.html()); module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.debug('Opened local tab', currentPath); module.debug('Opened local tab', currentPath);
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.error(errors.missingTab, tab); module.error(errors.missingTab, tab);
@ -245,6 +252,7 @@
module.debug('Content loaded in background', tabPath); module.debug('Content loaded in background', tabPath);
} }
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
}, },
urlData: { tab: fullTabPath } urlData: { tab: fullTabPath }
}, },
@ -255,7 +263,7 @@
module.debug('Showing existing content', fullTabPath); module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent); module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath); module.activate.tab(tabPath);
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
} }
else if(existingRequest) { else if(existingRequest) {
module.debug('Content is already loading', fullTabPath); module.debug('Content is already loading', fullTabPath);
@ -297,10 +305,10 @@
}, },
navigation: function(tabPath) { navigation: function(tabPath) {
var var
$nav = module.get.navElement(tabPath) $navigation = module.get.navElement(tabPath)
; ;
module.verbose('Activating tab navigation for', $nav); module.verbose('Activating tab navigation for', $navigation, tabPath);
$nav.addClass(className.active); $navigation.addClass(className.active);
} }
}, },
@ -354,6 +362,9 @@
} }
module.error(errors.recursion); module.error(errors.recursion);
} }
else {
module.debug('No default tabs found for', tabPath);
}
recursionDepth = 0; recursionDepth = 0;
return tabPath; return tabPath;
}, },
@ -626,4 +637,4 @@
}; };
})( jQuery, window , document ); })( jQuery, window , document );

41
node/src/files/components/semantic/modules/tab.js

@ -30,7 +30,7 @@
moduleSelector = $module.selector || '', moduleSelector = $module.selector || '',
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module', moduleNamespace = settings.namespace + '-module',
className = settings.className, className = settings.className,
metadata = settings.metadata, metadata = settings.metadata,
@ -62,7 +62,7 @@
return false; return false;
} }
else { else {
if(!settings.apiSettings) { if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) {
module.debug('No API url found, using current url'); module.debug('No API url found, using current url');
settings.apiSettings = { settings.apiSettings = {
url: settings.path + '/{$tab}' url: settings.path + '/{$tab}'
@ -71,7 +71,8 @@
module.verbose('Address library found adding state change event'); module.verbose('Address library found adding state change event');
$.address $.address
.state(settings.path) .state(settings.path)
.change(module.event.history.change) .unbind('change')
.bind('change', module.event.history.change)
; ;
} }
} }
@ -160,7 +161,14 @@
change: function(tabPath) { change: function(tabPath) {
var 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(); module.deactivate.all();
$.each(pathArray, function(index, tab) { $.each(pathArray, function(index, tab) {
@ -170,10 +178,6 @@
isTab = module.is.tab(currentPath), isTab = module.is.tab(currentPath),
isLastIndex = (index + 1 == pathArray.length), 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), $tab = module.get.tabElement(currentPath),
nextPathArray, nextPathArray,
@ -195,7 +199,9 @@
nextPathArray = pathArray.slice(0, index + 2); nextPathArray = pathArray.slice(0, index + 2);
nextPath = module.utils.arrayToPath(nextPathArray); nextPath = module.utils.arrayToPath(nextPathArray);
isLastTab = ( !module.is.tab(nextPath) ); isLastTab = ( !module.is.tab(nextPath) );
module.verbose('Tab parameters found', nextPathArray); if(isLastTab) {
module.verbose('Tab parameters found', nextPathArray);
}
} }
if(isLastTab && remoteContent) { if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) { if(!shouldIgnoreLoad) {
@ -208,14 +214,15 @@
module.cache.add(tabPath, $tab.html()); module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.debug('Opened local tab', currentPath); module.debug('Opened local tab', currentPath);
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.error(errors.missingTab, tab); module.error(errors.missingTab, tab);
@ -245,6 +252,7 @@
module.debug('Content loaded in background', tabPath); module.debug('Content loaded in background', tabPath);
} }
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
}, },
urlData: { tab: fullTabPath } urlData: { tab: fullTabPath }
}, },
@ -255,7 +263,7 @@
module.debug('Showing existing content', fullTabPath); module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent); module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath); module.activate.tab(tabPath);
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
} }
else if(existingRequest) { else if(existingRequest) {
module.debug('Content is already loading', fullTabPath); module.debug('Content is already loading', fullTabPath);
@ -297,10 +305,10 @@
}, },
navigation: function(tabPath) { navigation: function(tabPath) {
var var
$nav = module.get.navElement(tabPath) $navigation = module.get.navElement(tabPath)
; ;
module.verbose('Activating tab navigation for', $nav); module.verbose('Activating tab navigation for', $navigation, tabPath);
$nav.addClass(className.active); $navigation.addClass(className.active);
} }
}, },
@ -354,6 +362,9 @@
} }
module.error(errors.recursion); module.error(errors.recursion);
} }
else {
module.debug('No default tabs found for', tabPath);
}
recursionDepth = 0; recursionDepth = 0;
return tabPath; return tabPath;
}, },
@ -626,4 +637,4 @@
}; };
})( jQuery, window , document ); })( jQuery, window , document );

4
node/src/files/stylesheets/semantic.css

@ -236,7 +236,9 @@ a:hover {
-webkit-border-radius: 0px; -webkit-border-radius: 0px;
-moz-border-radius: 0px; -moz-border-radius: 0px;
border-radius: 0px; border-radius: 0px;
font-size: 0.85em; }
#example #menu .item .item {
font-size: 0.875rem;
} }
#example .sidr .ui.menu { #example .sidr .ui.menu {

41
src/modules/tab.js

@ -30,7 +30,7 @@
moduleSelector = $module.selector || '', moduleSelector = $module.selector || '',
eventNamespace = '.' + settings.namespace, eventNamespace = '.' + settings.namespace,
moduleNamespace = settings.namespace + '-module', moduleNamespace = settings.namespace + '-module',
className = settings.className, className = settings.className,
metadata = settings.metadata, metadata = settings.metadata,
@ -62,7 +62,7 @@
return false; return false;
} }
else { else {
if(!settings.apiSettings) { if($.isPlainObject(settings.apiSettings) && settings.action === undefined && settings.url === undefined) {
module.debug('No API url found, using current url'); module.debug('No API url found, using current url');
settings.apiSettings = { settings.apiSettings = {
url: settings.path + '/{$tab}' url: settings.path + '/{$tab}'
@ -71,7 +71,8 @@
module.verbose('Address library found adding state change event'); module.verbose('Address library found adding state change event');
$.address $.address
.state(settings.path) .state(settings.path)
.change(module.event.history.change) .unbind('change')
.bind('change', module.event.history.change)
; ;
} }
} }
@ -160,7 +161,14 @@
change: function(tabPath) { change: function(tabPath) {
var 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(); module.deactivate.all();
$.each(pathArray, function(index, tab) { $.each(pathArray, function(index, tab) {
@ -170,10 +178,6 @@
isTab = module.is.tab(currentPath), isTab = module.is.tab(currentPath),
isLastIndex = (index + 1 == pathArray.length), 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), $tab = module.get.tabElement(currentPath),
nextPathArray, nextPathArray,
@ -195,7 +199,9 @@
nextPathArray = pathArray.slice(0, index + 2); nextPathArray = pathArray.slice(0, index + 2);
nextPath = module.utils.arrayToPath(nextPathArray); nextPath = module.utils.arrayToPath(nextPathArray);
isLastTab = ( !module.is.tab(nextPath) ); isLastTab = ( !module.is.tab(nextPath) );
module.verbose('Tab parameters found', nextPathArray); if(isLastTab) {
module.verbose('Tab parameters found', nextPathArray);
}
} }
if(isLastTab && remoteContent) { if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) { if(!shouldIgnoreLoad) {
@ -208,14 +214,15 @@
module.cache.add(tabPath, $tab.html()); module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.debug('Opened local tab', currentPath); module.debug('Opened local tab', currentPath);
module.activate.all(currentPath); module.activate.all(currentPath);
$.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
} }
return false;
} }
else { else {
module.error(errors.missingTab, tab); module.error(errors.missingTab, tab);
@ -245,6 +252,7 @@
module.debug('Content loaded in background', tabPath); module.debug('Content loaded in background', tabPath);
} }
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
$.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
}, },
urlData: { tab: fullTabPath } urlData: { tab: fullTabPath }
}, },
@ -255,7 +263,7 @@
module.debug('Showing existing content', fullTabPath); module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent); module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath); module.activate.tab(tabPath);
$.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent); $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
} }
else if(existingRequest) { else if(existingRequest) {
module.debug('Content is already loading', fullTabPath); module.debug('Content is already loading', fullTabPath);
@ -297,10 +305,10 @@
}, },
navigation: function(tabPath) { navigation: function(tabPath) {
var var
$nav = module.get.navElement(tabPath) $navigation = module.get.navElement(tabPath)
; ;
module.verbose('Activating tab navigation for', $nav); module.verbose('Activating tab navigation for', $navigation, tabPath);
$nav.addClass(className.active); $navigation.addClass(className.active);
} }
}, },
@ -354,6 +362,9 @@
} }
module.error(errors.recursion); module.error(errors.recursion);
} }
else {
module.debug('No default tabs found for', tabPath);
}
recursionDepth = 0; recursionDepth = 0;
return tabPath; return tabPath;
}, },
@ -626,4 +637,4 @@
}; };
})( jQuery, window , document ); })( jQuery, window , document );

Loading…
Cancel
Save