$(document).ready(function () { $('body').addClass('js'); var $tab = $('.accordion-tab'); $tab.on("click", function (e) { e.preventDefault(); var $this = $(this); $this.toggleClass('active'); $this.next('.accordion-panel').toggleClass('active'); }); $('.jump-nav').on('click', function (e) { var target = $($(this).attr("href")); if (target.length) { ScrollTo(target.position().top - 65); e.preventDefault(); if (GetAdaptiveSize() == "xs") { $("ul.eyebrow-list, ul.jump-nav-list").slideUp(); } return false; } }); // $(".jump-nav-menu").on('click', function () { // $(this).siblings("ul").slideToggle(); // }) $(".jump-nav-menu").on('click', function () { $("ul.eyebrow-list, ul.jump-nav-list").slideToggle(); }) function GetAdaptiveSize() { if (!jQuery("#screen-test-xs").length) { //init adaptive check $("body").append('
'); } if (jQuery("#screen-test-xs:visible").length) { return "xs"; } else if (jQuery("#screen-test-sm:visible").length) { return "sm"; } else if (jQuery("#screen-test-md:visible").length) { return "md"; } else { return "lg"; } } function ScrollTo(t) { jQuery("html, body").animate({ scrollTop: t }, 1000) } navloc = $(".jump-nav-container")[0].getBoundingClientRect().top; $(window).on("scroll", function () { if ($(".jump-nav-container")[0].getBoundingClientRect().top < 0) { $(".jump-nav-container").addClass("fix"); } else { $(".jump-nav-container").removeClass("fix"); } }); //$(window).load(function () { // HandleResize(); //}); $(window).on('load', function () { HandleResize(); }); $(window).resize(function () { HandleResize(); }); function HandleResize() { NormalizeHeight('.news-item'); console.log("handling card resize"); } function NormalizeHeight(selector, forcedPadding, condition) { condition = condition == undefined ? true : condition; //leaning on a class that is only visible at mobile if (condition) { var maxHeight = 0; var cssHeight = ""; jQuery(selector).css({ "height": '' }); jQuery(selector).each(function () { var thisHeight = jQuery(this).height(); if (thisHeight > maxHeight) { maxHeight = thisHeight; cssHeight = jQuery(this).css("height"); } }); if (forcedPadding) cssHeight = (maxHeight + forcedPadding) + "px"; jQuery(selector).css({ "height": cssHeight }); } } });