1 2 3 4document.addEventListener('DOMContentLoaded', function () { 5 var modal = document.getElementById('custom-modal'); 6 var closeModalBtn = document.getElementById('closeModalBtn'); 7 8 if (modal && closeModalBtn) { 9 // Show the modal after 2 seconds 10 setTimeout(function () { 11 modal.style.display = 'block'; 12 }, 2000); 13 14 // Close the modal when the close button is clicked 15 closeModalBtn.addEventListener('click', function () { 16 modal.style.display = 'none'; 17 }); 18 19 // Close the modal if the user clicks outside of it 20 window.addEventListener('click', function (event) { 21 if (event.target == modal) { 22 modal.style.display = 'none'; 23 } 24 }); 25 } 26}); 27 28 29//Peoduct Quick View 30 31 32(function($) { 33 34 "use strict"; 35 36 37 38 39 40 41 42jQuery(document).ready(function($) { 43 44 function handleVariationImage() { 45 var $quickView = $('.wps_quick_view'); 46 var $variationForm = $quickView.find('.variations_form'); 47 48 // Initialize variation form 49 $variationForm.wc_variation_form(); 50 51 // Trigger variation form events 52 $variationForm.trigger('check_variations'); 53 $variationForm.trigger('reset_image'); 54 55 $variationForm.on('found_variation', function(event, variation) { 56 var $mainImage = $quickView.find('.woocommerce-product-gallery__image img'); 57 var variationImageSrc = variation.image.src; 58 var variationImageSrcset = variation.image.srcset; 59 var variationImageSizes = variation.image.sizes; 60 61 if (variationImageSrc) { 62 $mainImage.attr('src', variationImageSrc); 63 } 64 65 if (variationImageSrcset) { 66 $mainImage.attr('srcset', variationImageSrcset); 67 } 68 69 if (variationImageSizes) { 70 $mainImage.attr('sizes', variationImageSizes); 71 } 72 }); 73 } 74 75 $(".wpsection_quick_view_btn").on('click', function(event) { 76 event.preventDefault(); 77 var $quickViewBtn = $(this); 78 var data = { 79 action: 'quick_view', 80 id: $quickViewBtn.attr('href'), 81 nonce: WpsectionAjax.nonce , 82 beforeSend: function() { 83 $('.quick_view_loading').addClass('loading'); 84 } 85 }; 86 $.post(WpsectionAjax.ajaxurl, data, function(response) { 87 $.magnificPopup.open({ 88 type: 'inline', 89 preloader: true, 90 removalDelay: 160, 91 zoom: { 92 enabled: true, 93 duration: 50 94 }, 95 mainClass: 'mfp-fade', 96 items: { 97 src: response 98 }, 99 callbacks: { 100 open: function() { 101 handleVariationImage(); 102 } 103 } 104 }); 105 $('.quick_view_loading').removeClass('loading'); 106 $('body').addClass('quickview_enable'); 107 108 // Select the elements with the class "your-class" 109 var elements_r = $('.wps_quick_view .woocommerce-product-gallery'); 110 111 // Remove the inline style from each selected element 112 elements_r.removeAttr('style'); 113 var element = $('.wps_quick_view .woocommerce-product-gallery .woocommerce-product-gallery__wrapper'); 114 // Add the class "galler_box" to the selected element 115 element.addClass('owl-carousel'); 116 var owl = $('.wps_quick_view .woocommerce-product-gallery__wrapper'); 117 owl.owlCarousel({ 118 autoplay: true, 119 autoplayTimeout: 4000, 120 loop: false, 121 dots: false, 122 items: 1, 123 center: false, 124 nav: true, 125 }); 126 127 $('.wps_quick_view .mfp-close').on('click', function() { 128 $('.wps_quick_view, .mfp-wrap').css('opacity', 0); 129 }); 130 131 $('.product:not(.product-type-external) form.cart').on('submit', function (e) { 132 e.preventDefault(); 133 var form = $(this); 134 var formData = new FormData(form[0]); 135 formData.append('add-to-cart', form.find('[name=add-to-cart]').val()); 136 $.ajax({ 137 url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'ace_add_to_cart'), 138 data: formData, 139 type: 'POST', 140 processData: !1, 141 contentType: !1, 142 complete: function (response) { 143 response = response.responseJSON; 144 if (!response) { 145 return 146 } 147 if (response.error && response.product_url) { 148 window.location = response.product_url; 149 return 150 } 151 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 152 window.location = wc_add_to_cart_params.cart_url; 153 return 154 } 155 var $thisbutton = form.find('.single_add_to_cart_button'); 156 $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]); 157 $('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove(); 158 $(response.fragments.notices_html).appendTo('.cart_notice').delay(3000).fadeOut(300) 159 } 160 }); 161 }); 162 163 }); 164 }); 165}); 166 167 168 169})(window.jQuery); 170 171//Custom Search 172(function($) { 173 174 "use strict"; 175 176 177jQuery(document).ready(function ($) { 178 var searchResults = $('.wps_product_search #search-results'); 179 var searchInput = $('#search-input'); 180 181 // Function to close search results 182 function closeSearchResults() { 183 searchResults.removeClass('show'); 184 } 185 186 // Function to reset the search input and close results 187 function resetSearch() { 188 searchInput.val(''); 189 closeSearchResults(); 190 } 191 192 // Event handler for input changes 193 searchInput.on('input', function () { 194 var query = $(this).val(); 195 196 $.ajax({ 197 type: 'POST', 198 url: ajax_object.ajax_url, 199 data: { 200 action: 'custom_search', 201 query: query, 202 }, 203 success: function (response) { 204 // Assuming your search results are appended to the inner div with class "row" 205 searchResults.find('.row').html(response); 206 searchResults.addClass('show'); 207 208 // Set timeout to automatically close after 30 seconds 209 setTimeout(closeSearchResults, 30000); 210 }, 211 }); 212 }); 213 214 215 216 // Event handler for clicks outside the search box 217 $(document).on('click', function (e) { 218 if (!$(e.target).closest('.wps_product_search').length) { 219 resetSearch(); 220 } 221 }); 222 223 // Event handler for mouse leave 224 $('.wps_product_search').on('mouseleave', function () { 225 // Delay the resetSearch function by 2000 milliseconds (2 seconds) 226 setTimeout(resetSearch, 2000); 227 }); 228 229 // Event handler for clicks outside the search box 230 $(document).on('click', function (e) { 231 if (!$(e.target).closest('.wps_product_search').length) { 232 resetSearch(); 233 } 234 }); 235 236 237 238 239 240 241}); 242 243})(window.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.