summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfenstrat2018-07-20 13:46:04 (GMT)
committerMark Carver2018-07-20 13:46:04 (GMT)
commit295bf67cb592c263219b8b2a2f49a276e283bdad (patch)
treee6e503498f567c9175da91e422cf9b32d4e16b2f
parent97e3d9fd58dfb5fe4ac947b4e5a0618e2379579f (diff)
Issue #2985470 by fenstrat: Fragment links to children elements in closed vertical tabs don't work8.x-3.12
-rw-r--r--js/misc/vertical-tabs.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/misc/vertical-tabs.js b/js/misc/vertical-tabs.js
index 0085c4d..83cfec4 100644
--- a/js/misc/vertical-tabs.js
+++ b/js/misc/vertical-tabs.js
@@ -7,6 +7,23 @@
"use strict";
/**
+ * Show the parent vertical tab pane of a targeted page fragment.
+ *
+ * In order to make sure a targeted element inside a vertical tab pane is
+ * visible on a hash change or fragment link click, show all parent panes.
+ *
+ * @param {jQuery.Event} e
+ * The event triggered.
+ * @param {jQuery} $target
+ * The targeted node as a jQuery object.
+ */
+ var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e, $target) {
+ $target.parents('.vertical-tabs-pane').each(function (index, pane) {
+ $(pane).data('verticalTab').focus();
+ });
+ };
+
+ /**
* This script transforms a set of details into a stack of vertical
* tabs. Another tab pane can be selected by clicking on the respective
* tab.
@@ -26,6 +43,11 @@
return;
}
+ /**
+ * Binds a listener to handle fragment link clicks and URL hash changes.
+ */
+ $('body').once('vertical-tabs-fragments').on('formFragmentLinkClickOrHashChange.verticalTabs', handleFragmentLinkClickOrHashChange);
+
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
var $this = $(this).addClass('tab-content vertical-tabs-panes');