1'use strict'; 2 3var woosq_ids = [], woosq_products = []; 4 5(function ($) { 6 $(function () { 7 $('.woosq-btn, .woosq-link').each(function () { 8 var id = $(this).attr('data-id'); 9 var pid = $(this).attr('data-pid'); 10 var product_id = $(this).attr('data-product_id'); 11 12 if (typeof pid !== typeof undefined && pid !== false) { 13 id = pid; 14 } 15 16 if (typeof product_id !== typeof undefined && product_id !== false) { 17 id = product_id; 18 } 19 20 if (-1 === $.inArray(id, woosq_ids)) { 21 woosq_ids.push(id); 22 woosq_products.push({ 23 src: woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id, 24 }); 25 } 26 }); 27 28 // quick view 29 if (woosq_vars.quick_view > 0) { 30 setTimeout(function () { 31 woosq_open(woosq_vars.quick_view); 32 }, 1000); 33 } 34 }); 35 36 $(document).on('click touch', '[href*="#woosq-"]', function (e) { 37 var $this = $(this); 38 var href = $this.attr('href'); 39 var reg = /#woosq-([0-9]+)/g; 40 var match = reg.exec(href); 41 42 if (match[1] !== undefined) { 43 var id = match[1]; 44 var effect = $this.attr('data-effect'); 45 var context = $this.attr('data-context'); 46 47 woosq_open(id, effect, context); 48 e.preventDefault(); 49 } 50 }); 51 52 $(document).on('click touch', '.woosq-btn, .woosq-link', function (e) { 53 e.preventDefault(); 54 55 var $this = $(this); 56 var id = $this.attr('data-id'); 57 var pid = $this.attr('data-pid'); 58 var product_id = $this.attr('data-product_id'); 59 var effect = $this.attr('data-effect'); 60 var context = $this.attr('data-context'); 61 62 if (typeof pid !== typeof undefined && pid !== false) { 63 id = pid; 64 } 65 66 if (typeof product_id !== typeof undefined && product_id !== false) { 67 id = product_id; 68 } 69 70 woosq_open(id, effect, context); 71 }); 72 73 $(document).on('added_to_cart', function () { 74 if (woosq_vars.auto_close === 'yes') { 75 if (woosq_vars.view === 'popup') { 76 $.magnificPopup.close(); 77 } 78 79 woosq_close(); 80 } 81 }); 82 83 $(document).on('woosq_loaded', function () { 84 var form_variation = $('#woosq-popup').find('.variations_form'); 85 86 form_variation.each(function () { 87 $(this).wc_variation_form(); 88 }); 89 90 woosq_init_content('loaded'); 91 92 // add redirect 93 if (!$('#woosq-popup .woosq-redirect').length) { 94 // Use DOM property assignment (not HTML string concatenation) to prevent DOM XSS. 95 var $redirectInput = $('<input>', { 96 'class': 'woosq-redirect', 97 'name': 'woosq-redirect', 98 'type': 'hidden' 99 }); 100 101 if ((woosq_vars.cart_redirect === 'yes') && 102 (woosq_vars.cart_url !== '')) { 103 $redirectInput.val(woosq_vars.cart_url); 104 } else { 105 $redirectInput.val(window.location.href); 106 } 107 108 $('#woosq-popup form').prepend($redirectInput); 109 } 110 }); 111 112 $(window).on('resize', function () { 113 woosq_init_content('resize'); 114 }); 115 116 $(document).on('found_variation', function (e, t) { 117 if (!$(e['target']).closest('.woosb-product').length && 118 !$(e['target']).closest('.woosg-product').length && 119 !$(e['target']).closest('.woobt-product').length && 120 !$(e['target']).closest('.woofs-product').length && 121 $(e['target']).closest('#woosq-popup').length) { 122 if (t['image_id'] !== undefined) { 123 if ($('#woosq-popup .thumbnails .thumbnail').length > 1) { 124 var $thumb = $( 125 '.thumbnail:not(.slick-cloned)[data-id="' + t['image_id'] + '"]'); 126 127 if ($thumb.length) { 128 var pos = $('#woosq-popup .thumbnails .thumbnail').index($thumb); 129 var $images = $('#woosq-popup .thumbnails .images'); 130 131 if ((pos > 0) && $images.hasClass('slick-initialized')) { 132 setTimeout(function () { 133 $images.slick('slickGoTo', pos - 1); 134 }, 100); 135 } 136 } 137 } 138 } 139 } 140 }); 141 142 $(document).on('reset_data', function (e) { 143 if ($(e['target']).closest('#woosq-popup').length) { 144 if (($('#woosq-popup .thumbnails .thumbnail').length > 1) && 145 $('#woosq-popup .thumbnails .images').hasClass('slick-initialized')) { 146 $('#woosq-popup .thumbnails .images').slick('slickGoTo', 0); 147 } 148 } 149 }); 150 151 if (woosq_vars.hashchange === 'yes') { 152 $(window).on('hashchange', function () { 153 if (location.href.indexOf('#woosq') < 0) { 154 if (woosq_vars.view === 'popup') { 155 $.magnificPopup.close(); 156 } 157 158 woosq_close(); 159 } 160 }); 161 } 162 163 $(document).on('click touch', '.woosq-overlay, .woosq-close', function () { 164 woosq_close(); 165 }); 166})(jQuery); 167 168function woosq_open(id, effect, context) { 169 jQuery('body').addClass('woosq-open'); 170 171 if (woosq_vars.view === 'sidebar') { 172 // sidebar 173 woosq_loading(); 174 175 var data = { 176 action: 'woosq_quickview', 177 product_id: id, 178 context: context, 179 nonce: woosq_vars.nonce, 180 }; 181 182 jQuery.post(woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview'), data, function (response) { 183 jQuery('.woosq-sidebar').html(response); 184 woosq_loaded(); 185 jQuery(document.body).trigger('woosq_loaded', [id]); 186 }); 187 } else { 188 // popup 189 if (-1 === jQuery.inArray(id, woosq_ids)) { 190 woosq_ids.push(id); 191 woosq_products.push({ 192 src: woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id, 193 }); 194 } 195 196 var index = woosq_get_key(woosq_products, 'src', 197 woosq_vars.wc_ajax_url.toString().replace('%%endpoint%%', 'woosq_quickview') + '&product_id=' + id); 198 var main_class = 'mfp-woosq'; 199 200 if (typeof context !== typeof undefined && context !== false) { 201 main_class = main_class + ' mfp-woosq-' + context; 202 } 203 204 if (typeof effect !== typeof undefined && effect !== false) { 205 main_class = main_class + ' ' + effect; 206 } else { 207 main_class = main_class + ' ' + woosq_vars.effect; 208 } 209 210 jQuery.magnificPopup.open({ 211 items: woosq_products, 212 type: 'ajax', 213 mainClass: main_class, 214 removalDelay: 160, 215 overflowY: 'scroll', 216 fixedContentPos: true, 217 tClose: woosq_vars.close, 218 gallery: { 219 tPrev: woosq_vars.prev, 220 tNext: woosq_vars.next, 221 enabled: woosq_vars.next_prev === 'yes', 222 }, 223 ajax: { 224 settings: { 225 type: 'GET', data: { 226 nonce: woosq_vars.nonce, 227 }, 228 }, 229 }, 230 callbacks: { 231 open: function () { 232 if (woosq_vars.hashchange === 'yes') { 233 location.href = location.href.split('#')[0] + '#woosq'; 234 } 235 }, ajaxContentAdded: function () { 236 jQuery(document.body).trigger('woosq_loaded', [id]); 237 }, close: function () { 238 if (woosq_vars.hashchange === 'yes') { 239 if (location.hash) history.go(-1); 240 } 241 }, afterClose: function () { 242 jQuery(document.body).trigger('woosq_close', [id]); 243 }, 244 }, 245 }, index); 246 } 247 248 jQuery(document.body).trigger('woosq_open', [id]); 249} 250 251function woosq_close() { 252 jQuery('body').removeClass('woosq-open'); 253 jQuery(document.body).trigger('woosq_close'); 254} 255 256function woosq_loading() { 257 jQuery('.woosq-sidebar').addClass('woosq-loading'); 258} 259 260function woosq_loaded() { 261 jQuery('.woosq-sidebar').removeClass('woosq-loading'); 262} 263 264function woosq_init_content(context) { 265 if (context === 'loaded') { 266 woosq_thumbnails_zoom(); 267 woosq_thumbnails_slick(); 268 woosq_related_slick(); 269 } 270 271 if (woosq_vars.view === 'sidebar') { 272 if (woosq_vars.scrollbar === 'yes') { 273 jQuery('.woosq-product').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'}); 274 } 275 } else { 276 // fix for popup 277 if (woosq_vars.scrollbar === 'yes') { 278 if (jQuery(window).width() < 1024) { 279 jQuery('.woosq-product .summary-content').perfectScrollbar('destroy'); 280 jQuery('.woosq-product').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'}); 281 } else { 282 jQuery('.woosq-product').perfectScrollbar('destroy'); 283 jQuery('.woosq-product .summary-content').perfectScrollbar('destroy').perfectScrollbar({theme: 'wpc'}); 284 } 285 } 286 } 287} 288 289function woosq_get_key(array, key, value) { 290 for (var i = 0; i < array.length; i++) { 291 if (array[i][key] === value) { 292 return i; 293 } 294 } 295 296 return -1; 297} 298 299function woosq_thumbnails_zoom() { 300 if (woosq_vars.thumbnails_effect === 'zoom') { 301 jQuery('#woosq-popup .thumbnails .images .thumbnail').each(function () { 302 var $this = jQuery(this); 303 var zoom_params = JSON.parse(woosq_vars.thumbnails_zoom_params); 304 305 zoom_params.url = $this.find('img').attr('data-src'); 306 307 // destroy first 308 $this.trigger('zoom.destroy'); 309 $this.zoom(zoom_params); 310 }); 311 } 312} 313 314function woosq_thumbnails_slick() { 315 if (jQuery('#woosq-popup .thumbnails .images .thumbnail').length > 1) { 316 if (jQuery('#woosq-popup .thumbnails .images').hasClass('slick-initialized')) { 317 // unslick first 318 jQuery('#woosq-popup .thumbnails .images').slick('unslick'); 319 } 320 321 jQuery('#woosq-popup .thumbnails .images').slick(JSON.parse(woosq_vars.thumbnails_slick_params)); 322 } 323} 324 325function woosq_related_slick() { 326 if (jQuery('.woosq-related-products').hasClass('slick-initialized')) { 327 // unslick first 328 jQuery('.woosq-related-products').slick('unslick'); 329 } 330 331 if (jQuery('.woosq-related-product').length > 1) { 332 jQuery('.woosq-related-products').slick(JSON.parse(woosq_vars.related_slick_params)); 333 } 334}
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.