var AAN = AAN || {}; Formstone.NoConflict(); try { AAN.nav_universal = function ($) { var namespace = 'header'; var $doc = $(document); var $html = $('html'); var $body = $('body'); var $nav = $('.nav-universal-container'); var $btnSiteSearch = $nav.find('.btn-site-search'); var btnSiteSearchTextDefault = $btnSiteSearch.text(); var btnSiteSearchTextHide = 'Hide Search'; var $siteSearch = $nav.find('.site-search-container'); var $btnPublications = $nav.find('.publications button') var $modal = $('.modal-publications'); var $btnModalClose = $modal.find('.btn-close'); var $loginModal = $('#login'); var $btnLogin = $nav.find('.login button'); init = function () { var closeModal = function () { $(".hdr-global").show(); $("main").show(); $(".ftr-global-container").show(); $body.removeClass('modal-active-publications'); $modal.siblings().each(function () { $(this)[0].inert = false; }); $btnPublications.focus(); $doc.off('keyup.publicationsModal'); }; $btnPublications.on('click', function () { $(".hdr-global").hide(); $("main").hide(); $(".ftr-global-container").hide(); $body.addClass('modal-active-publications'); $modal.scrollTop(0); $modal.siblings().each(function () { $(this)[0].inert = true; }); $btnModalClose.focus(); $doc.on('keyup.publicationsModal', function (e) { if (e.keyCode === 27) { closeModal(); } }); }); $btnModalClose.on('click', function () { closeModal(); }); $btnSiteSearch.on('click', function () { var $btn = $(this); if ($nav.hasClass('search-active')) { $nav.removeClass('search-active'); $siteSearch.fadeOut('fast'); $btn.text(btnSiteSearchTextDefault); } else { $nav.addClass('search-active'); $btn.text(btnSiteSearchTextHide); $siteSearch.fadeIn('fast'); $siteSearch.find('input[type="search"]').eq(0).focus(); } }); $btnLogin.on('click', function () { $loginModal.addClass('visible'); $loginModal.animate({ 'opacity': 1, }, 500); $html.addClass('modal-open'); }); $loginModal.find('.overlay, .btn-close').on('click', function () { $loginModal.animate({ 'opacity': 0, }, 500, function () { $loginModal.removeClass('visible'); }); $html.removeClass('modal-open'); }); }; self.init(); }(jQuery); } catch (error) { console.error(error); } try { AAN.main_nav = function ($) { var namespace = 'main-nav'; var $html = $('html'); var $menu = $('#main-menu'); var $menuBtn = $menu.find('.btn-nav-main'); var $submenuTriggers = $menu.find('.icon-submenu-trigger'); var $navButtons = $menu.find('> ul > li'); init = function () { $menuBtn.on('click.' + namespace, function () { var $this = $(this); if (!$html.hasClass('menu-open')) { $this.find('span').html('Hide'); $this.attr('aria-expanded', 'true'); } else { $this.find('span').html('Display'); $this.attr('aria-expanded', 'false'); } $html.toggleClass('menu-open'); }); $submenuTriggers.on('click.' + namespace, function () { var $this = $(this), $li = $this.closest('li'); $this.blur(); if (!$li.hasClass('submenu-open')) { var $openMenu = $menu.find('.submenu-open'); $openMenu.find('button').attr('aria-expanded', 'false').find('span').html('Display'); $this.attr('aria-expanded', 'true').find('span').html('Hide'); } else { $this.attr('aria-expanded', 'false').find('span').html('Display'); } $li.toggleClass('submenu-open'); }); $.fsMediaquery("bind", "mq-key", "(min-width: 959px)", { enter: function () { whatInput.registerOnChange(inputChange, 'intent'); // if the main input changes (touch -> mouse, mouse -> touch) we need to change how we handle the // logic for the nav menu. function inputChange(type) { $html.removeClass('menu-open'); $navButtons.find('a').off('click'); if (type === 'touch') { $navButtons.find('> a').on('click.' + namespace, function (e) { var focusEvent, li = $(this).closest('li'); if (!$(this).closest('li').hasClass('submenu-open')) { e.preventDefault(); $menu.find('.submenu-open').removeClass('submenu-open'); li.addClass('submenu-open').focus(); li.one("focusout", function () { li.removeClass('submenu-open'); }); } }); } } var lastScrollPos; var upDistance; $(window).on('scroll.stickynav', $.throttle(150, function () { var scrollTop = $(this).scrollTop(); var $body = $('body'); var headerOuterHeight = $('.hdr-global').outerHeight(); if (lastScrollPos) { if (scrollTop > lastScrollPos && scrollTop > headerOuterHeight) { $body.addClass('direction-down'); $body.removeClass('direction-up'); upDistance = null; } else { if (!upDistance) { upDistance = scrollTop; } if (upDistance - scrollTop > 25 || scrollTop < headerOuterHeight) { $body.addClass('direction-up'); $body.removeClass('direction-down'); } } } lastScrollPos = scrollTop; })); }, leave: function () { $navButtons.find('a').off('click.' + namespace); $(window).unbind('scroll.stickynav'); $('body').removeClass('direction-down'); $('body').removeClass('direction-up'); } }); }; self.init(); }(jQuery); } catch (error) { console.error(error); } try { AAN.multistepForm = function ($) { var $formContainer = $('#main').find('.multistep-form'); function init() { $formContainer.find('fieldset.step').eq(0).removeClass('collapsed').find('.multistep-form-fields').slideDown(); $('.multistep-form .step .button-next').on('click', function () { $error = false; $(this).parents('fieldset.step').find('input').each(function () { if ($(this)[0].checkValidity()) { $(this).parents(".field").removeClass('error'); } else { $error = true; $(this).parents(".field").addClass('error'); } }); if ($error === true) { return false; } $(this) .parents('fieldset.step') .addClass('filled') .toggleClass('expanded') .toggleClass('collapsed') .find('.multistep-form-fields') .slideUp() .parents() .next('fieldset.step.collapsed') .toggleClass('expanded') .toggleClass('collapsed') .find('.multistep-form-fields') .slideDown(); return false; }); $('.multistep-form .step .button').on('click', function () { $error = false; $(this).parents('fieldset.step').find('input').each(function () { if ($(this)[0].checkValidity()) { $(this).parents(".field").removeClass('error'); } else { $error = true; $(this).parents(".field").addClass('error'); } }); if ($error === true) { return false; } }); $('.multistep-form .step .multistep-form-modify').on('click', function () { $formContainer.find('fieldset.step').addClass('collapsed').removeClass('expanded').find('.multistep-form-fields').slideUp(); $(this) .parents('fieldset.step') .removeClass('filled') .addClass('expanded') .removeClass('collapsed') .find('.multistep-form-fields') .slideDown() }); $('#IDoNotSeeMyMedicalSchoolListed, #IDoNotSeeMyResidencyLocationListed').on('click', function () { if ($(this).is(':checked')) { $(this).parents('.field').next('.field').addClass('is-visible'); $(this).parents('.field').next('.field').find('input').prop('disabled', false); $(this).parents('.field').next('.field').find('input').prop('required', true); $(this).parents('.secondary-element').find('select').prop('disabled', true); } else { $(this).parents('.field').next('.field').removeClass('is-visible'); $(this).parents('.field').next('.field').find('input').prop('disabled', true); $(this).parents('.field').next('.field').find('input').prop('required', false); $(this).parents('.secondary-element').find('select').prop('disabled', false); } }) } if ($formContainer.length) { init(); } }(jQuery); } catch (error) { console.error(error); } try { AAN.slick_slider = function ($) { var $window = $(window); var $slick = $('.slick-slider'); var $pagination = $('.slider-pagination'); init = function () { if ($window.width() < 768) { $slick.slick({ arrows: false, dots: true, appendDots: $pagination }); } }; if ($slick.length) { self.init(); } }(jQuery); } catch (error) { console.error(error); } try { AAN.alert = function ($) { var $alert = $('main .alert-container:not([id])'); var $breaking = $('main .breaking-container:not([id])'); //migrate the flag from session storage to local storage. if (window.sessionStorage.closedAlert !== undefined) { window.localStorage.closedAlert = "true"; delete window.sessionStorage.closedAlert; } //If the cookie saying the user if (document.querySelector("main > .breaking-container") !== null && window.localStorage.closedAlert !== "true") { document.querySelector("main > .breaking-container") .style.display = ""; } init = function () { $alert.each(function () { var $this = $(this); $this.find('.btn-close').on('click', function () { $this.remove(); }); }); }; if ($alert.length) { self.init(); } if ($breaking.length) { $breaking.each(function () { var $this = $(this); $this.find('.btn-close').on('click', function () { window.localStorage.closedAlert = "true"; $this.hide(); }); }); } }(jQuery); } catch (error) { console.error(error); } try { AAN.seeMore = function ($) { var $seeMoreItems = $('.see-more'); function init() { // loop through each see more item on the page $seeMoreItems.each(function (i, el) { $(el).data('initialheight', $(el).find('.text').height()); $(el).on('click', 'button', function () { toggle(el); }); // append the button $(el).append($('