jQuery(document).ready(function () { // Add submission date to hidden field value on Designer link gated content new and Design & Renovation Contact form submissionDateField(); // Blog active menu item fix blogCurrentMenuItem(); // Fix mobile background 100vh jumping glitch on innovation pages. jQuery(window).resize(resizeBackground); resizeBackground(); }); function resizeBackground() { var innovationBackground = jQuery(".itc-jsheight"); innovationBackground.height(jQuery(window).height()); } function submissionDateField() { if (jQuery('.form-submission-date').length) { let d = new Date(); let submissionMonth = d.getMonth() + 1; let submissionDay = d.getDate(); let submissionYear = d.getFullYear(); let submissionDate = submissionMonth + '/' + submissionDay + '/' + submissionYear; let submissionField = document.querySelector('.form-submission-date input'); submissionField.value = submissionDate; } } function blogCurrentMenuItem() { // If the current page is a single blog post if (jQuery('body').hasClass('single-post')) { if (jQuery('article').hasClass('category-stories')) { // Add current item menu class to Stories menu item when user is on a stories blog post jQuery('.stories-menu-item').addClass('current-menu-item'); } else { // Add current item menu class to Insights menu item when user is on a non stories blog post jQuery('.insights-menu-item').addClass('current-menu-item'); } } } // Fix anchor link scrolling on page load document.addEventListener('DOMContentLoaded', function(event){ if (window.location.hash) { // Start at top of page window.scrollTo(0, 0); // Prevent default scroll to anchor by hiding the target element var db_hash_elem = document.getElementById(window.location.hash.substring(1)); window.db_location_hash_style = db_hash_elem.style.display; db_hash_elem.style.display = 'none'; // After a short delay, display the element and scroll to it jQuery(function($){ setTimeout(function(){ $(window.location.hash).css('display', window.db_location_hash_style); et_pb_smooth_scroll($(window.location.hash), false, 800); }, 700); }); } }); jQuery(document).ready(function ($) { // Select all links with hashes $('a[href*="#"]') // Remove links that don't actually link to anything .not('[href="#"]') .not('[href="#0"]') .click(function(event) { // On-page links if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { // Figure out element to scroll to var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); // Does a scroll target exist? if (target.length) { // Only prevent default if animation is actually gonna happen event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 1000, function() { // Callback after animation // Must change focus! var $target = $(target); $target.focus(); if ($target.is(":focus")) { // Checking if the target was focused return false; } else { $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable $target.focus(); // Set focus again }; }); } } }); }); jQuery(document).ready(function ($) { // Retrieve params via window.location.search const paramsString = window.location.search; // Create new URLSearchParams Object const searchParams = new URLSearchParams(paramsString); const utm_source_key = 'utm_source'; const utm_medium_key = 'utm_medium'; const utm_term_key = 'utm_term'; const utm_campaign_key = 'utm_campaign'; const utm_content_key = 'utm_content'; function writeCookie(cName, cValue, expDays) { if(expDays){ let date = new Date(); date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000)); const expires = "expires=" + date.toUTCString(); document.cookie = "ds_" + cName + "=" + cValue + ";" + expires + ";path=/;"; }else{ document.cookie = "ds_" + cName + "=" + cValue + ";path=/;"; } } function readCookie(utm_property) { var allcookies = document.cookie; // Get all the cookies pairs in an array cookiearray = allcookies.split(';'); var output = ''; // Take key value pair out of this array for(var i=0; i