1/** 2 * Custom javascript for the Insite Child theme. 3 * This file loads after the custom.js file in the Insite parent theme. 4 */ 5 6/** debounce function 7* Use to fire a function in steps rather than continuosly, as for example 8* during resize or scrolling. 9* Returns a function, that, as long as it continues to be invoked, will not 10* be triggered. The function will be called after it stops being called for 11* N milliseconds. If 'immediate' is passed, trigger the function on the 12* leading edge, instead of the trailing. 13* see: https://davidwalsh.name/javascript-debounce-function 14*/ 15function debounce(func, wait, immediate) { 16 var timeout; 17 return function() { 18 var context = this, args = arguments; 19 var later = function() { 20 timeout = null; 21 if (!immediate) func.apply(context, args); 22 }; 23 var callNow = immediate && !timeout; 24 clearTimeout(timeout); 25 timeout = setTimeout(later, wait); 26 if (callNow) func.apply(context, args); 27 }; 28} 29 30$(document).ready(function(){ 31 /** Remove comments from homepage */ 32 function removeHomepageComments() { 33 if ($('body').hasClass('home')) { 34 //var str = $('body').html(); 35 //str = str.replace(/<\!--.*?-->/g, ""); 36 html = $('#content').html(); 37 return html.replace(/<!--[\s\S]*?(?:-->)/g, ''); 38 } 39 } 40 removeHomepageComments(); 41 42 function alignHomepageTop() { 43 if ( ($('body').hasClass('home')) ) { 44 let waveHeight = $('nav.site-nav').height(); 45 let sectionMarginBottom = waveHeight / 4; 46 let tuck = waveHeight / 2; 47 $('div.donation-top').css({ 48 "height": waveHeight, 49 "top": -waveHeight 50 }); 51 $('section.donation > .row').css("transform", `translateY(-${tuck}px)`); 52 $('section.donation .col-support').css("background-image", "url('https://alzfdn2.mystagingwebsite.com/wp-content/uploads/2025/04/AFA-welcome-image.jpg')"); 53 $('section.donation #mobile-mother-daughter-hug-image img').css("visibility", "visible"); 54 /* $('section.donation').css("margin-bottom", -sectionMarginBottom); */ 55 $('section.donation .col-help').css("padding-top", waveHeight); 56 } 57 }; 58 alignHomepageTop(); 59 /** reload page on orientation change */ 60 window.onorientationchange = function() { window.location.reload(); }; 61 /** move translator element */ /* no longer in use */ 62 /* $("section#polylang-2").prependTo("div.top-col.top-tools"); */ 63 /** font size toggling */ 64 function fontToggler(){ 65 /* Create the toggler element and add it to the webpage: */ 66 /* Using Font Awesome letter "A" so it is not translated to the word A e.g. UN */ 67 var togglerElement = '<div class="font-toggler" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-html="true" data-bs-title="<em>change the size <br>of the text</em>" data-bs-custom-class="custom-tooltip"><span class="font-sm" aria-label="Choose small font size"><i class="fa-sharp fa-solid fa-a"></i></span><span class="font-md" aria-label="Choose medium font size"><i class="fa-sharp fa-solid fa-a"></i></span><span class="font-lg" aria-label="Choose large font size"><i class="fa-sharp fa-solid fa-a"></i></span><span class="font-xl" aria-label="Choose extra large font size"><i class="fa-sharp fa-solid fa-a"></i></span></div>'; 68 $('.top-tools').prepend(togglerElement); 69 /** enable tooltips */ 70 const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); 71 const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)); 72 73 74 /* Check if a cookie exists or not: */ 75 let fontCookie = Cookies.get('fontSize'); 76 console.log("fontCookie is "+fontCookie); 77 /* Set the initial size: */ 78 if ( fontCookie == 'sm' ) { initial = 'f-sm'; } 79 if ( fontCookie == 'md' ) { initial = 'f-md'; } 80 if ( fontCookie == 'lg' ) { initial = 'f-lg'; } 81 if ( fontCookie == 'xl' ) { initial = 'f-xl'; } 82 if ( fontCookie == undefined ) { 83 //initial = getComputedStyle(document.documentElement).getPropertyValue('--content-font-size'); 84 initial = $('html').attr('class'); 85 } 86 /* Set CSS variable, which determines how the resizable text is displayed: */ 87 //document.documentElement.style.setProperty('--content-font-size', initial); 88 $('html').addClass(initial); 89 90 console.log('initial font-size is '+initial); 91 92 /* Synch the active selector element indicator with the intital state: */ 93 var initialSelector; 94 if ( initial == 'f-sm' ) { 95 initialSelector = '.font-sm'; 96 } else if ( initial == 'f-md' ) { 97 initialSelector = '.font-md'; 98 } else if ( initial == 'f-lg' ) { 99 initialSelector = '.font-lg'; 100 } else if ( initial == 'f-xl' ) { 101 initialSelector = '.font-xl'; 102 } 103 $(initialSelector).addClass('active-size'); 104 105 /* Actions upon indicator click: */ 106 $('.font-sm').click(function() { 107 //document.documentElement.style.setProperty('--content-font-size', '1rem'); 108 $('html').removeClass('f-md f-lg f-xl').addClass('f-sm'); 109 $('.font-toggler span').each(function(){ 110 $(this).removeClass('active-size'); 111 }); 112 $(this).addClass('active-size'); 113 /* Set a cookie to make this the preferred size: */ 114 Cookies.set('fontSize', 'sm', { expires: 365 }); 115 }); 116 $('.font-md').click(function() { 117 //document.documentElement.style.setProperty('--content-font-size', '1.1rem'); 118 $('html').removeClass('f-sm f-lg f-xl').addClass('f-md'); 119 $('.font-toggler span').each(function(){ 120 $(this).removeClass('active-size'); 121 }); 122 $(this).addClass('active-size'); 123 /* Set a cookie to make this the preferred size: */ 124 Cookies.set('fontSize', 'md', { expires: 365 }); 125 }); 126 $('.font-lg').click(function() { 127 //document.documentElement.style.setProperty('--content-font-size', '1.2rem'); 128 $('html').removeClass('f-sm f-md f-xl').addClass('f-lg'); 129 $('.font-toggler span').each(function(){ 130 $(this).removeClass('active-size'); 131 }); 132 $(this).addClass('active-size'); 133 /* Set a cookie to make this the preferred size: */ 134 Cookies.set('fontSize', 'lg', { expires: 365 }); 135 }); 136 $('.font-xl').click(function() { 137 //document.documentElement.style.setProperty('--content-font-size', '1.3rem'); 138 $('html').removeClass('f-sm f-md f-lg').addClass('f-xl'); 139 $('.font-toggler span').each(function(){ 140 $(this).removeClass('active-size'); 141 }); 142 $(this).addClass('active-size'); 143 /* Set a cookie to make this the preferred size: */ 144 Cookies.set('fontSize', 'xl', { expires: 365 }); 145 }); 146 } 147 fontToggler(); 148 149 function afaTranslateButton() { 150 $(".gtranslate_wrapper").addClass('afa-translate-wrapper').attr('id','afa_translate_wrapper'); 151 $(".gtranslate_wrapper").wrap('<div id="translate-tooltip-wrap" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="<em>Translations powered by <br>Google Translate.</em>" data-bs-custom-class="custom-tooltip"></div>'); 152 const translateEl = document.getElementById('translate-tooltip-wrap'); 153 const tooltip = new bootstrap.Tooltip(translateEl); 154 /* const tooltip = new bootstrap.Tooltip({ 155 container: document.querySelector('#afa_translate_wrapper'); 156 }); */ 157 158 }; 159 afaTranslateButton(); 160 161 /* function chatFunction() { 162 Zingle.open(); 163 return false;
164 } */ 165 //chatFunction(); 166 //function equalDonateColumns 167 168 /** 169 * Randomize sidebar widgets. 170 * Do not randomize on the first page visited after the homepage, or on the first page visited in the session if not the homepage. 171 */ 172 173 /** Randomize first 4 #secondary widgets using Bootstrap .order-* classes */ 174 var referrer = document.referrer; 175 var originHome = window.location.origin + '/'; 176 var cameFromHome = referrer === originHome; 177 var isHome = $('body').hasClass('home'); 178 179 if ($('#secondary').length) { 180 var shuffled = $('#secondary > section').slice(0, 4); 181 182 if (!cameFromHome && !isHome) { 183 var orders = ['order-1', 'order-2', 'order-3', 'order-4']; 184 shuffled.addClass('invisible'); 185 orders.sort(function() { 186 return 0.5 - Math.random(); 187 }); 188 shuffled.each(function(index) { 189 var $this = $(this); 190 $this.removeClass('order-1 order-2 order-3 order-4 order-5 order-6'); 191 $this.removeClass(function(i, c) { 192 return (c.match(/(^|\s)random-\d+/g) || []).join(' '); 193 }); 194 $this.addClass(orders[index]); 195 $this.addClass('random-' + (index + 1)); 196 }); 197 shuffled.removeClass('invisible').hide().fadeIn(150); 198 } else { 199 /* Reveal unmodified widgets immediately */ 200 shuffled.removeClass('invisible').show(); 201 } 202 } 203 204 /** Randomize all #tertiary widgets using Bootstrap .order-* classes */ 205 if ($('#tertiary').length) { 206 var sections = $('#tertiary > section'); 207 var total = sections.length; 208 209 if (!cameFromHome && !isHome) { 210 var orders = []; 211 for (var i = 1; i <= total; i++) { 212 orders.push('order-' + i); 213 } 214 sections.addClass('invisible'); 215 orders.sort(function() { 216 return 0.5 - Math.random(); 217 }); 218 sections.each(function(index) { 219 var $this = $(this); 220 for (var j = 1; j <= total; j++) { 221 $this.removeClass('order-' + j); 222 } 223 $this.removeClass(function(i, c) { 224 return (c.match(/(^|\s)random-\d+/g) || []).join(' '); 225 }); 226 $this.addClass(orders[index]); 227 $this.addClass('random-' + (index + 1)); 228 }); 229 sections.removeClass('invisible').hide().fadeIn(150); 230 } else { 231 /* Reveal unmodified widgets immediately */ 232 sections.removeClass('invisible').show(); 233 } 234 } 235 236 /** fixes (temporary?) to remove some of the block editor styling from old content */ 237 function professionalize() { 238 /* Fix inline color styles */ 239 $('body.has-blocks .entry-content span, body.no-blocks .entry-content span').each(function(){ 240 const $span = $(this); 241 if (this.style && this.style.color) { 242 $span.css('color', 'inherit'); 243 } 244 if (this.style && this.style.textDecoration) { 245 $span.css('text-decoration', 'inherit'); 246 } 247 }); 248 /* Fix inline font sizes */ 249 $('body.has-blocks .entry-content p, body.no-blocks .entry-content p').each(function(){ 250 const $paragraph = $(this); 251 if (this.style && this.style.fontSize) { 252 $paragraph.css('fontSize', 'inherit'); 253 } 254 }); 255 /* Remove <mark> tags but keep their content */ 256 $('body.has-blocks .entry-content mark').each(function(){ 257 $(this).replaceWith($(this).contents()); 258 }); 259 /* Remove <u> tags but keep their content */ 260 $('body.has-blocks .entry-content u, body.no-blocks .entry-content u').each(function(){ 261 $(this).replaceWith($(this).contents()); 262 }); 263 /* hide p tags containing only whitespace */ 264 $('p').each(function(){ 265 if($.trim($(this).text()) == '' && $(this).children().length == 0){ 266 $(this).hide(); 267 } 268 }); 269 console.log('Professionalized.'); 270 } 271 professionalize(); 272 273 function printFriendly() { 274 const thisUrl = window.location.href; 275 const encodedUrl = encodeURIComponent(thisUrl); 276 const logoUrl = 'https://alzfdn.org/wp-content/uploads/2022/12/cropped-AFA-teal-logo-transparent.png'; 277 const encodedLogoUrl = encodeURIComponent(logoUrl); 278 const cssUrl = 'https://' + window.location.host + '/wp-content/themes/insite-child/printfriendly.css?ver=1.0.15'; 279 const encodedCssUrl = encodeURIComponent(cssUrl); 280 281 const baseUrl = "https://www.printfriendly.com/print/"; 282 const params = 283 '?source=cs' + 284 '&url=' + encodedUrl + 285 '&headerImageUrl=' + encodedLogoUrl + 286 '&imageDisplayStyle=block' + 287 '&disableClickToDel=0' + 288 '&disablePDF=0' + 289 '&encodeImages=false' + 290 '&showHiddenContent=false' + 291 '&disablePrint=0' + 292 '&disableEmail=0' + 293 '&imagesSize=size-large' + 294 '&fallbackStrategy=algo' + 295 '&primaryImage=all' + 296 '&fetchOriginalPage=default' + 297 '&customCSSURL=' + encodedCssUrl; 298 299 const printFriendlyUrl = baseUrl + params.trim(); 300 console.log('thisUrl = '+thisUrl); 301 console.log('encodedUrl = '+encodedUrl); 302 console.log('printFriendlyUrl Url = '+printFriendlyUrl); // Verify the output 303 $('#print-button').click(function(){ 304 window.open(printFriendlyUrl, "printFriendlyTab"); 305 306 }); 307 } 308 printFriendly(); 309 /* //$('span.pf a').trigger('click'); */ 310 311 /* search with icon */ 312 function searchWithIcon() { 313 $('.header-search .fa-magnifying-glass').click(function(){ 314 $("#site-search").submit(); 315 }); 316 } 317 searchWithIcon(); 318 319 function searchPageSearchWithIcon() { 320 if($('body').hasClass('search-results')) { 321 $('.header-search .fa-magnifying-glass').click(function(){
322 alert("Hit ENTER to search"); 323 $("#site-search").submit(); 324 }); 325 } 326 } 327 searchPageSearchWithIcon(); 328 329 /** homepage carousel */ 330 /* only run the carousel when it is visible */ 331 if($('body').hasClass('page-alzheimers-foundation-of-america')) { 332 /* !!Next line just for testng!! */ 333 $('.carousel').attr( "data-bs-interval", "300" ); 334 $('.carousel').attr( "is-paused", "no" ); 335 /* initially pause until page is scrolled */ 336 $('.carousel').carousel('pause'); 337 var pausePlayCarousel = debounce(function() { 338 $('.carousel').each(function() { 339 if ( ($(this).visible(true)) && ($(this).attr("is-paused")=="no") ) { 340 /* console.log('Carousel is visible.'); */ 341 $('.carousel').carousel('cycle'); 342 } else if ( ($(this).visible(true)) && ($(this).attr("is-paused")=="yes") ) { 343 /* console.log('Carousel is visible.'); */ 344 $('.carousel').carousel('pause'); 345 } else { 346 $('.carousel').carousel('pause'); 347 } 348 }); 349 }, 250); 350 window.addEventListener('scroll', pausePlayCarousel); 351 /* hide caption during transitions to avoid ugly appearance */ 352 $('.carousel').on('slide.bs.carousel', function () { 353 /* console.log('slide'); */ 354 $('.item-inner .carousel-caption').each(function(){ 355 $(this).addClass('invisible').delay(750).queue(function(next){ 356 $(this).removeClass('invisible'); 357 next(); 358 }); 359 }) 360 }) 361 /* } */ /* end bracket was here */ 362 let items = document.querySelectorAll('.carousel .carousel-item') 363 /* multi-item slider */ 364 items.forEach((el) => { 365 const minPerSlide = 6 366 let next = el.nextElementSibling 367 for (var i=1; i<minPerSlide; i++) { 368 if (!next) { 369 /* wrap carousel by using first child */ 370 next = items[0] 371 } 372 let cloneChild = next.cloneNode(true) 373 el.appendChild(cloneChild.children[0]) 374 next = next.nextElementSibling 375 } 376 }) 377 /* play and pause. since carousel is set to play when visible on scroll, we add extra to make sure it stays "pause"d until play is clicked again. */ 378 $('.btn.play').click(function(){ 379 $('.carousel').attr( "is-paused", "no" ); 380 $('.carousel').carousel('next').carousel('cycle'); 381 }) 382 $('.btn.pause').click(function(){ 383 $('.carousel').carousel('pause'); 384 $('.carousel').attr( "data-bs-ride", "false" ); 385 $('.carousel').attr( "is-paused", "yes" ); 386 }) 387 $('.carousel-control-next, .carousel-control-prev').click(function(){ 388 $('.carousel').carousel('pause'); 389 $('.carousel').attr( "data-bs-ride", "false" ) 390 $('.carousel').attr( "data-bs-next-when-visible", "false" ); 391 $('.carousel').attr( "data-bs-interval", "100000" ); 392 $('.carousel').attr( "is-paused", "yes" ); 393 }) 394 /* set default play/pause behavior */ 395 if($('.carousel').attr("is-paused")=="no") { 396 $('.carousel').carousel('cycle'); 397 } 398 if($('.carousel').attr("is-paused")=="yes") { 399 $('.carousel').carousel('pause'); 400 } 401 402 /** make the last line of carousel capts a span for color cahnge */ 403 $('div.carousel-caption p a').each(function() { 404 $( $(this).children('br').last().get(0).nextSibling ).wrap('<span></span>'); 405 }); 406 /** special for video modal link */ 407 $('div.carousel-item div.item-inner > a[href$="#videoModal"]').click(function() { 408 $(this).closest('.item-inner').find('.carousel-caption button').click(); 409 }); 410 $('div.carousel-item div.item-inner div.carousel-caption h4 a[href$="#videoModal"]').click(function() { 411 $(this).closest('.item-inner').find('.carousel-caption button').click(); 412 }); 413 $('div.carousel-item div.item-inner p > a[href$="#videoModal"]').attr("style", "cursor: text !important").css("text-decoration", "none"); 414 } /* testing end bracket here instead */ 415 416 /** Adjust mobile menu placement */ 417 /* scroll to top of window so that the menu will be onscreen */ 418 $('.mega-toggle-animated-box').click(function(){ 419 window.scrollTo(0, 0); 420 /* Get an element's distance from the top of the page */ 421 var getElemDistance = function ( elem ) { 422 var location = 0; 423 if (elem.offsetParent) { 424 do { 425 location += elem.offsetTop; 426 elem = elem.offsetParent; 427 } while (elem); 428 } 429 return location >= 0 ? location : 0; 430 }; 431 /* find the navbar and calculate its distance from the top of the window */
432 var elem = document.querySelector('nav.navbar.site-nav'); 433 var location = getElemDistance( elem ); 434 /* reset value to 0 */ 435 $('.width-xs #mega-menu-primary, .width-sm #mega-menu-primary, .width-md #mega-menu-primary').css('transform', 'translateY(0px)'); 436 /* use CSS to move the menu to the top of the window so that it will all be visible */ 437 let transformValue = 'translateY(-'+location+'px)'; 438 $('.width-xs #mega-menu-primary, .width-sm #mega-menu-primary, .width-md #mega-menu-primary').css('transform', transformValue); 439 }) 440 441 /** Find a Member Organization form adjustments */ 442 $('div.col-md-3:nth-of-type(2)').toggleClass('col-md-3 col-md-2'); 443 444 /** augment the labels of input fields in the Find a Member Organization form */ 445 $('form#member-filter input#afadir_search_wp').before("<div><strong>Search by Name:</strong> <em>(optional)</em></div>"); 446 $('form#member-filter div.col-md-3 > p, form#member-filter div.col-md-2 > p').html("Search by ZIP:").append(" <em>(optional)</em>"); 447 $('form#member-filter div.col-md-6.right').prepend('<div class="filter-instructions"><strong>Apply Filters:</strong> <em>(optional)</em></div>'); 448 449 /** duplicate the submit button to the proper place in the Find a Member Organization form */ 450 $(document).ready(function () { 451 // Clone the original submit button 452 //var submitButtonClone = $('form#member-filter input[type="submit"]').first().clone(); 453 454 // Insert the cloned button after the ZIP input 455 //submitButtonClone.insertAfter('#afadir_search_zip'); 456 }); 457 458 /** move the submit button to the proper place in the Find a Member Organization form */ 459 $(document).ready(function () { 460 $('form#member-filter input[type="submit"]').insertAfter('#afadir_search_languages'); 461 }); 462 463 /** allow multiple select fields to be filled without submitting the form until the "Search" button is clicked */ 464 /* Remove change handlers on selects to prevent auto-submit */ 465 $('form#member-filter select').off('change'); 466 /* Restore values from sessionStorage */ 467 $('form#member-filter').find('select, input[type="text"]').each(function () { 468 const savedValue = sessionStorage.getItem(this.name); 469 if (savedValue !== null) { 470 $(this).val(savedValue); 471 } 472 }); 473 /* Save values on submit */ 474 $('form#member-filter').on('submit', function () { 475 $(this).find('select, input[type="text"]').each(function () { 476 sessionStorage.setItem(this.name, $(this).val()); 477 }); 478 }); 479 480 /** Inject a Clear button at the end of the form */ 481 const clearBtn = $('<button type="button" class="btn-default btn-sm btn-reset" id="clear-filters">reset</button>'); 482 //$('form#member-filter').append(clearBtn); 483 $('form#member-filter .col-md-6.right').after(clearBtn); 484 $('#clear-filters').on('click', function () { 485 const form = $('form#member-filter'); 486 /* Clear form field values and sessionStorage */ 487 form.find('select, input[type="text"]').each(function () { 488 sessionStorage.removeItem(this.name); 489 $(this).val(''); 490 }); 491 /* Trigger change for enhanced select widgets */ 492 form.find('select').trigger('change'); 493 /* Submit the form to show all results again */ 494 form.submit(); 495 }); 496 497 /** Clean up the results list of Member Oranizations. Remove un-needed "Member" and finesse white-space. */ 498 $('section.c div.row.organization .col-md-8 p').each(function () { 499 let brCount = 0; 500 const contents = $(this).contents().toArray(); 501 for (let i = 0; i < contents.length; i++) { 502 const node = contents[i]; 503 /* Count <br> elements */ 504 if (node.nodeName === 'BR') { 505 brCount++; 506 } 507 /* Identify and remove "Member" text and preceding <br> */ 508 if (node.nodeType === 3 && brCount === 2 && node.nodeValue.trim() === 'Member') { 509 $(node).remove(); 510 const prev = contents[i - 1]; 511 if (prev && prev.nodeName === 'BR') { 512 $(prev).remove(); 513 } 514 /* Look ahead to find a <br> followed by a meaningful text node */ 515 for (let j = i; j < contents.length - 1; j++) { 516 const nextBr = contents[j]; 517 const nextText = contents[j + 1]; 518 if (nextBr.nodeName === 'BR' && nextText.nodeType === 3 && /\S/.test(nextText.nodeValue)) { 519 const span = $('<span class="org-services"></span>').text(nextText.nodeValue); 520 $(nextText).replaceWith(span); 521 break; 522 } 523 } 524 break; 525 } 526 } 527 /* Remove any stray whitespace-only text nodes */ 528 $(this).contents().filter(function () { 529 return this.nodeType === 3 && !/\S/.test(this.nodeValue); 530 }).remove(); 531 }); 532 533 /** Make listed organization clickable and hide other orgs when one is clicked */ 534 const scrollToEl = $('#member-filter'); 535 $('section.c div.row.organization .col-md-8').each(function(){ 536 $(this).addClass('listed-org'); 537 $(this).wrapInner("<span class='org-listing'></span>"); 538 //let orgName = $(this).children('org-listing h3').text(); 539 $('.listed-org').not(this).click(function(){ 540 $('.listed-org').not(this).parent('.row.organization').addClass('make-invisible'); 541 $('html').animate({ 542 scrollTop: scrollToEl.offset().top - 100, 543 }, 0 ); 544 }); 545 }); 546 547 /** fix placement of gravity forms Cardholder Name field */ 548 if ($('.gform_wrapper').length) { 549 $('label:contains("Cardholder Name")').addClass('clear'); 550 } 551 552 /** enable disabled submit button on research study acceptance form */ 553 $('#acceptance-checkbox').change(function () { 554 $('#signup-handoff').prop("disabled", !this.checked); 555 }).change() 556 557 /** spousal caregivers survey jumpoff form */ 558 /* Only execute script on the specific landing page */ 559 if ($('body').hasClass('page-spousal-caregiver-study-registration')) { 560 var handoffForm = function() { 561 var pageLoadTime = Date.now(); 562 var targetUrl = 'https://redcap.vumc.org/surveys/?s=KXPJPL8NTXRXJENW'; 563 /* 1. Handle Checkbox Toggle & Visibility */ 564 $('#acceptance-checkbox').on('change', function() { 565 var isChecked = this.checked; 566 var $form = $('#enrollment-form'); 567 var $submitBtn = $('#signup-handoff'); 568 /* Toggle CSS class for smooth fade-in/fade-out */ 569 $('#handoff-message').toggleClass('is-visible', isChecked); 570 if (isChecked) { 571 $submitBtn.prop('disabled', false); 572 $form.attr('action', targetUrl); 573 /* Inject JS verification token on interaction */ 574 if ($('#human_token').length === 0) { 575 $form.append('<input type="hidden" name="human_verification" id="human_token" value="verified_human" />'); 576 } 577 } else { 578 $submitBtn.prop('disabled', true); 579 $form.attr('action', '#'); 580 } 581 }).trigger('change');
581 /* Sync state if browser caches checked box on back/refresh */ 582 /* 2. Spam Prevention Validation on Form Submit */ 583 $('#enrollment-form').on('submit', function(e) { 584 var timeTaken = (Date.now() - pageLoadTime) / 1000; 585 /* Reject if honeypot was filled */ 586 if ($('#url_choice').val() !== '') { 587 e.preventDefault(); 588 return false; 589 } 590 /* Reject if JS token missing */ 591 if ($('#human_token').val() !== 'verified_human') { 592 e.preventDefault(); 593 return false; 594 } 595 /* Reject if submitted in less than 2 seconds */ 596 if (timeTaken < 2) { 597 e.preventDefault(); 598 return false; 599 } 600 /* 3. Handle Post-Submission UI (Prevent duplicate clicks) */ 601 setTimeout(function() { 602 $('#signup-handoff').prop('disabled', true).val('Submitted'); 603 $('#acceptance-checkbox').prop('checked', false); 604 $('#handoff-message').html('The survey has opened in a new tab or window. If you need to start over, please click or tap the <strong>Refresh button</strong> at the top of your browser.'); 605 }, 100); 606 }); 607 }; 608 handoffForm(); 609 } 610 611 612}); 613/** 614 * Copyright 2012, Digital Fusion 615 * Licensed under the MIT license. 616 * http://teamdf.com/jquery-plugins/license/ 617 * 618 * @author Sam Sehnert 619 * @desc A small plugin that checks whether elements are within 620 * the user visible viewport of a web browser. 621 * can account for vertical position, horizontal, or both 622 * https://github.com/customd/jquery-visible 623 * https://www.customd.com/articles/13/checking-if-an-element-is-visible-on-screen-using-jquery 624 * 625 * detect whether an element is visible in the viewport 626 * See author URL for usage details. Briefly: 627 * $('#element').visible() returns true if the entire element is within the viewport; 628 * $('#element').visible( true ) returns true if any part of the element within the viewport. 629 */ 630(function($){var $w=$(window);$.fn.visible=function(partial,hidden,direction,container){if(this.length<1)return;direction=direction||"both";var $t=this.length>1?this.eq(0):this,isContained=typeof container!=="undefined"&&container!==null,$c=isContained?$(container):$w,wPosition=isContained?$c.position():0,t=$t.get(0),vpWidth=$c.outerWidth(),vpHeight=$c.outerHeight(),clientSize=hidden===true?t.offsetWidth*t.offsetHeight:true;if(typeof t.getBoundingClientRect==="function"){var rec=t.getBoundingClientRect(),tViz=isContained?rec.top-wPosition.top>=0&&rec.top<vpHeight+wPosition.top:rec.top>=0&&rec.top<vpHeight,bViz=isContained?rec.bottom-wPosition.top>0&&rec.bottom<=vpHeight+wPosition.top:rec.bottom>0&&rec.bottom<=vpHeight,lViz=isContained?rec.left-wPosition.left>=0&&rec.left<vpWidth+wPosition.left:rec.left>=0&&rec.left<vpWidth,rViz=isContained?rec.right-wPosition.left>0&&rec.right<vpWidth+wPosition.left:rec.right>0&&rec.right<=vpWidth,vVisible=partial?tViz||bViz:tViz&&bViz,hVisible=partial?lViz||rViz:lViz&&rViz,vVisible=rec.top<0&&rec.bottom>vpHeight?true:vVisible,hVisible=rec.left<0&&rec.right>vpWidth?true:hVisible;if(direction==="both")return clientSize&&vVisible&&hVisible;else if(direction==="vertical")return clientSize&&vVisible;else if(direction==="horizontal")return clientSize&&hVisible}else{var viewTop=isContained?0:wPosition,viewBottom=viewTop+vpHeight,viewLeft=$c.scrollLeft(),viewRight=viewLeft+vpWidth,position=$t.position(),_top=position.top,_bottom=_top+$t.height(),_left=position.left,_right=_left+$t.width(),compareTop=partial===true?_bottom:_top,compareBottom=partial===true?_top:_bottom,compareLeft=partial===true?_right:_left,compareRight=partial===true?_left:_right;if(direction==="both")return!!clientSize&&(compareBottom<=viewBottom&&compareTop>=viewTop)&&(compareRight<=viewRight&&compareLeft>=viewLeft);else if(direction==="vertical")return!!clientSize&&(compareBottom<=viewBottom&&compareTop>=viewTop);else if(direction==="horizontal")return!!clientSize&&(compareRight<=viewRight&&compareLeft>=viewLeft)}}})(jQuery); 631 632/**! js-cookie v3.0.5 | MIT 633 * https://github.com/js-cookie/js-cookie 634 * Create a session cookie, valid across the entire site: Cookies.set('name', 'value') 635 * Create a cookie that expires 7 days from now: Cookies.set('name', 'value', { expires: 7 }) 636 * Read cookie: Cookies.get('name') // => 'value' 637 */ 638!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}var t=function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decode
638URIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});return t})); 639/**! WOW - v1.1.3 - 2016-05-06 640* Copyright (c) 2016 Matthieu Aussaguel;*/(function(){var a,b,c,d,e,f=function(a,b){return function(){return a.apply(b,arguments)}},g=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b=function(){function a(){}return a.prototype.extend=function(a,b){var c,d;for(c in b)d=b[c],null==a[c]&&(a[c]=d);return a},a.prototype.isMobile=function(a){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(a)},a.prototype.createEvent=function(a,b,c,d){var e;return null==b&&(b=!1),null==c&&(c=!1),null==d&&(d=null),null!=document.createEvent?(e=document.createEvent("CustomEvent"),e.initCustomEvent(a,b,c,d)):null!=document.createEventObject?(e=document.createEventObject(),e.eventType=a):e.eventName=a,e},a.prototype.emitEvent=function(a,b){return null!=a.dispatchEvent?a.dispatchEvent(b):b in(null!=a)?a[b]():"on"+b in(null!=a)?a["on"+b]():void 0},a.prototype.addEvent=function(a,b,c){return null!=a.addEventListener?a.addEventListener(b,c,!1):null!=a.attachEvent?a.attachEvent("on"+b,c):a[b]=c},a.prototype.removeEvent=function(a,b,c){return null!=a.removeEventListener?a.removeEventListener(b,c,!1):null!=a.detachEvent?a.detachEvent("on"+b,c):delete a[b]},a.prototype.innerHeight=function(){return"innerHeight"in window?window.innerHeight:document.documentElement.clientHeight},a}(),c=this.WeakMap||this.MozWeakMap||(c=function(){function a(){this.keys=[],this.values=[]}return a.prototype.get=function(a){var b,c,d,e,f;for(f=this.keys,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],c===a)return this.values[b]},a.prototype.set=function(a,b){var c,d,e,f,g;for(g=this.keys,c=e=0,f=g.length;f>e;c=++e)if(d=g[c],d===a)return void(this.values[c]=b);return this.keys.push(a),this.values.push(b)},a}()),a=this.MutationObserver||this.WebkitMutationObserver||this.MozMutationObserver||(a=function(){function a(){"undefined"!=typeof console&&null!==console&&console.warn("MutationObserver is not supported by your browser."),"undefined"!=typeof console&&null!==console&&console.warn("WOW.js cannot detect dom mutations, please call .sync() after loading new content.")}return a.notSupported=!0,a.prototype.observe=function(){},a}()),d=this.getComputedStyle||function(a,b){return this.getPropertyValue=function(b){var c;return"float"===b&&(b="styleFloat"),e.test(b)&&b.replace(e,function(a,b){return b.toUpperCase()}),(null!=(c=a.currentStyle)?c[b]:void 0)||null},this},e=/(\-([a-z]){1})/g,this.WOW=function(){function e(a){null==a&&(a={}),this.scrollCallback=f(this.scrollCallback,this),this.scrollHandler=f(this.scrollHandler,this),this.resetAnimation=f(this.resetAnimation,this),this.start=f(this.start,this),this.scrolled=!0,this.config=this.util().extend(a,this.defaults),null!=a.scrollContainer&&(this.config.scrollContainer=document.querySelector(a.scrollContainer)),this.animationNameCache=new c,this.wowEvent=this.util().createEvent(this.config.boxClass)}return e.prototype.defaults={boxClass:"wow",animateClass:"animated",offset:0,mobile:!0,live:!0,callback:null,scrollContainer:null},e.prototype.init=function(){var a;return this.element=window.document.documentElement,"interactive"===(a=document.readyState)||"complete"===a?this.start():this.util().addEvent(document,"DOMContentLoaded",this.start),this.finished=[]},e.prototype.start=function(){var b,c,d,e;if(this.stopped=!1,this.boxes=function(){var a,c,d,e;for(d=this.element.querySelectorAll("."+this.config.boxClass),e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),this.all=function(){var a,c,d,e;for(d=this.boxes,e=[],a=0,c=d.length;c>a;a++)b=d[a],e.push(b);return e}.call(this),this.boxes.length)if(this.disabled())this.resetStyle();else for(e=this.boxes,c=0,d=e.length;d>c;c++)b=e[c],this.applyStyle(b,!0);return this.disabled()||(this.util().addEvent(this.config.scrollC
vendor: 4,577 bytes, line 640
640ontainer||window,"scroll",this.scrollHandler),this.util().addEvent(window,"resize",this.scrollHandler),this.interval=setInterval(this.scrollCallback,50)),this.config.live?new a(function(a){return function(b){var c,d,e,f,g;for(g=[],c=0,d=b.length;d>c;c++)f=b[c],g.push(function(){var a,b,c,d;for(c=f.addedNodes||[],d=[],a=0,b=c.length;b>a;a++)e=c[a],d.push(this.doSync(e));return d}.call(a));return g}}(this)).observe(document.body,{childList:!0,subtree:!0}):void 0},e.prototype.stop=function(){return this.stopped=!0,this.util().removeEvent(this.config.scrollContainer||window,"scroll",this.scrollHandler),this.util().removeEvent(window,"resize",this.scrollHandler),null!=this.interval?clearInterval(this.interval):void 0},e.prototype.sync=function(b){return a.notSupported?this.doSync(this.element):void 0},e.prototype.doSync=function(a){var b,c,d,e,f;if(null==a&&(a=this.element),1===a.nodeType){for(a=a.parentNode||a,e=a.querySelectorAll("."+this.config.boxClass),f=[],c=0,d=e.length;d>c;c++)b=e[c],g.call(this.all,b)<0?(this.boxes.push(b),this.all.push(b),this.stopped||this.disabled()?this.resetStyle():this.applyStyle(b,!0),f.push(this.scrolled=!0)):f.push(void 0);return f}},e.prototype.show=function(a){return this.applyStyle(a),a.className=a.className+" "+this.config.animateClass,null!=this.config.callback&&this.config.callback(a),this.util().emitEvent(a,this.wowEvent),this.util().addEvent(a,"animationend",this.resetAnimation),this.util().addEvent(a,"oanimationend",this.resetAnimation),this.util().addEvent(a,"webkitAnimationEnd",this.resetAnimation),this.util().addEvent(a,"MSAnimationEnd",this.resetAnimation),a},e.prototype.applyStyle=function(a,b){var c,d,e;return d=a.getAttribute("data-wow-duration"),c=a.getAttribute("data-wow-delay"),e=a.getAttribute("data-wow-iteration"),this.animate(function(f){return function(){return f.customStyle(a,b,d,c,e)}}(this))},e.prototype.animate=function(){return"requestAnimationFrame"in window?function(a){return window.requestAnimationFrame(a)}:function(a){return a()}}(),e.prototype.resetStyle=function(){var a,b,c,d,e;for(d=this.boxes,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.style.visibility="visible");return e},e.prototype.resetAnimation=function(a){var b;return a.type.toLowerCase().indexOf("animationend")>=0?(b=a.target||a.srcElement,b.className=b.className.replace(this.config.animateClass,"").trim()):void 0},e.prototype.customStyle=function(a,b,c,d,e){return b&&this.cacheAnimationName(a),a.style.visibility=b?"hidden":"visible",c&&this.vendorSet(a.style,{animationDuration:c}),d&&this.vendorSet(a.style,{animationDelay:d}),e&&this.vendorSet(a.style,{animationIterationCount:e}),this.vendorSet(a.style,{animationName:b?"none":this.cachedAnimationName(a)}),a},e.prototype.vendors=["moz","webkit"],e.prototype.vendorSet=function(a,b){var c,d,e,f;d=[];for(c in b)e=b[c],a[""+c]=e,d.push(function(){var b,d,g,h;for(g=this.vendors,h=[],b=0,d=g.length;d>b;b++)f=g[b],h.push(a[""+f+c.charAt(0).toUpperCase()+c.substr(1)]=e);return h}.call(this));return d},e.prototype.vendorCSS=function(a,b){var c,e,f,g,h,i;for(h=d(a),g=h.getPropertyCSSValue(b),f=this.vendors,c=0,e=f.length;e>c;c++)i=f[c],g=g||h.getPropertyCSSValue("-"+i+"-"+b);return g},e.prototype.animationName=function(a){var b;try{b=this.vendorCSS(a,"animation-name").cssText}catch(c){b=d(a).getPropertyValue("animation-name")}return"none"===b?"":b},e.prototype.cacheAnimationName=function(a){return this.animationNameCache.set(a,this.animationName(a))},e.prototype.cachedAnimationName=function(a){return this.animationNameCache.get(a)},e.prototype.scrollHandler=function(){return this.scrolled=!0},e.prototype.scrollCallback=function(){var a;return!this.scrolled||(this.scrolled=!1,this.boxes=function(){var b,c,d,e;for(d=this.boxes,e=[],b=0,c=d.length;c>b;b++)a=d[b],a&&(this.isVisible(a)?this.show(a):e.push(a));return e}.call(this),this.boxes.length||this.config.live)?void 0:this.stop()},e.prototype.offsetTop=function(a){for(var b;void 0===a.offsetTop;)a=a.parentNode;for(b=a.offsetTop;a=a.offsetParent;)b+=a.offsetTop;return b},e.prototype.isVisible=function(a){var b,c,d,e,f;return c=a.getAttribute("data-wow-offset")||this.config.offset,f=this.config.scrollContainer&&this.config.scrollContainer.scrollTop||window.pageYOffset,e=f+Math.min(this.element.clientHeight,this.util().innerHeight())-c,d=this.offsetTop(a),b=d+a.clientHeight,e>=d&&b>=f},e.prototype.util=function(){return null!=this._util?this._util:this._util=new b},e.prototype.disabled=function(){return!this.config.mobile&&this.util().isMobile(navigator.userAgent)},e}()}).call(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.