1// JavaScript Document 2(function ($) { 3 4 $(window).on('load', function () { 5 6 var e = document.getElementById("filt-single"), 7 d = document.getElementById("filt-monthly"), 8 t = document.getElementById("switcher"); 9 10 if (t) { 11 12 t.addEventListener("click", function () { 13 d.classList.toggle("toggler--is-active"); 14 e.classList.toggle("toggler--is-active"); 15 }) 16 } 17 18 }); 19 20 $(document).ready(function () { 21 22 // Attach a delegated event handler 23 $(document).on("click", "#donation-recognition", {}, function () { 24 $("#donation-tribute-name").toggle(); 25 $("#tributeType").toggle(); 26 $("#donation-tribute-contact").toggle(); 27 28 }); 29 30 var spektrixMinHeight = 300; 31 32 const genericFundId = $("#spk-webc").attr('data-generic-fund'); 33 $("#spk-webc").attr('fund-id', genericFundId); 34 35 // User clicks without toggling 36 $(".donation-class").click(function (event) { 37 38 $(".spk-donate-content").each(function () { 39 $(this).removeClass("spk-tab-active"); 40 }); 41 42 $(".donation-class").each(function () { 43 $(this).removeClass("active"); 44 }); 45 46 var id = this.getAttribute("id"); 47 48 49 $("#donate" + id.replace("donation-class-", "")).addClass("spk-tab-active"); 50 $(this).addClass("active"); 51 52 var fundId = this.getAttribute("data-fund-id"); 53 54 var membershipId = this.getAttribute("data-membership-id"); 55 56 let paymentType = $("#spk-webc").attr("data-payment-type"); 57 58 if (paymentType) { 59 if (paymentType === "donation") { 60 $("#spk-webc").attr('fund-id', fundId); 61 } 62 else { 63 $("#spk-webc").attr('membership-id', membershipId); 64 } 65 } 66 67 var donation = document.getElementById('spektrix-donation-amount'); 68 if (event.preventDefault, null != this.getAttribute("data-donate-amount")) { 69 var amount = this.getAttribute("data-donate-amount"); 70 donation.value = amount; 71 $("#spektrix-donation-amount").attr("value", amount); 72 $("#spektrix-donation-amount").attr("data-custom-donation-input", amount); 73 $("#spektrix-donation span").attr("data-display-donation-amount", amount); 74 $("#spektrix-donation span").text(amount); 75 } 76 77 }); 78 79 // User toggles
80 $(".toggle").click(function () { 81 82 83 var paymentType = $("#spk-webc").attr("data-payment-type"); 84 85 if (paymentType) { 86 87 if (paymentType === "donation") {// About to enter into membership mode 88 89 $(".single-arrow").removeClass("show"); 90 $(".monthly-arrow").addClass("show"); 91 92 $("#autorenew").attr("checked", true) 93 94 // Change mode to membership from donation 95 $("#spk-webc").attr("data-payment-type", "membership"); 96 $("#spk-webc").addClass("membership-enabled"); 97 $("#spk-webc").removeClass("donation-enabled"); 98 99 // Hide all the donation UI elements 100 $(".upper-range, .range-divider, .donation-amount>span, #spektrix-donation-amount, .donation, .donation-funds, .hideme").hide(); 101 102 // Reveal all the membership UI elements 103 $(".monthly-payment, .monthly, .amount").show(); 104 105 // Update the button text with the current active payment level amount 106 let monthlyAmount = $(".donation-class.active").attr("data-monthly-amount"); 107 $(".monthly").text("Donate Now: $" + monthlyAmount + " Monthly"); 108 109 110 111 // Update the webcomponent attritbutes to reflect change to membership mode 112 // switch over to membership webcomponent 113 $("spektrix-donate").replaceWith(function () { 114 return this.outerHTML.replace("<spektrix-donate", "<spektrix-memberships").replace("</spektrix-donate", "</spektrix-memberships") 115 }); 116 117 $('#spektrix-donation span').text(monthlyAmount); 118 119 // Remove any attributes that are only needed for donations 120 $("#spk-webc").removeAttr("fund-id"); 121 122 // Get the memberhip id from the current active payment level selected 123 var initalMembership = $(".donation-class.active").attr("data-membership-id"); 124 // Add in membership required attributes 125 $("#spk-webc").attr('membership-id', initalMembership); 126 127 // Switch out donation button to membership button 128 $('.donation-button').removeAttr("data-submit-donation"); 129 $('.donation-button').attr("data-submit-membership", ""); 130 131 132 var amount = $(".donation-class.active").attr("data-monthly-amount"); 133 //var amount = donation.getAttribute("data-donate-amount"); 134 var userInput = parseFloat(amount * 12); 135 var threshold = parseFloat($(".modal").attr("data-threshold")); 136 137 if (userInput >= threshold) { 138 var modal = document.querySelector(".modal"); 139 modal.classList.toggle("show-modal"); 140 141 } 142 143 $(".donation-class").click(function (event) { 144 145 146 // New payment level is click so we update the membership id 147 var membershipId = this.getAttribute("data-membership-id"); 148 $("#spk-webc").attr('membership-id', membershipId); 149 150 // Update the amount selected to pass over to Spektrix 151 var donation = document.getElementById('spektrix-donation-amount'); 152 if (event.preventDefault, null != this.getAttribute("data-donate-amount")) { 153 var amount = this.getAttribute("data-donate-amount"); 154 donation.value = amount 155 } 156 157 // Reset the active elements in the UI 158 $(".spk-donate-content").each(function () { 159 $(this).removeClass("spk-tab-active"); 160 }); 161 162 $(".donation-class").each(function () { 163 $(this).removeClass("active"); 164 }); 165 166 // Update the UI to display the related content for the newly selected payment level 167 var id = this.getAttribute("id"); 168 $("#donate" + id.replace("donation-class-", "")).addClass("spk-tab-active"); 169 $(this).addClass("active"); 170 171 // Update the button text to reflect a change in monthly payment level 172 var monthlyAmount = $(".donation-class.active").attr("data-monthly-amount"); 173 174 $(".monthly").text("Donate Now: $" + monthlyAmount + " Monthly"); 175 176 var donation = document.getElementById('spektrix-donation-amount'); 177 if (event.preventDefault, null != this.getAttribute("data-donate-amount")) { 178 var amount = this.getAttribute("data-donate-amount"); 179 donation.value = amount; 180 $("#spektrix-donation-amount").attr("value", amount); 181 $("#spektrix-donation-amount").attr("data-custom-donation-input", amount); 182 $("#spektrix-donation span").attr("data-display-donation-amount", amount); 183 $("#spektrix-donation span").text(amount); 184 185 var userInput = parseFloat(amount * 12); 186 var threshold = parseFloat($(".modal").attr("data-threshold")); 187 188 if (userInput >= threshold) { 189 var modal = document.querySelector(".modal"); 190 modal.classList.toggle("show-modal"); 191 192 } 193 194 195 196 } 197 198 }); 199 200 $(".donation-button").addClass("center-btn"); 201 202 } 203 else { 204 205 $(".single-arrow").addClass("show"); 206 $(".monthly-arrow").removeClass("show"); 207 208 // Change mode to donation from membership 209 $("#spk-webc").attr("data-payment-type", "donation"); 210 $("#spk-webc").addClass("donation-enabled"); 211 $("#spk-webc").removeClass("membership-enabled"); 212 213 // Hide all the monthly donation UI elements 214 $(".monthly-payment, .monthly, .amount").hide(); 215 // Show all the donation UI elements 216 $(".upper-range, .range-divider, .donation-amount>span, #spektrix-donation-amount, .donation, .donation-funds, .hideme").show(); 217 218 // Switch over to the donation web component 219 $("spektrix-memberships").replaceWith(function () { 220 return this.outerHTML.replace("<spektrix-memberships", "<spektrix-donate").replace("</spektrix-memberships", "</spektrix-donate") 221 }); 222 223 $("#spk-webc").removeAttr('membership-id'); 224 225 // Get the memberhip id from the current active payment level selected 226 var fund = $(".donation-class.active").attr("data-fund-id"); 227 // Add in membership required attributes 228 $("#spk-webc").attr('fund-id', fund); 229 230 // Switch out donation button to membership button 231 232 $('.donation-button').removeAttr("data-submit-membership"); 233 $('.donation-button').attr("data-submit-donation", ""); 234 235 $(".donation-class").click(function (event) { 236 237 // Reset the active elements in the UI 238 $(".spk-donate-content").each(function () { 239 $(this).removeClass("spk-tab-active"); 240 }); 241 242 $(".donation-class").each(function () { 243 $(this).removeClass("active"); 244 }); 245 246 // Update the UI to display the related content for the newly selected payment level 247 var id = this.getAttribute("id"); 248 $("#donate" + id.replace("donation-class-", "")).addClass("spk-tab-active"); 249 $(this).addClass("active"); 250 251 var donation = document.getElementById('spektrix-donation-amount'); 252 if (event.preventDefault, null != this.getAttribute("data-donate-amount")) { 253 var amount = this.getAttribute("data-donate-amount"); 254 donation.value = amount; 255 $("#spektrix-donation-amount").attr("value", amount); 256 $("#spektrix-donation-amount").attr("data-custom-donation-input", amount); 257 $("#spektrix-donation span").attr("data-display-donation-amount", amount); 258 $("#spektrix-donation span").text(amount); 259 } 260 261 }); 262 263 $(".donation-button").removeClass("center-btn"); 264 265 // if #donation-tribute-contact losses focus and has a value then change update #spk-webc forward-to attribute 266 // Save value to cookie and forward user to tribute.php 267 268 } 269 } 270 }); 271 272 $("#donation-tribute-contact").focusout(function () { 273 274 if ($("#donation-tribute-contact").length > 0 && $("#donation-tribute-contact").val() != '') { 275 var tribute = $("#donation-tribute-contact").val(); 276 createCookie("tribute", tribute, 1); 277 278 279 var cookieValue = readCookie("tribute"); 280 if (cookieValue === tribute) { 281 $("#spk-webc").attr("forward-to", "tribute") 282 } 283 284 } 285 }); 286 });
287})(jQuery); 288 289 290function createCookie(name, value, days) { 291 var expires; 292 293 if (days) { 294 var date = new Date(); 295 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 296 expires = "; expires=" + date.toGMTString(); 297 } else { 298 expires = ""; 299 } 300 document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/"; 301} 302 303function readCookie(name) { 304 var nameEQ = encodeURIComponent(name) + "="; 305 var ca = document.cookie.split(';'); 306 for (var i = 0; i < ca.length; i++) { 307 var c = ca[i]; 308 while (c.charAt(0) === ' ') 309 c = c.substring(1, c.length); 310 if (c.indexOf(nameEQ) === 0) 311 return decodeURIComponent(c.substring(nameEQ.length, c.length)); 312 } 313 return null; 314} 315 316function eraseCookie(name) { 317 createCookie(name, "", -1); 318}
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.