1/* 2 * To change this template, choose Tools | Templates 3 * and open the template in the editor. 4 */ 5var TIMEOUT_CHECK_FORM_SUBMIT = 3000; 6var NEWSLETTER_POPUP_DELAY = 15000; 7var SHOW_OPTIN_COOKIE_NAME = 'showoptin'; 8var SHOW_OPTIN_EXPIRE_DAYS = 30; 9var OPTIN_NEWSLETTER_EMAIL_COOKIE_NAME = 'newsletteremail'; 10 11var ACTIVE_NEWSLETTERS = [ 12 { 13 popupID: 1, 14 file: "/newsletters/newsletter-popup-A.html" 15 }, 16 { 17 popupID: 2, 18 file: "/newsletters/newsletter-popup-B.html" 19 } 20]; 21 22var activeNewsletterIndex = -1; 23var wasUserInitiated = false; 24 25function chooseNextNewsletterPopup() 26{ 27 var index = -1; 28 index = (Math.floor(Math.random() * 10) + 1) > 5 ? 1 : 0; 29 return index; 30} 31 32function submitSignup() 33{ 34 // Set a timeout to check for whether the form was successfully submitted 35 setTimeout(function() { 36 37 // Check for success message to indicate that it was submitted properly 38 if ( $('#newsletter-popup #success_message').css('display') != 'none' ) { 39 var emailAddress = $('#newsletter-email-address').val(); 40 Cookies.set(OPTIN_NEWSLETTER_EMAIL_COOKIE_NAME, emailAddress); 41 logNewsletterPopup(ACTIVE_NEWSLETTERS[activeNewsletterIndex], true, wasUserInitiated, emailAddress); 42 } 43 }, TIMEOUT_CHECK_FORM_SUBMIT); 44 45 return true; 46} 47 48function logNewsletterPopup(popup, conversion, userInitiated, emailAddress) 49{ 50 $.ajax("/newsletters/newsletter-handler.php?popupid=" + popup.popupID + "&activePage=" + window.location.href + "&conversion=" + conversion + "&userInitiated=" + userInitiated + "&userEmail=" + emailAddress); 51} 52 53function showNewsletterPopup(userInitiated) 54{ 55 activeNewsletterIndex = chooseNextNewsletterPopup(); 56 wasUserInitiated = userInitiated; 57 58 // Load the newsletter html into the popup-container. 59 $('#popup-container').load(ACTIVE_NEWSLETTERS[activeNewsletterIndex].file, function() { 60 61 // Make the container visible and display bootstrap based modal dialog 62 $('#popup-container').css('display', 'block'); 63 $('#newsletter-popup').modal(); 64 65 // Set cookie to indicate we have shown the popup 66 Cookies.set(SHOW_OPTIN_COOKIE_NAME, true, { expires: SHOW_OPTIN_EXPIRE_DAYS }); 67 68 logNewsletterPopup(ACTIVE_NEWSLETTERS[activeNewsletterIndex], false, userInitiated, ""); 69 }); 70 71} 72 73function showVirtualFamilyMathNightPopup() 74{ 75 // Load the newsletter html into the popup-container. 76 $('#popup-container').load("/virtualfmn-popup.html", function() { 77 78 // Make the container visible and display bootstrap based modal dialog 79 $('#popup-container').css('display', 'block'); 80 $('#virtualfmn-popup').modal(); 81 82 }); 83 84} 85 86function showDownloadPopup() 87{ 88 // First 89 $('#newsletter-popup').modal(); 90} 91 92function isOnPopupPage() 93{ 94 95} 96 97$(document).ready(function() { 98 99 var $grid = $('.masonry-grid'); 100 101 if ( $grid.length > 0 ) { 102 // Initialize masonry 103 $grid.masonry({ 104 itemSelector: '.masonry-grid-item', 105 percentPosition: true 106 }); 107 108 // Reflow layout after images load 109 imagesLoaded($grid[0], function() { 110 $grid.masonry('layout'); 111 }); 112 } 113 114 // Handle any product-image-viewers on the current page 115 var digImageViewer = $('.product-image-viewer'); 116 if ( digImageViewer ) { 117 118 var images = $('.product-thumb-container > img'); 119 images.click(function() { 120 121 var imageViewer = $('#product-image'); 122 123 // Select the image that was clicked 124 var selImage = $(this); 125 images.removeClass('selected'); 126 selImage.addClass('selected'); 127 128 // Fade out the current image 129 imageViewer.fadeTo(100, 0, function() { 130 131 var imageDesc = digImageViewer.find('#product-image-desc'); 132 imageDesc.css('opacity', 0); 133 134 // Select either the video viewer or img viewer and change its src based on selected content 135 var videoURL = selImage.data('video'); 136 if ( videoURL != '' ) { 137 imageViewer.parent().attr('href', videoURL); 138 imageViewer.parent().removeClass('pe-none'); 139 } 140 else { 141 imageViewer.parent().addClass('pe-none'); 142 } 143 144 imageViewer.attr('src', selImage.data('image')); 145 146 // Fade in the new image and description 147 imageViewer.fadeTo(600, 1); 148 149 if ( imageDesc ) { 150 var desc = selImage.data('desc'); 151 imageDesc.text(desc); 152 imageDesc.fadeIn(); 153 imageDesc.fadeTo(600, 1); 154 } 155 156 }); 157 158 }); 159 160 } 161 162 // See if we should display the newsletter sign-up popup. Basically, if they have not previously 163 // completed it and we either have never shown it or have not shown it in a while, then we want to 164 // display it to them. 165 if ( window.location.href.includes("resources") && !Cookies.get(SHOW_OPTIN_COOKIE_NAME) && !Cookies.get(OPTIN_NEWSLETTER_EMAIL_COOKIE_NAME) ) { 166 167 setTimeout(function() { 168 showNewsletterPopup(false); 169 170 }, NEWSLETTER_POPUP_DELAY); 171 } 172 173 var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]')) 174 var popoverList = popoverTriggerList.map(function (popoverTriggerEl) { 175 return new bootstrap.Popover(popoverTriggerEl) 176 }); 177 178}); 179
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.