Updating hash plugin to behave correctly in the presence of <base> tag.

This commit is contained in:
Jeremy Banks 2012-06-25 12:57:56 -03:00
parent 9accb16013
commit a4e4c8540f

View file

@ -110,6 +110,7 @@ slide.
/* Update permalink, address bar, and state class on a slide change */
.bind('deck.change', function(e, from, to) {
var hash = '#' + $[deck]('getSlide', to).attr('id'),
hashPath = window.location.href.replace(/#.*/, '') + hash,
opts = $[deck]('getOptions'),
osp = opts.classes.onPrefix,
$c = $[deck]('getContainer');
@ -117,9 +118,9 @@ slide.
$c.removeClass(osp + $[deck]('getSlide', from).attr('id'));
$c.addClass(osp + $[deck]('getSlide', to).attr('id'));
$(opts.selectors.hashLink).attr('href', hash);
$(opts.selectors.hashLink).attr('href', hashPath);
if (Modernizr.history) {
window.history.replaceState({}, "", hash);
window.history.replaceState({}, "", hashPath);
}
});