/// $(document).ready(function () { var firstLoad = true; //cssObjectFit($('.resources__item__image')); // open the first container of each section $('.resources__container').each(function () { loadSection($(this), 'resources'); }); // expand containers on click $('.resources__content').on('click', '.resources__section__top', function () { //resetContainers('resources'); // find target and expand, else close the div var $target = $(this).closest('.resources__section'); if (!$(this).hasClass('resources__section__active')) { resetResourcesSection(); if (!firstLoad) { $('html, body').animate({ scrollTop: $target.offset().top - $('#header').outerHeight(true) }, 350); } else { firstLoad = false; } $target.find('.resources__section__hidden').stop().slideDown(); $target.find('.resources__section__top, .resources__section__title').addClass('resources__section__active'); $target.find('.icon').addClass('icon-minus-icon').removeClass('icon-plus-icon'); } else { resetResourcesSection(); } }); function resetResourcesSection() { //reset all containers $('.resources__section__hidden').stop().hide(); $('.resources__section__top, .resources__section__title').removeClass('resources__section__active'); $('.resources').find('.icon').removeClass('icon-minus-icon').addClass('icon-plus-icon'); } function autoExpandFirstItem() { // open first container setTimeout(function () { var $firstTarget = $(document).find('.resources__container:visible .resources__section:first'); $firstTarget.find('.resources__section__top').click(); }, 10); } autoExpandFirstItem(); // change the directory $('.resources__navigation__button').click(function () { firstLoad = true; $this = $(this); $('.resources__navigation__button').removeClass('resources__active'); $(this).addClass('resources__active'); var theIndex = $(this).index(); $('.resources__container').addClass('hidden'); $('.r__' + theIndex).removeClass('hidden'); // reset all containers resetContainers('resources'); loadSection($('.r__' + theIndex), 'resources'); autoExpandFirstItem(); // set focus on first section item setTimeout(function () { $this.focus(); }, 500); return false; }); // bypass back/forward cache window.onpageshow = function (event) { if (event.persisted) { window.location.reload(); } }; $(window).bind('unload', function () { window.scrollTo(0, 0); }); $(window).bind('beforeunload', function () { window.scrollTo(0, 0); }); });