1 2 3document.addEventListener("DOMContentLoaded", function () { 4 const elements = { 5 emailVolume: document.getElementById("email-volume"), 6 emailVolumeIncrementor: document.getElementById("email-volume-incrementor"), 7 emailVolumeDecrementor: document.getElementById("email-volume-decrementor"), 8 planPrice: document.getElementById("plan-price"), 9 }; 10 11 // Kill select2. 12 jQuery(".can_select").select2("destroy"); 13 14 // Initialize the feature matrix. 15 featureMatrix(); 16 17 const initVolumeIncrementors = () => { 18 elements.emailVolumeIncrementor.addEventListener("click", () => incrementVolume(elements.emailVolume, 1000)); 19 elements.emailVolumeDecrementor.addEventListener("click", () => incrementVolume(elements.emailVolume, -1000)); 20 21 function incrementVolume(element, step) { 22 let newValue = parseInt(element.value) + step; 23 if (newValue <= 1000) { 24 newValue = 1000; 25 } 26 element.value = newValue; 27 element.dispatchEvent(new Event("change")); 28 } 29 } 30 31 initVolumeIncrementors(); 32 33 function setRecommendedPlan() { 34 elements.planPrice.innerHTML = calculateBoostPrice(parseInt(elements.emailVolume.value)); 35 } 36 37 // @todo: AM-28: @jason - sync the email volume to the Action Network form. 38 function syncEmbedEmailVolume() { 39 const emailVolumeSimple = parseInt(elements.emailVolume.value) / 1000; 40 let anFormEmailVolume; 41 42 if (emailVolumeSimple < 200000) { 43 anFormEmailVolume = Math.ceil(emailVolumeSimple / 10) * 10; 44 } else { 45 anFormEmailVolume = Math.ceil(emailVolumeSimple / 50) * 50; 46 } 47 48 if (anFormEmailVolume > 1000) { 49 anFormEmailVolume = 1001; 50 } 51 52 try { 53 jq_can( 54 ".get-a-quote-popup select#Email-Volume-Drop-Down" 55 ) 56 .select2("val", anFormEmailVolume.toString()) 57 .trigger("change"); 58 } catch (err) { 59 console.log(err); 60 } 61 } 62 63 elements.emailVolume.addEventListener("change", setRecommendedPlan); 64 65 // Sync the Action Network forms within the "Get a Quote" popups when volume changes. 66 document.addEventListener("can_embed_loaded", function (event) { 67 syncEmbedEmailVolume(event); 68 69 $('input[name="Existing partnership?"]').change(function () { 70 if ($('input[name="Existing partnership?"]:checked').val() == "No") { 71 $(".popup__inner").hide(); 72 $(".js-no_partnership").fadeIn(); 73 } 74 }); 75 76 elements.emailVolume.addEventListener("change", () => syncEmbedEmailVolume(event)); 77 }); 78 79 document.addEventListener("can_embed_submitted", function (event) { 80 jQuery(event.target) 81 .find(".fancybox-content") 82 .find(".popup__inner___top") 83 .hide(); 84 }); 85});
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.