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