summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-09-06 14:57:39 +0200
committerSimon Rettberg2019-09-06 14:57:39 +0200
commit1dfde3501818ce43345a929e4d033d915bda7843 (patch)
tree97248a7bd879c2c27f21b7f7ba1dfe7e3e3b2f81
parent[roomplanner] Ugly workaround for modal-close-bug on Firefox (diff)
downloadslx-admin-1dfde3501818ce43345a929e4d033d915bda7843.tar.gz
slx-admin-1dfde3501818ce43345a929e4d033d915bda7843.tar.xz
slx-admin-1dfde3501818ce43345a929e4d033d915bda7843.zip
[slx-fixes.js] Put current tab on pages with tab-panes in history
Also restore tab properly on reload or when sending link to other people.
-rw-r--r--script/slx-fixes.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/script/slx-fixes.js b/script/slx-fixes.js
index e8380702..e3b42812 100644
--- a/script/slx-fixes.js
+++ b/script/slx-fixes.js
@@ -122,3 +122,17 @@ jQuery.cachedScript = function(url, callback, options) {
});
return jQuery.ajax( options );
};
+
+// Restore tab state on refresh and add it to URL so copying URLs works
+$(document).ready(function() {
+ if ($('a[data-toggle="tab"]').click(function (e) {
+ history.pushState(null, null, this.getAttribute('href'));
+ }).length === 0) return;
+ var initTab = $('li.active > a[data-toggle="tab"]').attr('href');
+ var bla = function() {
+ var h = location.hash || initTab;
+ $('a[data-toggle="tab"][href="' + h + '"]').tab('show');
+ };
+ bla();
+ $(window).on('popstate', bla);
+});