Skip to content
Snippets Groups Projects
Commit c9416d54 authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Improved record tab hash handling for the initially active tab.

parent 1f7683b4
No related merge requests found
...@@ -183,6 +183,8 @@ function ajaxLoadTab($newTab, tabid, setHash) { ...@@ -183,6 +183,8 @@ function ajaxLoadTab($newTab, tabid, setHash) {
} }
if (typeof setHash == 'undefined' || setHash) { if (typeof setHash == 'undefined' || setHash) {
window.location.hash = tabid; window.location.hash = tabid;
} else {
removeHashFromLocation();
} }
}); });
return false; return false;
...@@ -264,6 +266,15 @@ function applyRecordTabHash() { ...@@ -264,6 +266,15 @@ function applyRecordTabHash() {
} }
} }
function removeHashFromLocation() {
if (window.history.replaceState) {
var href = window.location.href.split('#');
window.history.replaceState({}, document.title, href[0]);
} else {
window.location.hash = '#';
}
}
$(window).on('hashchange', applyRecordTabHash); $(window).on('hashchange', applyRecordTabHash);
function recordDocReady() { function recordDocReady() {
...@@ -293,7 +304,11 @@ function recordDocReady() { ...@@ -293,7 +304,11 @@ function recordDocReady() {
$(this).tab('show'); $(this).tab('show');
if ($top.find('.' + tabid + '-tab').length > 0) { if ($top.find('.' + tabid + '-tab').length > 0) {
$top.find('.' + tabid + '-tab').addClass('active'); $top.find('.' + tabid + '-tab').addClass('active');
window.location.hash = tabid; if ($(this).parent().hasClass('initiallyActive')) {
removeHashFromLocation();
} else {
window.location.hash = tabid;
}
return false; return false;
} else { } else {
var newTab = getNewRecordTab(tabid).addClass('active'); var newTab = getNewRecordTab(tabid).addClass('active');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment