1/** 2* 3* NOTICE OF LICENSE 4* 5* This product is licensed for one customer to use on one installation (test stores and multishop included). 6* Site developer has the right to modify this module to suit their needs, but can not redistribute the module in 7* whole or in part. Any other use of this module constitues a violation of the user agreement. 8* 9* DISCLAIMER 10* 11* NO WARRANTIES OF DATA SAFETY OR MODULE SECURITY 12* ARE EXPRESSED OR IMPLIED. USE THIS MODULE IN ACCORDANCE 13* WITH YOUR MERCHANT AGREEMENT, KNOWING THAT VIOLATIONS OF 14* PCI COMPLIANCY OR A DATA BREACH CAN COST THOUSANDS OF DOLLARS 15* IN FINES AND DAMAGE A STORES REPUTATION. USE AT YOUR OWN RISK. 16* 17* @author idnovate.com <[email protected]> 18* @copyright 2019 idnovate.com 19* @license See above 20*/ 21 22function getQueryString() { 23 var key = false, res = {}, itm = null; 24 // get the query string without the ? 25 var qs = location.search.substring(1); 26 // check for the key as an argument 27 if (arguments.length > 0 && arguments[0].length > 1) 28 key = arguments[0]; 29 // make a regex pattern to grab key/value 30 var pattern = /([^&=]+)=([^&]*)/g; 31 // loop the items in the query string, either 32 // find a match to the argument, or build an object 33 // with key/value pairs 34 while (itm = pattern.exec(qs)) { 35 if (key !== false && decodeURIComponent(itm[1]) === key) 36 return decodeURIComponent(itm[2]); 37 else if (key === false) 38 res[decodeURIComponent(itm[1])] = decodeURIComponent(itm[2]); 39 } 40 41 return key === false ? res : null; 42} 43 44/***** EVENTS ******/ 45$(document).ready(function() { 46 // Preview popup 47 if (getQueryString('previewPopup')) { 48 displayPopup(getQueryString('popupId')); 49 return; 50 } 51 52 getPopup(1); 53 getPopup(4); 54 55 if (typeof ajaxCart !== "undefined") { 56 ajaxCart.add = (function() { 57 var ajaxCartaddCached = ajaxCart.add; 58 return function(idProduct) { 59 ajaxCartaddCached.apply(this, arguments); 60 productAddedToTheCart(idProduct); 61 } 62 })(); 63 } else if (typeof prestashop !== "undefined") { 64 prestashop.on( 65 'updateCart', 66 function (event) { productAddedToTheCart(event.reason.idProduct); } 67 ); 68 69 prestashop.on( 70 'stUpdateCart', 71 function(event) { productAddedToTheCart(event.reason.idProduct); } 72 ); 73 } else if ($('#layer_cart').length || $('.layer_cart_overlay').length || /*$('.blockcart').length ||*/ $('.mfp-container').length) { 74 $(document).on('click', '#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay, #blockcart-modal, .mfp-container', function() { 75 productAddedToTheCart(); 76 }); 77 78 /*$('.ajax_add_to_cart_button span, .add-to-cart').on('click', function(){ 79 getPopup(2); 80 }); 81 prestashop.on( 82 'stUpdateCart', 83 function() { getPopup(2); } 84 );*/ 85 } else { 86 $(document).on('click', '.add-to-cart, .product-add-to-cart', function(){ 87 productAddedToTheCart(); 88 }); 89 } 90}); 91 92function productAddedToTheCart(idProduct) { 93 getPopup(2, idProduct); 94} 95 96_html = document.documentElement; 97_html.addEventListener('mouseout', handleMouseleave); 98 99function handleMouseleave(e) { 100 e = e ? e : window.event; 101 102 // If this is an autocomplete element. 103 if (e.target.tagName.toLowerCase() === "input" 104 || e.target.tagName.toLowerCase() === "select") { 105 return; 106 } 107 // Get the current viewport width. 108 var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 109 110 // If the current mouse X position is within 50px of the right edge 111 // of the viewport, return. 112 if (e.clientX >= (vpWidth - 50)) { 113 return; 114 } 115 116 // If the current mouse Y position is not within 50px of the top 117 // edge of the viewport, return. 118 if (e.clientY >= 50) { 119 return; 120 } 121 122 // Reliable, works on mouse exiting window and 123 // user switching active program 124 var from = e.relatedTarget || e.toElement; 125 if (!from) {
126 if ($('#apc_content_exit').length && $('#apc_content_exit').html().length) { 127 displayPopup(3); 128 } else { 129 getPopup(3); 130 } 131 } 132 133 //_html.removeEventListener('mouseleave', handleMouseleave); 134} 135 136function getPopup(event, idProduct) { 137 var availablePopups = []; 138 $('.apc_modal').each (function () { availablePopups.push($(this).data('popupId')); }); 139 availablePopups = availablePopups.join(','); 140 141 if (!availablePopups) { return; } 142 143 if (!idProduct) { 144 idProduct = $('input[name="id_product"]').val(); 145 } 146 147 $.ajax({ 148 type: 'POST', 149 headers: { "cache-control": "no-cache" }, 150 url: apc_link, 151 async: true, 152 cache: false, 153 dataType : "json", 154 data: 'getPopup=1&time='+(new Date()).getTime()+apc_data+'&event='+event+'&idProduct='+idProduct+'&availablePopups='+availablePopups, 155 success: function(jsonData) 156 { 157 if (!jsonData.hasError && typeof jsonData.popups != "undefined") { 158 $.each(jsonData.popups, function(i, item) { 159 var popup = JSON.parse(item); 160 if (popup.selector) { 161 var popupSelector = eval(popup.selector); 162 if (popupSelector.length) { 163 popupSelector.click(function () { 164 displayPopup(popup.id); 165 }); 166 } 167 } else { 168 displayPopup(popup.id); 169 } 170 }); 171 } 172 }, 173 error: function(errorThrown) 174 { 175 console.log(errorThrown); 176 } 177 }); 178} 179 180function displayPopup(popupId) { 181 // Check if modal function is enabled 182 // (May fail if overrided by another JQUERY plugin!!) 183 if (!$.prototype.fancybox) { 184 console.log('Fancybox library does not exist!'); 185 return; 186 } 187 188 if (typeof $.fancyboxPopup != "undefined") { 189 var $apcFancybox = $.fancyboxPopup; 190 } else { 191 $apcFancybox = $.fancybox; 192 } 193 194 if ($apcFancybox.current) { 195 return; 196 } 197 198 content = $('#apc_modal_'+popupId); 199 200 var popupProperties = content.data(); 201 202 if (typeof popupProperties === "undefined") { 203 return; 204 } 205 206 if (typeof preview === "undefined") { 207 preview = false; 208 } 209 210 if (typeof(popupProperties.height) == "undefined" || typeof(popupProperties.width) == "undefined") { 211 var maxWidth = 'auto'; 212 var maxHeight = 'auto'; 213 } else if (popupProperties.height === '100%' && popupProperties.width === '100%') { 214 maxWidth = '100%'; 215 maxHeight = '100%'; 216 } else { 217 maxWidth = '90%'; 218 maxHeight = '90%'; 219 } 220 221 if (!popupProperties.height && !popupProperties.width) { 222 var autoSize = true; 223 } else { 224 autoSize = false; 225 } 226 227 if (!popupProperties.height) { 228 popupProperties.height = 'auto'; 229 } 230 231 if (!popupProperties.width) { 232 popupProperties.width = 'auto'; 233 } 234 235 if (!popupProperties.openEffect) { 236 popupProperties.openEffect = 'zoom'; 237 } 238 239 if (popupProperties.secsDisplay) { 240 secsDisplay = popupProperties.secsDisplay; 241 } else if (popupProperties.secsDisplayCart) { 242 secsDisplay = popupProperties.secsDisplayCart; 243 } else { 244 secsDisplay = 0; 245 } 246 247 setTimeout(function() { 248 $apcFancybox.open([ 249 { 250 type : 'inline', 251 content : content, 252 autoSize : autoSize, 253 width : popupProperties.width, 254 height : popupProperties.height, 255 padding : popupProperties.padding, 256 autoCenter : true, 257 aspectRatio : false, 258 wrapCSS : 'apc-popup apc-popup-'+popupProperties.popupId+' '+popupProperties.css, 259 margin : 0, 260 maxWidth : maxWidth, 261 maxHeight : maxHeight, 262 openMethod : popupProperties.openEffect+'In', 263 closeMethod : popupProperties.openEffect+'Out', 264 beforeShow : function () { 265 if (!preview) { 266 $.ajax({ 267 type: 'POST', 268 headers: {"cache-control": "no-cache"}, 269 url: apc_link, 270 async: true, 271 cache: false, 272 dataType: "json", 273 data: 'markAsSeen=1&popupId=' + popupProperties.popupId + '&time=' + (new Date()).getTime() + '&token='
273+ apc_token 274 }); 275 } 276 277 if (popupProperties.blurBackground) { 278 $("main, header, body > section, footer, #page").addClass("apc-effect-blur"); 279 } 280 281 // Bug with Uniform 282 if (typeof bindUniform == 'function') { 283 $("select.form-control,input[type='checkbox']:not(.comparator), input[type='radio'],input#id_carrier2, input[type='file']").not(".not_unifrom, .not_uniform").uniform(); 284 } 285 }, 286 afterShow : function () { 287 if (popupProperties.opacity == 0 && !popupProperties.locked) { 288 $('.fancybox-overlay').attr('style', function(i,s) { if (s == undefined) { s = ''; } return s + 'display: none !important;' }); 289 } 290 291 // Bug with vertical scroll in images 292 if ($('.apc-popup-'+popupProperties.popupId+' .modal-img').scrollTop() == 0) { 293 $('.apc-popup-'+popupProperties.popupId+' .fancybox-inner').attr('style', 'overflow: hidden !important;'); 294 } 295 }, 296 afterClose : function () { 297 if (popupProperties.blurBackground) { 298 $("main, header, body > section, footer, #page").removeClass("apc-effect-blur"); 299 } 300 301 } 302 }], 303 { 304 helpers: { 305 overlay : { 306 css: { 307 'background' : 'rgba(0, 0, 0, '+popupProperties.opacity+')' 308 }, 309 locked: popupProperties.locked, 310 closeClick: popupProperties.closeBackground 311 } 312 } 313 }); 314 }, secsDisplay); 315 316 if (typeof(popupProperties.secsClose) != "undefined" && popupProperties.secsClose > 0) { 317 setTimeout( function() {$apcFancybox.close(); }, popupProperties.secsClose); // 3000 = 3 secs 318 } 319} 320 321function dontDisplayAgain(popupId) { 322 if (typeof $.fancyboxPopup != "undefined") { 323 var $apcFancybox = $.fancyboxPopup; 324 } else { 325 $apcFancybox = $.fancybox; 326 } 327 328 $.ajax({ 329 type: 'POST', 330 headers: {"cache-control": "no-cache"}, 331 url: apc_link, 332 async: true, 333 cache: false, 334 dataType: "json", 335 data: 'dontDisplayAgain=1&popupId=' + popupId + '&time='+(new Date()).getTime()+'&token='+apc_token 336 }); 337 338 $apcFancybox.close(); 339}
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.