1(function ($) { 2 3 $(function () { 4 5 const $pricingForm = $('#js-pricing-packages'); 6 7 if ( $pricingForm.length > 0 ) { 8 9 // Open modal and show selected slide 10 $('.js-open-features-modal').click(function (e) { 11 e.preventDefault(); 12 13 var modal = $(this).data('modal'); 14 var feature = $(this).data('feature'); 15 var $features = $('#feature-modal-' + modal).find('.js-feature-slider'); 16 17 MicroModal.show('feature-modal-' + modal, { 18 onShow: function () { 19 20 $features.slick({ 21 arrows: true, 22 dots: true, 23 adaptiveHeight: false, 24 }); 25 26 $features.slick('slickGoTo', feature); 27 }, 28 onClose: function () { 29 $features.slick('unslick'); 30 } 31 }); 32 }); 33 34 const $pricingCheckboxes = $pricingForm.find('.js-package-checkbox'); 35 const $pricingSummary = $('#js-pricing-summary'); 36 const $pricingBtn = $('#js-pricing-contact-button'); 37 const $pricingPrice = $('#js-packages-total-price'); 38 39 $pricingForm[0].reset(); 40 41 const queryString = window.location.search; 42 const urlParams = new URLSearchParams(queryString); 43 const selectedPackages = urlParams.getAll('package'); 44 45 // Select packages that are selected in url parameters 46 for (var i = 0; i < selectedPackages.length; i++) { 47 $('#js-package-checkbox-' + selectedPackages[i]).prop('checked', true); 48 $('#js-pspa__package-' + selectedPackages[i]).addClass('selected'); 49 } 50 updatePrice(); 51 52 // Update selected packages list 53 $pricingCheckboxes.on('change', function () { 54 var pack = this.value; 55 var checked = this.checked; 56 57 if (checked) { 58 $('#js-pspa__package-' + pack).addClass('selected'); 59 } else { 60 $('#js-pspa__package-' + pack).removeClass('selected'); 61 } 62 63 updatePrice(); 64 updateUrlParameters(); 65 }); 66 67 // Remove package from selected packages list 68 $pricingSummary.find('.js-package-remove').on('click', function () { 69 var pack = $(this).data('package'); 70 $('#js-pspa__package-' + pack).removeClass('selected'); 71 $('#js-package-checkbox-' + pack).prop('checked', false); 72 73 updatePrice(); 74 updateUrlParameters(); 75 }); 76 77 // Redirect user to button url and include selected packages information as parameter fe. "p1234" 78 $pricingBtn.on('click', function () { 79 var packages = 'p'; 80 $pricingForm.find('.js-package-checkbox:checked').each(function () { 81 packages += this.value; 82 }); 83 84 var url = $(this).data('url'); 85 url += packages; 86 87 window.location.href = url; 88 }); 89 90 /** 91 * Update price field 92 */ 93 function updatePrice() { 94 var totalPrice = 0; 95 $pricingForm.find('.js-package-checkbox:checked').each(function () { 96 var price = Number($(this).data('price')); 97 if (!isNaN(price)) { 98 totalPrice += price; 99 } 100 }); 101 102 $pricingPrice.text(totalPrice); 103 } 104 105 /** 106 * Add form selected values to url 107 */ 108 function updateUrlParameters() { 109 history.pushState(null, '', '?' + $pricingForm.serialize()); 110 } 111 } 112 }); 113})(jQuery);
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.