Fixed defaultTab selecting across instances if last tab was with current instance

This commit is contained in:
Steve Schwartz
2012-01-19 01:27:39 -05:00
parent a9cd969d73
commit 5aaa60bd75
+11 -5
View File
@@ -48,6 +48,7 @@
$defaultTab,
$defaultTabLink,
transitions,
lastHash,
skipUpdateToHash,
animationSpeeds = {
fast: 200,
@@ -285,6 +286,7 @@
} else if( ! $clicked.hasClass(settings.tabActiveClass) || ! $targetPanel.hasClass(settings.panelActiveClass) ){
plugin.activateTab($clicked, $targetPanel, ajaxUrl, callback);
}
};
plugin.toggleTabCollapse = function($clicked, $targetPanel, ajaxUrl, callback) {
@@ -345,7 +347,8 @@
targetHeight,
visibleHeight,
heightDifference,
showPanel;
showPanel,
hash = window.location.hash.match(/^[^\?]*/)[0];
if (settings.animate) {
targetHeight = plugin.getHeightForHidden($targetPanel);
@@ -353,6 +356,10 @@
heightDifference = targetHeight - visibleHeight;
}
// Set lastHash to help indicate if defaultTab should be
// activated across multiple tab instances.
lastHash = hash;
// TODO: Move this function elsewhere
showPanel = function() {
// At this point, the previous panel is hidden, and the new one will be selected
@@ -458,10 +465,9 @@
// If default tab is not active...
} else if ( ! $defaultTab.hasClass(settings.tabActiveClass) && ! settings.cycle ) {
// ...and hash is blank or matches a parent of the tab container
// TODO: probably make this also switch to defaultTab if the last tab (before the hash updated) was
// one of the other tabs in this container.
if ( hash === '' || $container.closest(hash).length ) {
// ...and hash is blank or matches a parent of the tab container or
// if the last tab (before the hash updated) was one of the other tabs in this container.
if ( hash === '' || plugin.matchTab(lastHash).length || $container.closest(hash).length ) {
skipUpdateToHash = true;
plugin.selectTab( $defaultTabLink );
}