Skip to content

extend pushState call to allow use of base href #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 40 additions & 13 deletions lib/jquery.easytabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
$defaultTabLink,
transitions,
lastHash,
skipUpdateToHash,
animationSpeeds = {
skipUpdateToHash,
fast: 200,
normal: 400,
slow: 600
Expand Down Expand Up @@ -341,10 +341,8 @@
});
}
};

// Convenient public methods
plugin.publicMethods = {
select: function(tabSelector){

plugin.getTabBySelector = function(tabSelector){
var $tab;

// Find tab container that matches selector (like 'li#tab-one' which contains tab link)
Expand All @@ -371,7 +369,36 @@
// Select the child tab link, since the first option finds the tab container (like <li>)
$tab = $tab.children("a").first();
}
plugin.selectTab($tab);
return $tab;
}

// Convenient public methods
plugin.publicMethods = {
select: function(tabSelector){
plugin.selectTab(plugin.getTabBySelector(tabSelector));
},
href: function(args){
// method parameters: String tabSelector, String href, Boolean reload
var $tab, href, reload;
if (args.length < 1){
$.error('tabSelector parameter missing');
return this;
}

$tab = plugin.getTabBySelector(args[0]);

if (args.length == 1){
return $tab.parent().data('easytabs').ajax;
}

$tab.parent().data('easytabs').ajax = args[1];

if (args.length < 2 || args[2] !== false)
{
plugin.selectTab($tab);

}
return this;
}
};

Expand Down Expand Up @@ -538,12 +565,12 @@
if ( settings.updateHash && ! skipUpdateToHash ) {
//window.location = url.toString().replace((url.pathname + hash), (url.pathname + $clicked.attr("href")));
// Not sure why this behaves so differently, but it's more straight forward and seems to have less side-effects
if (window.history.pushState) {
window.history.pushState(null, null, '#' + $targetPanel.attr('id'));
}
else {
window.location.hash = '#' + $targetPanel.attr('id');
}
if (window.history.pushState) {
window.history.pushState(null, null, window.location.href.split('#')[0] + '#' + $targetPanel.attr('id'));
}
else {
window.location.hash = '#' + $targetPanel.attr('id');
}
} else {
skipUpdateToHash = false;
}
Expand Down Expand Up @@ -706,4 +733,4 @@
});
};

})(jQuery);
})(jQuery);
12 changes: 0 additions & 12 deletions lib/jquery.easytabs.min.js

This file was deleted.