From f00301991c0953e8739f9ece09ccb3c312c7d53d Mon Sep 17 00:00:00 2001 From: Brian Canini <canini.16@osu.edu> Date: Tue, 19 Jan 2021 11:06:38 -0500 Subject: [PATCH] setting option to link to anchors within accordions and have accordions open as expanded when user lands on page --- web/themes/asc_bootstrap/js/scripts.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/themes/asc_bootstrap/js/scripts.js b/web/themes/asc_bootstrap/js/scripts.js index 0d840471f6..7216c24b8e 100644 --- a/web/themes/asc_bootstrap/js/scripts.js +++ b/web/themes/asc_bootstrap/js/scripts.js @@ -218,6 +218,20 @@ jQuery(document).ready(function(){ }); } + //check for anchor hash in url and if exists open accordion + var accordionAnchor = window.location.hash; + var accordAnchorTrimmed = accordionAnchor.substring(1); + + if (accordionAnchor.length) { + var accordDiv = jQuery('[id="'+accordAnchorTrimmed+'"]').parent().parent().parent().parent().parent().attr('id'), + pattern = /collapse/, + exists = pattern.test(accordDiv); + if(exists) { + jQuery(window).scrollTop(jQuery('#'+accordDiv).offset().top); + jQuery('#'+accordDiv).addClass('in'); + } + } + }); // window.addEventListener("load", function(event) { -- GitLab