Add tab position saving to tenderfoot

This commit is contained in:
Graham Triggs 2017-09-28 13:04:23 +01:00
parent 3980859101
commit 1ffe30fb4b

View file

@ -5,4 +5,26 @@ $(document).ready(function(){
$("#viewAllTab").addClass("active");
$(".tab-pane").addClass("fade active in");
});
if (location.hash) {
$('li[href=\'' + location.hash + '\']').tab('show');
}
var activeTab = localStorage.getItem('activeTab');
if (activeTab) {
$('li[href="' + activeTab + '"]').tab('show');
}
$('body').on('click', 'li[data-toggle=\'tab\']', function (e) {
e.preventDefault()
var tab_name = this.getAttribute('href')
localStorage.setItem('activeTab', tab_name)
$(this).tab('show');
return false;
});
$(window).on('popstate', function () {
var anchor = location.hash ||
$('li[data-toggle=\'tab\']').first().attr('href');
$('li[href=\'' + anchor + '\']').tab('show');
});
});