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 constitutes 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 2020 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/* 46 * 1 = On load 47 * 2 = When product added to the cart 48 * 3 = Exit popup 49 * 4 = On element click 50*/ 51 52$(document).ready(function() { 53 // Preview popup 54 if (getQueryString('previewPopup')) { 55 displayPopup(getQueryString('popupId')); 56 return; 57 } 58 59 updateVisits(); 60 61 // 1 = On load 62 getPopup(1); 63 64 // 4 = On element click 65 getPopup(4); 66 67 68 // 2 = When product added to the cart 69 if (typeof ajaxCart !== "undefined") { 70 ajaxCart.add = (function() { 71 var ajaxCartaddCached = ajaxCart.add; 72 return function(idProduct) { 73 ajaxCartaddCached.apply(this, arguments); 74 setTimeout(function() { 75 productAddedToTheCart(idProduct); 76 }, 100) 77 } 78 })(); 79 } else if (typeof prestashop !== "undefined") { 80 prestashop.on( 81 'updateCart', 82 function (event) { 83 if (event.reason.linkAction == "add-to-cart") { 84 productAddedToTheCart(event.reason.idProduct); 85 } 86 } 87 ); 88 89 prestashop.on( 90 'stUpdateCart', 91 function (event) { 92 if (event.reason.linkAction == "add-to-cart") { 93 productAddedToTheCart(event.reason.idProduct); 94 } 95 } 96 ); 97 98 //phbuscadorllantas 99 $('body').on('click', '.add1', function() { 100 idProduct = $(this).parents('.product-actions').find('input[name="id_product"]').val(); 101 productAddedToTheCart(idProduct); 102 }); 103 104 } else if ($('#layer_cart').length || $('.layer_cart_overlay').length || /*$('.blockcart').length ||*/ $('.mfp-container').length) { 105 $(document).on('click', '#layer_cart .cross, #layer_cart .continue, .layer_cart_overlay, #blockcart-modal, .mfp-container', function() { 106 productAddedToTheCart(); 107 }); 108 109 /*$('.ajax_add_to_cart_button span, .add-to-cart').on('click', function(){ 110 getPopup(2); 111 }); 112 prestashop.on( 113 'stUpdateCart', 114 function() { getPopup(2); } 115 );*/ 116 } else { 117 $(document).on('click', '.add-to-cart, .product-add-to-cart', function(){ 118 productAddedToTheCart(); 119 }); 120 } 121 122 // 3 = Exit popup 123 _html = document.documentElement; 124 _html.addEventListener('mouseout', handleMouseleave); 125}); 126 127function productAddedToTheCart(idProduct) { 128 getPopup(2, idProduct); 129} 130 131function handleMouseleave(e) { 132 e = e ? e : window.event; 133 134 // If this is an autocomplete element. 135 if (e.target.tagName.toLowerCase() === "input" 136 || e.target.tagName.toLowerCase() === "select") { 137 return; 138 } 139 // Get the current viewport width. 140 var vpWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 141 142 // If the current mouse X position is within 50px of the right edge 143 // of the viewport, return. 144 if (e.clientX >= (vpWidth - 50)) { 145 return; 146 } 147 148 // If the current mouse Y position is not within 50px of the top 149 // edge of the viewport, return. 150 if (e.clientY >= 50) { 151 return; 152 } 153 154 // Reliable, works on mouse exiting window and 155 // user switching active program 156 var from = e.relatedTarget || e.toElement; 157 if (!from) {
158 if ($('#apc_content_exit').length && $('#apc_content_exit').html().length) { 159 displayPopup(3); 160 } else { 161 getPopup(3); 162 } 163 } 164 165 //_html.removeEventListener('mouseleave', handleMouseleave); 166} 167 168function updateVisits() { 169 $.ajax({ 170 type: 'POST', 171 headers: { "cache-control": "no-cache" }, 172 url: apc_link, 173 async: true, 174 cache: false, 175 dataType : "json", 176 data: { 177 token: apc_token, 178 responsiveWidth: window.innerWidth, 179 url: encodeURIComponent(window.location.href), 180 referrer: encodeURIComponent(document.referrer), 181 updateVisits: 1, 182 time: (new Date()).getTime(), 183 fromController: apc_controller, 184 id_product: apc_product, 185 id_category: apc_category, 186 id_manufacturer: apc_manufacturer, 187 id_supplier: apc_supplier, 188 id_cms: apc_cms, 189 }, 190 error: function(errorThrown) 191 { 192 console.log(errorThrown); 193 } 194 }); 195} 196 197function getPopup(event, idProduct) { 198 var availablePopups = []; 199 $('.apc_modal').each (function () { availablePopups.push($(this).data('popupId')); }); 200 availablePopups = availablePopups.join(','); 201 202 if (!availablePopups) { return; } 203 204 if (!idProduct) { 205 idProduct = apc_product; 206 } 207 208 $.ajax({ 209 type: 'POST', 210 headers: { "cache-control": "no-cache" }, 211 url: apc_link, 212 async: true, 213 cache: false, 214 dataType : "json", 215 data: { 216 token: apc_token, 217 responsiveWidth: window.innerWidth, 218 url: encodeURIComponent(window.location.href), 219 referrer: encodeURIComponent(document.referrer), 220 getPopup: 1, 221 event: event, 222 time: (new Date()).getTime(), 223 fromController: apc_controller, 224 id_product: idProduct, 225 id_category: apc_category, 226 id_manufacturer: apc_manufacturer, 227 id_supplier: apc_supplier, 228 availablePopups: availablePopups 229 }, 230 success: function(jsonData) 231 { 232 if (!jsonData.hasError && typeof jsonData.popups != "undefined") { 233 $.each(jsonData.popups, function(i, item) { 234 var popup = JSON.parse(item); 235 if (event == 4 && popup.selector) { 236 var popupSelector = eval(popup.selector); 237 if (popupSelector.length) { 238 //iOS bug 239 popupSelector.css('cursor', 'pointer'); 240 popupSelector.on('click touch', function () { 241 displayPopup(popup.id); 242 }); 243 } 244 } else { 245 displayPopup(popup.id); 246 } 247 }); 248 } 249 }, 250 error: function(errorThrown) 251 { 252 console.log(errorThrown); 253 } 254 }); 255} 256 257function displayPopup(popupId) { 258 // Check if modal function is enabled 259 // (May fail if overrided by another JQUERY plugin!!) 260 if (!$.prototype.fancybox) { 261 console.log('Fancybox library does not exist!'); 262 return; 263 } 264 265 var $apcFancybox = ''; 266 267 if (typeof $.fancyboxPopup != "undefined") { 268 $apcFancybox = $.fancyboxPopup; 269 } else { 270 $apcFancybox = $.fancybox; 271 } 272 273 if ($apcFancybox.current) { 274 return; 275 } 276 277 var content = $('#apc_modal_'+popupId); 278 279 var popupProperties = content.data(); 280 281 if (typeof popupProperties === "undefined") { 282 return; 283 } 284 285 var preview = false; 286 if (getQueryString('previewPopup') !== null) { 287 preview = true; 288 } 289 290 var maxWidth = '90%'; 291 var maxHeight = '90%'; 292 if (typeof(popupProperties.height) == "undefined" || typeof(popupProperties.width) == "undefined") { 293 maxWidth = 'auto'; 294 maxHeight = 'auto'; 295 } else if (popupProperties.height === '100%' && popupProperties.width === '100%') { 296 maxWidth = '100%'; 297 maxHeight = '100%'; 298 } 299 300 var autoSize = false;
301 if (!popupProperties.height && !popupProperties.width) { 302 autoSize = true; 303 } 304 305 if (!popupProperties.height) { 306 popupProperties.height = 'auto'; 307 } 308 309 if (!popupProperties.width) { 310 popupProperties.width = 'auto'; 311 } 312 313 if (!popupProperties.openEffect) { 314 popupProperties.openEffect = 'zoom'; 315 } 316 317 var secsDisplay = 0; 318 if (popupProperties.secsDisplay) { 319 secsDisplay = popupProperties.secsDisplay; 320 } else if (popupProperties.secsDisplayCart) { 321 secsDisplay = popupProperties.secsDisplayCart; 322 } 323 324 setTimeout(function() { 325 $apcFancybox.open({ 326 href : '#apc_modal_'+popupId, 327 src : '#apc_modal_'+popupId, 328 autoSize : autoSize, 329 width : popupProperties.width, 330 height : popupProperties.height, 331 padding : popupProperties.padding, 332 autoCenter : true, 333 aspectRatio : false, 334 wrapCSS : 'apc-popup apc-popup-'+popupProperties.popupId+' '+popupProperties.css, 335 margin : 0, 336 maxWidth : maxWidth, 337 maxHeight : maxHeight, 338 openMethod : popupProperties.openEffect+'In', 339 closeMethod : popupProperties.openEffect+'Out', 340 beforeShow : function () { 341 if (!preview) { 342 $.ajax({ 343 type: 'POST', 344 headers: {"cache-control": "no-cache"}, 345 url: apc_link, 346 async: true, 347 cache: false, 348 dataType: "json", 349 data: 'markAsSeen=1&popupId=' + popupProperties.popupId + '&time=' + (new Date()).getTime() + '&token=' + apc_token 350 }); 351 } 352 353 if (popupProperties.blurBackground) { 354 $("main, header, body > section, footer, #page").addClass("apc-effect-blur"); 355 } 356 357 // Bug with Uniform 358 if (typeof $.fn.uniform === 'function') { 359 $("select.form-control,input[type='checkbox']:not(.comparator), input[type='radio'],input#id_carrier2, input[type='file']").not(".not_unifrom, .not_uniform").uniform(); 360 } 361 }, 362 afterShow : function () { 363 if (popupProperties.opacity == 0 && !popupProperties.locked) { 364 $('.fancybox-overlay').attr('style', function(i,s) { if (s == undefined) { s = ''; } return s + 'display: none !important;' }); 365 } 366 367 // Bug with vertical scroll in images 368 /*if ($('.apc-popup-'+popupProperties.popupId+' .modal-img').scrollTop() == 0) { 369 $('.apc-popup-'+popupProperties.popupId+' .fancybox-inner').attr('style', 'overflow: hidden !important;'); 370 }*/ 371 372 $apcFancybox.toggle(); 373 374 if ($('.apc-popup-'+popupProperties.popupId+' .modal-img').length > 0) { 375 var img = $('.apc-popup-'+popupProperties.popupId+' .modal-img'); 376 if (img.get(0).height <= $('.apc-popup-'+popupProperties.popupId+' .fancybox-inner').height()) { 377 $('.apc-popup-'+popupProperties.popupId+' .fancybox-inner').attr('style', 'overflow: hidden !important;'); 378 } 379 } 380 }, 381 afterClose : function () { 382 if (popupProperties.blurBackground) { 383 $("main, header, body > section, footer, #page").removeClass("apc-effect-blur"); 384 } 385 386 }, 387 helpers: { 388 overlay : { 389 css: { 390 'background' : 'rgba(0, 0, 0, '+popupProperties.opacity+')', 391 }, 392 locked: popupProperties.locked, 393 closeClick: popupProperties.closeBackground 394 } 395 } 396 }); 397 }, secsDisplay); 398 399 if (typeof(popupProperties.secsClose) != "undefined" && popupProperties.secsClose > 0) { 400 setTimeout( function() {$apcFancybox.close(); }, popupProperties.secsClose);
400 // 3000 = 3 secs 401 } 402} 403 404function dontDisplayAgain(popupId) { 405 if (typeof $.fancyboxPopup != "undefined") { 406 var $apcFancybox = $.fancyboxPopup; 407 } else { 408 $apcFancybox = $.fancybox; 409 } 410 411 $.ajax({ 412 type: 'POST', 413 headers: {"cache-control": "no-cache"}, 414 url: apc_link, 415 async: true, 416 cache: false, 417 dataType: "json", 418 data: 'dontDisplayAgain=1&popupId=' + popupId + '&time='+(new Date()).getTime()+'&token='+apc_token 419 }); 420 421 $apcFancybox.close(); 422}
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.