|
|
@ -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 ); |
|
|
|
})( jQuery, window , document ); |