From 3aeccdc0cf3aa60040326313b84c483af0199e6f Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 21 Apr 2016 10:20:58 -0400 Subject: [PATCH] Smarter tab behavior for noajax tabs. --- themes/bootstrap3/js/record.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 1235a36d575..e3727b6c3e5 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -229,12 +229,25 @@ function recordDocReady() { $('.record-tabs .nav-tabs a').click(function (e) { var $li = $(this).parent(); // If it's an active tab, click again to follow to a shareable link. - // if we're flagged to skip AJAX for this tab, just return true and let the browser handle it. - if($li.hasClass('active') || $li.hasClass('noajax')) { + if ($li.hasClass('active')) { return true; } var tabid = this.className; var $top = $(this).closest('.record-tabs'); + // if we're flagged to skip AJAX for this tab, we need special behavior: + if ($li.hasClass('noajax')) { + // if this was the initially active tab, we have moved away from it and + // now need to return -- just switch it back on. + if ($li.hasClass('initiallyActive')) { + $(this).tab('show'); + $top.find('.tab-pane.active').removeClass('active'); + $top.find('.'+tabid+'-tab').addClass('active'); + window.location.hash = 'tabnav'; + return false; + } + // otherwise, we need to let the browser follow the link: + return true; + } $top.find('.tab-pane.active').removeClass('active'); $(this).tab('show'); if ($top.find('.'+tabid+'-tab').length > 0) { -- GitLab