(function ($) { Drupal.behaviors.views_glossary = { attach: function (context, settings) { $('.sidebar-entry-wrapper').click(function () { var id = $(this).attr('data-id'); $('.sidebar-entry-wrapper').removeClass('is-active'); $(this).addClass('is-active'); $('.glossary-inner .single-node-wrap').hide(); $(".glossary-inner article[data-history-node-id='" + id + "']").closest('.single-node-wrap').show(); }); $('.top-trigger').click(function () { function jq( myid ) { return '#' + myid.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1" ); } if ($(this).attr('rel') !== '') { $(jq($(this).attr('rel'))).trigger("click"); $('.glossary-scroll').scrollTo(jq($(this).attr('rel'))); } }); if (window.location.hash !== '') { $(window.location.hash).trigger("click"); $('.glossary-scroll').scrollTo(window.location.hash); } } } }(jQuery));