1var egyeb_ar1_netto = new Array(); 2var egyeb_ar1_brutto = new Array(); 3var egyeb_ar2_netto = new Array(); 4var egyeb_ar2_brutto = new Array(); 5var egyeb_ar3_netto = new Array(); 6var egyeb_ar3_brutto = new Array(); 7var egyeb_ar1_orig_netto = new Array(); 8var egyeb_ar1_orig_brutto = new Array(); 9var egyeb_ar2_orig_netto = new Array(); 10var egyeb_ar2_orig_brutto = new Array(); 11var egyeb_ar3_orig_netto = new Array(); 12var egyeb_ar3_orig_brutto = new Array(); 13 14var price_shop_netto = new Array(); 15var price_shop_brutto = new Array(); 16var price_net_netto = new Array(); 17var price_net_brutto = new Array(); 18var price_net_afa = new Array(); 19var price_akcio_netto = new Array(); 20var price_akcio_brutto = new Array(); 21var price_akcio_afa = new Array(); 22var price_unit_netto = new Array(); 23var price_unit_brutto = new Array(); 24var price_unit_div = new Array(); 25 26var price_net_akt = 0; 27var price_akcio_akt = 0; 28var price_save = 0; 29 30var recaptcha_rendered; 31var page_artdet; 32var price_kedv = new Array(); 33var price_kedv_netto = new Array(); 34var percent_kedv = new Array(); 35var kedv_num = -1; 36 37if (price_nullcut_disable == undefined) var price_nullcut_disable = 0; 38if (price_decimal_sup == undefined) var price_decimal_sup = 0; 39if (typeof google_analytics == undefined) var google_analytics = 0; 40if (typeof google_ads == undefined) var google_ads = 0; 41if (typeof google_consent == undefined) var google_consent = 0; 42if (typeof facebook_pixel == undefined) var facebook_pixel = 0; 43 44var marketing_settings={ 45 width: 660, 46 height: "content", 47 offsetHeight: -80, 48 contentId:"page_marketing_content", 49 popupId:"marketing", 50 modal:0.6, 51 overflow: "scroll" 52} 53 54$(document).ready(function () { 55 if (UNAS.design!=undefined && UNAS.design.page!="") { 56 $(document).trigger("loadPage", {page:UNAS.design.page}); 57 } 58}); 59 60function throttleWithTrailing(func, wait = 200, option = {leading: true, trailing: true}) { 61 let waiting = false; 62 let lastArgs = null; 63 return function wrapper(...args) { 64 if(!waiting) { 65 waiting = true; 66 const startWaitingPeriod = () => setTimeout(() => { 67 if(option.trailing && lastArgs) { 68 func.apply(this, lastArgs); 69 lastArgs = null; 70 startWaitingPeriod(); 71 } 72 else { 73 waiting = false; 74 } 75 }, wait); 76 if(option.leading) { 77 func.apply(this, args); 78 } else { 79 lastArgs = args; 80 } 81 startWaitingPeriod(); 82 } 83 else { 84 lastArgs = args; 85 } 86 } 87} 88 89function number_format( number, decimals, dec_point, thousands_sep ) { 90 var n = number, prec = decimals; 91 n = !isFinite(+n) ? 0 : +n; 92 prec = !isFinite(+prec) ? 0 : Math.abs(prec); 93 var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep; 94 var dec = (typeof dec_point == "undefined") ? '.' : dec_point; 95 96 var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0; 97 98 var abs = Math.abs(n).toFixed(prec); 99 var _, i; 100 101 if (abs >= 1000) { 102 _ = abs.split(/\D/); 103 i = _[0].length % 3 || 3; 104 105 _[0] = s.slice(0,i + (n < 0)) + 106 _[0].slice(i).replace(/(\d{3})/g, sep+'$1'); 107 s = _.join(dec); 108 } else { 109 s = s.replace('.', dec); 110 } 111 112 if (price_decimal_sup==1) price_nullcut_disable=1; 113 if (decimals>0 && price_nullcut_disable!=1) s=s.replace(/0*$/, ''); 114 115 if (price_decimal_sup==1) { 116 if (s.indexOf(dec_point)) { 117 s=s.replace(dec_point,'<sup>')+'</sup>'; 118 } 119 } 120 121 if (s[s.length-1]==dec) s=s.substr(0,s.length-1); 122 123 return s; 124} 125 126function unas_number_format( number, decimals, dec_point, thousands_sep ) { 127 var n = number, prec = decimals; 128 n = !isFinite(+n) ? 0 : +n; 129 prec = !isFinite(+prec) ? 0 : Math.abs(prec); 130 var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep; 131 var dec = (typeof dec_point == "undefined") ? '.' : dec_point; 132 133 var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0; 134 135 var abs = Math.abs(n).toFixed(prec); 136 var _, i; 137 138 if (abs >= 1000) { 139 _ = abs.split(/\D/); 140 i = _[0].length % 3 || 3; 141 142 _[0] = s.slice(0,i + (n < 0)) + 143 _[0].slice(i).replace(/(\d{3})/g, sep+'$1'); 144 s = _.join(dec); 145 } else { 146 s = s.replace('.', dec); 147 } 148 149 if (price_decimal_sup==1) price_nullcut_disable=1; 150 if (decimals>0 && price_nullcut_disable!=1) s=s.replace(/0*$/, ''); 151 152 if (price_decimal_sup==1) { 153 if (s.indexOf(dec_point)) { 154 s=s.replace(dec_point,'<sup>')+'</sup>'; 155 } 156 } 157 158 if (s[s.length-1]==dec) s=s.substr(0,s.length-1); 159 160 return s; 161} 162
163/*** VARIANTS ***/ 164function select_base_price(cikk,artdet) { 165 egyeb_ar1_netto[cikk]=new Array(); 166 egyeb_ar1_brutto[cikk]=new Array(); 167 egyeb_ar2_netto[cikk]=new Array(); 168 egyeb_ar2_brutto[cikk]=new Array(); 169 egyeb_ar3_netto[cikk]=new Array(); 170 egyeb_ar3_brutto[cikk]=new Array(); 171 egyeb_ar1_orig_netto[cikk]=new Array(); 172 egyeb_ar1_orig_brutto[cikk]=new Array(); 173 egyeb_ar2_orig_netto[cikk]=new Array(); 174 egyeb_ar2_orig_brutto[cikk]=new Array(); 175 egyeb_ar3_orig_netto[cikk]=new Array(); 176 egyeb_ar3_orig_brutto[cikk]=new Array(); 177 178 if (money_thousend=="") money_thousend=" "; 179 if (money_dec=="") money_dec=","; 180 181 if (money_thousend==".") { 182 var re_thousend = /\./g; 183 } else { 184 var re_thousend = new RegExp(money_thousend, "g"); 185 } 186 if (money_dec==".") { 187 var re_dec = new RegExp("---unas---", "g"); 188 } else { 189 var re_dec = new RegExp(money_dec, "g"); 190 } 191 192 if ($(".price_shop_netto_"+cikk).length > 0 ) price_shop_netto[cikk]=parseFloat($(".price_shop_netto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 193 if ($(".price_shop_brutto_"+cikk).length > 0 ) price_shop_brutto[cikk]=parseFloat($(".price_shop_brutto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 194 if ($(".price_net_netto_"+cikk).length > 0 ) price_net_netto[cikk]=parseFloat($(".price_net_netto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 195 if ($(".price_net_brutto_"+cikk).length > 0 ) price_net_brutto[cikk]=parseFloat($(".price_net_brutto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 196 if ($(".price_net_afa_"+cikk).length > 0 ) price_net_afa[cikk]=parseFloat($(".price_net_afa_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 197 if ($(".price_akcio_netto_"+cikk).length > 0 ) price_akcio_netto[cikk]=parseFloat($(".price_akcio_netto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 198 if ($(".price_akcio_brutto_"+cikk).length > 0 ) price_akcio_brutto[cikk]=parseFloat($(".price_akcio_brutto_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 199 if ($(".price_akcio_afa_"+cikk).length > 0 ) price_akcio_afa[cikk]=parseFloat($(".price_akcio_afa_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 200 201 if ($("#price_unit_div_"+cikk).length > 0 ) price_unit_div[cikk]=parseFloat($("#price_unit_div_"+cikk).html().replace(re_thousend,'').replace(re_dec,'.')); 202 price_unit_brutto[cikk]=price_shop_brutto[cikk]; 203 price_unit_netto[cikk]=price_shop_netto[cikk]; 204 if (price_net_brutto[cikk]>0) { 205 price_unit_brutto[cikk]=price_net_brutto[cikk]; 206 price_unit_netto[cikk]=price_net_netto[cikk]; 207 } 208 if (price_akcio_brutto[cikk]>0) { 209 price_unit_brutto[cikk]=price_akcio_brutto[cikk]; 210 price_unit_netto[cikk]=price_akcio_netto[cikk]; 211 } 212 213 if (artdet==1) { 214 const parsePrice = $el => 215 parseFloat($el.html().replace(re_thousend, '').replace(re_dec, '.')); 216 do { 217 kedv_num++; 218 219 let $price = $(`#price_kedv_${cikk}_${kedv_num}`); 220 const $priceNext = $(`#price_kedv_${cikk}_${kedv_num + 1}`); 221 222 if (!$price.length && $priceNext.length) { 223 kedv_num++; 224 $price = $priceNext; 225 } 226 227 const $priceNet = $(`#price_kedv_netto_${cikk}_${kedv_num}`); 228 229 if ($price.length || $priceNet.length) { 230 if ($price.length) 231 price_kedv[kedv_num] = parsePrice($price); 232 233 if ($priceNet.length) 234 price_kedv_netto[kedv_num] = parsePrice($priceNet); 235 } else { 236 kedv_num--; 237 break; 238 } 239 } while(true); 240 page_artdet=1; 241 } else { 242 page_artdet=0; 243 } 244} 245 246function change_price(cikk,orig,type,result,value) { 247 //alert(result.indexOf("_net_")); 248 if (result.indexOf("_net_")!=-1 || result.indexOf("_unit_netto_")!=-1) { 249 if (type=='netto' || type == "unit_netto") { 250 temp_ar1=egyeb_ar1_orig_netto[cikk]; 251 temp_ar2=egyeb_ar2_orig_netto[cikk]; 252 temp_ar3=egyeb_ar3_orig_netto[cikk]; 253 } else if (type=='afa') { 254 temp_ar1=new Array();
255 egyeb_ar1_orig_brutto[cikk].forEach(function(item, index){ 256 temp_ar1[index]=egyeb_ar1_orig_brutto[cikk][index]-egyeb_ar1_orig_netto[cikk][index]; 257 }); 258 temp_ar2=new Array(); 259 egyeb_ar2_orig_brutto[cikk].forEach(function(item, index){ 260 temp_ar2[index]=egyeb_ar2_orig_brutto[cikk][index]-egyeb_ar2_orig_netto[cikk][index]; 261 }); 262 temp_ar3=new Array(); 263 egyeb_ar3_orig_brutto[cikk].forEach(function(item, index){ 264 temp_ar3[index]=egyeb_ar3_orig_brutto[cikk][index]-egyeb_ar3_orig_netto[cikk][index]; 265 }); 266 } else { 267 temp_ar1=egyeb_ar1_orig_brutto[cikk]; 268 temp_ar2=egyeb_ar2_orig_brutto[cikk]; 269 temp_ar3=egyeb_ar3_orig_brutto[cikk]; 270 } 271 } else { 272 if (type=='netto') { 273 temp_ar1=egyeb_ar1_netto[cikk]; 274 temp_ar2=egyeb_ar2_netto[cikk]; 275 temp_ar3=egyeb_ar3_netto[cikk]; 276 } else if (type=='afa') { 277 temp_ar1=new Array(); 278 egyeb_ar1_brutto[cikk].forEach(function(item, index){ 279 temp_ar1[index]=egyeb_ar1_brutto[cikk][index]-egyeb_ar1_netto[cikk][index]; 280 }); 281 temp_ar2=new Array(); 282 egyeb_ar2_brutto[cikk].forEach(function(item, index){ 283 temp_ar2[index]=egyeb_ar2_brutto[cikk][index]-egyeb_ar2_netto[cikk][index]; 284 }); 285 temp_ar3=new Array(); 286 egyeb_ar3_brutto[cikk].forEach(function(item, index){ 287 temp_ar3[index]=egyeb_ar3_brutto[cikk][index]-egyeb_ar3_netto[cikk][index]; 288 }); 289 } else { 290 temp_ar1=egyeb_ar1_brutto[cikk]; 291 temp_ar2=egyeb_ar2_brutto[cikk]; 292 temp_ar3=egyeb_ar3_brutto[cikk]; 293 } 294 } 295 296 var akt=orig; 297 var percent2=(100-value)/100; 298 if (jQuery.fn.jquery<'1.6.0') { 299 if ($("#egyeb_list1_"+cikk).length > 0 ) akt=akt+(temp_ar1[$("#egyeb_list1_"+cikk).attr("selectedIndex")]*percent2); 300 if ($("#egyeb_list2_"+cikk).length > 0 ) akt=akt+(temp_ar2[$("#egyeb_list2_"+cikk).attr("selectedIndex")]*percent2); 301 if ($("#egyeb_list3_"+cikk).length > 0 ) akt=akt+(temp_ar3[$("#egyeb_list3_"+cikk).attr("selectedIndex")]*percent2); 302 } else { 303 if ($("#egyeb_list1_"+cikk).length > 0 ) akt=akt+(temp_ar1[$("#egyeb_list1_"+cikk).prop("selectedIndex")]*percent2); 304 if ($("#egyeb_list2_"+cikk).length > 0 ) akt=akt+(temp_ar2[$("#egyeb_list2_"+cikk).prop("selectedIndex")]*percent2); 305 if ($("#egyeb_list3_"+cikk).length > 0 ) akt=akt+(temp_ar3[$("#egyeb_list3_"+cikk).prop("selectedIndex")]*percent2); 306 } 307 if (type!='netto') { 308 if (type=='unit_brutto' && price_unit_div[cikk]>0) akt=akt/price_unit_div[cikk]; 309 if (type=='unit_netto' && price_unit_div[cikk]>0) akt=akt/price_unit_div[cikk]; 310 } 311 if (akt>0 || (typeof config_plus['variant_price_change_allow_null']!=='undefined' && akt>=0)) { 312 var money_len_act=money_len; 313 if ((type=="unit_netto" || type=="unit_brutto") && typeof unit_price_len !== "undefined") money_len_act=unit_price_len; 314 315 $(result).html(unas_number_format(akt,money_len_act,money_dec,money_thousend)); 316 return akt; 317 } 318} 319 320function change_egyeb(cikk, ajax = 0) { 321 let temp_product_array = {}; 322 if ($(".price_shop_netto_"+cikk).length > 0 ) change_price(cikk,price_shop_netto[cikk],'netto','.price_shop_netto_'+cikk,0); 323 if ($(".price_shop_brutto_"+cikk).length > 0 ) change_price(cikk,price_shop_brutto[cikk],'brutto','.price_shop_brutto_'+cikk,0); 324 325 if ($(".price_net_netto_" + cikk).length > 0) { 326 price_net_akt = change_price(cikk, price_net_netto[cikk], 'netto', '.price_net_netto_' + cikk, 0); 327 temp_product_array['price_net'] = price_net_akt; 328 } 329 if ($(".price_net_brutto_" + cikk).length > 0) { 330 price_net_akt = change_price(cikk, price_net_brutto[cikk], 'brutto', '.price_net_brutto_' + cikk, 0); 331 temp_product_array['price_gross'] = price_net_akt; 332 } 333 if ($(".price_net_afa_" + cikk).length > 0) change_price(cikk, price_net_afa[cikk], 'afa', '.price_net_afa_' + cikk, 0); 334 335 if ($(".price_akcio_netto_" + cikk).length > 0) { 336 price_akcio_akt = change_price(cikk, price_akcio_netto[cikk], 'netto', '.price_akcio_netto_' + cikk, 0); 337 temp_product_array['price_sale_net'] = price_akcio_akt; 338 } 339 if ($(".price_akcio_brutto_" + cikk).length > 0) { 340 price_akcio_akt = change_price(cikk, price_akcio_brutto[cikk], 'brutto', '.price_akcio_brutto_' + cikk, 0); 341 temp_product_array['price_sale_gross'] = price_akcio_akt; 342 } 343 if ($(".price_akcio_afa_"+cikk).length > 0 ) change_price(cikk,price_akcio_afa[cikk],'afa','.price_akcio_afa_'+cikk,0); 344 345 if ($("#price_unit_brutto_"+cikk).length > 0 ) change_price(cikk,price_unit_brutto[cikk],'unit_brutto','#price_unit_brutto_'+cikk,0); 346 if ($("#price_unit_netto_"+cikk).length > 0 ) change_price(cikk,price_unit_netto[cikk],'unit_netto','#price_unit_netto_'+cikk,0); 347 348 for (i = 0; i <= kedv_num; i++) { 349 if (price_kedv[i] !== undefined) { 350 change_price(cikk, price_kedv[i], 'brutto', `#price_kedv_${cikk}_${i}`, percent_kedv[i]); 351 } 352 if (price_kedv_netto[i] !== undefined) { 353 change_price(cikk, price_kedv_netto[i], 'netto', `#price_kedv_netto_${cikk}_${i}`, percent_kedv[i]); 354 } 355 } 356 357 let price_save_badge_element = $("#price_save_"+cikk); 358 let price_save_percent_element = $(".js-sale-percent-"+cikk); 359 360 if ( price_akcio_akt>0 && price_net_akt>0 && (price_save_badge_element.length > 0 || price_save_percent_element.length > 0) ) { 361 if (typeof config_plus['price_save_len']!=='undefined') { 362 price_save_len=config_plus['price_save_len']; 363 } else { 364 price_save_len=0; 365 } 366 if (typeof config_plus['price_save_round_normal']!=='undefined') { 367 price_save_round_normal=config_plus['price_save_round_normal']; 368 } else { 369 price_save_round_normal=0; 370 } 371 372 //price_save=100-Math.round(price_akcio_akt/price_net_akt*100); 373 price_save_raw=100-price_akcio_akt/price_net_akt*100; 374 if (price_save_round_normal!=1) { 375 price_save_round=Math.pow(price_save_len); 376 if (price_save_raw>=0) { 377 price_save_raw=Math.floor(price_save_raw*price_save_round)/price_save_round; 378 } else { 379 price_save_raw=Math.ceil(price_save_raw*price_save_round)/price_save_round; 380 } 381 } 382 383 price_save=number_format(price_save_raw, price_save_len,".",""); 384 if (price_save>0) { 385 if ( (price_save_badge_element.length > 0 && price_save_badge_element.html().indexOf("%")!=-1) || (price_save_percent_element.length > 0 && price_save_percent_element.html().indexOf("%")!=-1) ) { 386 price_save=price_save+"%"; 387 } 388 price_save_badge_element.html(price_save); 389 price_save_percent_element.html(price_save); 390 } 391 } 392 393 //custom event call for retargeting.biz 394 temp_product_array['sku'] = cikk; 395 temp_product_array['ajax'] = ajax; 396 397 if ($("#egyeb_list1_"+cikk).length > 0 ) { 398 temp_product_array['variant_name1']=$("#egyeb_nev1_"+cikk).val(); 399 temp_product_array['variant_list1']=$("#egyeb_list1_"+cikk).val(); 400 401 var variant_gross1 = parseFloat($(`#egyeb_list1_${cikk} option:selected`).data("price-gross")); 402 var variant_net1 = parseFloat($(`#egyeb_list1_${cikk} option:selected`).data("price-net")); 403 404 temp_product_array['variant_price_gross1']=(isNaN(variant_gross1) ? 0 : variant_gross1); 405 temp_product_array['variant_price_net1']=(isNaN(variant_net1) ? 0 : variant_net1); 406 } 407 408 if ($("#egyeb_list2_"+cikk).length > 0 ) { 409 temp_product_array['variant_name2']=$("#egyeb_nev2_"+cikk).val(); 410 temp_product_array['variant_list2']=$("#egyeb_list2_"+cikk).val(); 411 412 var variant_gross2 = parseFloat($(`#egyeb_list2_${cikk} option:selected`).data("price-gross")); 413 var variant_net2 = parseFloat($(`#egyeb_list2_${cikk} option:selected`).data("price-net")); 414 415 temp_product_array['variant_price_gross2']=(isNaN(variant_gross2) ? 0 : variant_gross2); 416 temp_product_array['variant_price_net2']=(isNaN(variant_net2) ? 0 : variant_net2); 417 } 418 419 if ($("#egyeb_list3_"+cikk).length > 0 ) { 420 temp_product_array['variant_name3']=$("#egyeb_nev3_"+cikk).val(); 421 temp_product_array['variant_list3']=$("#egyeb_list3_"+cikk).val(); 422 423 var variant_gross3 = parseFloat($(`#egyeb_list3_${cikk} option:selected`).data("price-gross")); 424 var variant_net3 = parseFloat($(`#egyeb_list3_${cikk} option:selected`).data("price-net")); 425 426 temp_product_array['variant_price_gross3']=(isNaN(variant_gross3) ? 0 : variant_gross3); 427 temp_product_array['variant_price_net3']=(isNaN(variant_net3) ? 0 : variant_net3); 428 } 429 430 $(document).trigger("changeVariant", temp_product_array); 431} 432 433function select_get(select_num,cikk,prefix) { 434 temp_egyeb1="!!!unas-no-data!!!"; 435 temp_egyeb2="!!!unas-no-data!!!"; 436 temp_egyeb3="!!!unas-no-data!!!"; 437 438 if ($("#egyeb_list1_"+cikk).length > 0 ) temp_egyeb1=$("#egyeb_list1_"+cikk).val(); 439 if ($("#egyeb_list2_"+cikk).length > 0 ) temp_egyeb2=$("#egyeb_list2_"+cikk).val(); 440 if ($("#egyeb_list3_"+cikk).length > 0 ) temp_egyeb3=$("#egyeb_list3_"+cikk).val(); 441 442 if ((select_num==1 && $("#egyeb_list2_"+cikk).length > 0 ) || (select_num==2 && $("#egyeb_list3_"+cikk).length > 0 )) { 443 $.ajax({ 444 type: "GET", 445 async: true, 446 dataType: 'json', 447 url: shop_url_main+'/shop_artdet.php', 448 data: { 449 action:"select_get", 450 cikk:cikk, 451 list1:temp_egyeb1, 452 list2:temp_egyeb2, 453 list3:temp_egyeb3, 454 select_num:select_num, 455 prefix:prefix 456 }, 457 success: function(result) { 458 if (select_num==1 && $("#egyeb_list2_"+cikk).length > 0 ) { 459 $("#egyeb_list2_"+cikk+" option").each(function(){ 460 if (result.select2_enable.includes($(this).val())) {
461 $(this).prop("disabled",false); 462 $(this).css("display", "");/*fix ver 5 option style*/ 463 } 464 if (result.select2_disable.includes($(this).val())) { 465 $(this).prop("disabled",true); 466 $(this).css("display","none"); 467 } 468 }); 469 470 if ($("#egyeb_list2_"+cikk+" option:selected").attr("value")!="") $("#egyeb_list2_"+cikk).val(result.list2); 471 } 472 if ((select_num==1 || select_num==2) && $("#egyeb_list3_"+cikk).length > 0 ) { 473 $("#egyeb_list3_"+cikk+" option").each(function(){ 474 if (result.select3_enable.includes($(this).val())) { 475 $(this).prop("disabled",false); 476 $(this).css("display", ""); 477 } 478 if (result.select3_disable.includes($(this).val())) { 479 $(this).prop("disabled",true); 480 $(this).css("display","none"); 481 } 482 }); 483 484 if ($("#egyeb_list3_"+cikk+" option:selected").attr("value")!="") $("#egyeb_list3_"+cikk).val(result.list3); 485 } 486 change_egyeb(cikk, 1); 487 488 if (unas_design_ver>=3) { 489 $('.select-styled-variants').each(function(){ 490 var $temp_variant_items=$(this); 491 $(this).find("option").each(function(){ 492 if ($(this).prop("disabled")==true) { 493 $temp_variant_items.find("li[rel='"+$(this).attr("value")+"']").css("display","none"); 494 } else { 495 $temp_variant_items.find("li[rel='"+$(this).attr("value")+"']").css("display","block"); 496 } 497 }); 498 $temp_variant_items.find(".select-styled").html($temp_variant_items.find("select option:checked").text()); 499 }); 500 } 501 } 502 }); 503 } 504} 505 506/*** TOOLTIP + PRODUCT TYPE ***/ 507function product_type_get() { 508 if (arguments[0] === 'trigger') $(document).trigger('ajaxProductTooltipLoading'); 509 let product_type_select_data=new Object(); 510 product_type_select_data['action']="get_product_type"; 511 product_type_select_data['get_type']=arguments[0]; 512 product_type_select_data['param_id']=new Array(); 513 product_type_select_data['param_value']=new Array(); 514 temp_num=-1; 515 let selector = ".product_type_select"; 516 if (arguments[0] === 'trigger' && $(".product_type_select.tooltip").length > 0) selector = ".product_type_select.tooltip"; 517 $(selector).each(function() { 518 temp_num++; 519 product_type_select_data['param_id'][temp_num]=$(this).attr('data-param_id'); 520 if (product_type_select_data['param_id'][temp_num]==undefined) product_type_select_data['param_id'][temp_num]=$(this).attr('rel'); 521 product_type_select_data['param_value'][temp_num]=$(this).val(); 522 }); 523 $.ajax({ 524 type: "GET", 525 dataType: "json", 526 async: true, 527 data: product_type_select_data, 528 url: arguments[1], 529 success: function(result){ 530 if (result.get_type=="trigger") { 531 $(document).trigger("productTypeChange",result); 532 } 533 if (result.get_type=="location_href" && result.url!="") { 534 location.href=result.url; 535 } 536 } 537 }); 538} 539 540function product_type_url() { 541 product_type_get("location_href"); 542} 543 544function product_type_mod(param_id,new_value) { 545 $("#param_type_"+param_id).val(new_value); 546 $("#tooltip_param_type_"+param_id).val(new_value); 547 product_type_get(arguments[2],arguments[3]); 548 return false; 549} 550 551function product_type_none() {} 552 553$(document).ready(function(){ 554 $(".product_type_select").change(function() { 555 product_type_url(); 556 }); 557 $(".page_artdet_product_type_element a").attr("href","javascript:product_type_none();"); 558}); 559 560function ajaxProductTooltip(sku,target){ 561 $.ajax({ 562 type: "GET", 563 url: shop_url_main + "/shop_artdet.php", 564 data: "ajax_tooltip=1&get_ajax=1&ajax_nodesign=1&cikk=" + sku + '&
564change_lang=' + actual_lang, 565 beforeSend: function(){ 566 $(document).trigger('ajaxProductTooltipLoading'); 567 }, 568 success: function(result) { 569 $(target).html(result); 570 $(document).trigger('ajaxProductTooltipLoaded'); 571 } 572 }); 573} 574 575/*** OLD TOOLTIP ***/ 576$(document).ready(function(){ 577 if ($(".param_desc_popup[title]:not(.param_desc_popup_ver4)").length>0) { 578 $(".param_desc_popup[title]:not(.param_desc_popup_ver4)").tooltip({tipClass: "param_desc_tooltip text_normal bg_color_light3 border_1"}); 579 } 580}); 581 582/*** CART ADD ***/ 583function cart_file_submit(random, sku_orig) { 584 var fd = new FormData(); 585 $(".cust_input_file").each(function(){ 586 var $this = $(this); 587 var add_to_sku_only = $this.attr("data-add-to-sku-only"); 588 var file_data = $this[0].files[0]; 589 590 if (file_data !== undefined) { 591 if ( add_to_sku_only !== undefined && add_to_sku_only !== false ) { /* param has add_to_sku_only attribute */ 592 if (add_to_sku_only === sku_orig) { /* attribute value is equal with actual product sku which added to cart, so add parameter ONLY to this product! */ 593 $this.addClass("cust_input_file_uploading"); 594 fd.append($this.attr("id"), file_data); 595 } 596 } else { /* DEFAULT behavior, param has no attribute */ 597 $this.addClass("cust_input_file_uploading"); 598 fd.append($this.attr("id"), file_data); 599 } 600 } 601 }); 602 fd.append("action", "fileupload"); 603 fd.append("get_ajax", "1"); 604 fd.append("rnd_number", random); 605 606 $.ajax({ 607 url: shop_url_main+"/shop_ajax/ajax_cart.php", 608 type: "POST", 609 async: false, 610 data: fd, 611 processData: false, 612 contentType: false, 613 cache: false, 614 enctype: "multipart/form-data", 615 complete: function(){ 616 $(".cust_input_file.cust_input_file_uploading").removeClass("cust_input_file_uploading").addClass('cust_input_file_uploaded'); 617 } 618 }); 619 return false; 620} 621 622function cart_marketing_popup(sku,variant_name1,variant_list1,variant_name2,variant_list2,variant_name3,variant_list3,product_param,marketing_close_script) { 623 if (quick_order_in_progress) return; 624 var cart_marketing_ajax_data="get_ajax=1&marketing_type=popup&change_lang="+actual_lang+"&cikk="+sku; 625 cart_marketing_ajax_data=cart_marketing_ajax_data+"&egyeb_nev1="+encodeURIComponent(variant_name1)+"&egyeb_list1="+encodeURIComponent(variant_list1); 626 cart_marketing_ajax_data=cart_marketing_ajax_data+"&egyeb_nev2="+encodeURIComponent(variant_name2)+"&egyeb_list2="+encodeURIComponent(variant_list2); 627 cart_marketing_ajax_data=cart_marketing_ajax_data+"&egyeb_nev3="+encodeURIComponent(variant_name3)+"&egyeb_list3="+encodeURIComponent(variant_list3); 628 cart_marketing_ajax_data=cart_marketing_ajax_data+"&product_param="+encodeURIComponent(product_param); 629 if (typeof config_plus['unas_design']!=='undefined') cart_marketing_ajax_data=cart_marketing_ajax_data+"&unas_design="+config_plus['unas_design']; 630 631 $.shop_popup("open",{ 632 ajax_url:shop_url_main+"/shop_marketing.php", 633 ajax_data:cart_marketing_ajax_data, 634 ajax_loader:false, 635 width: 660, 636 height: "content", 637 offsetHeight: -80, 638 contentId:"page_marketing_content", 639 popupId:"marketing", 640 class:"shop_popup_marketing", 641 modal:0.6, 642 onClose: function() { 643 if (marketing_close_script!="") setTimeout(function() { 644 eval(marketing_close_script); 645 $(document).trigger("addToCartSuccessEnd",{onClose:marketing_close_script}); 646 },400); 647 }, 648 onForbidden: function(){ 649 if (marketing_close_script!="") setTimeout(function() { 650 eval(marketing_close_script); 651 $(document).trigger("addToCartSuccessEnd",{onClose:marketing_close_script}); 652 },400); 653 }, 654 onLoad: function() { 655 if ($("#page_PopupContainer").css("display") == "none") $.shop_popup("close"); 656 }, 657 onEmpty: function() { 658 if (marketing_close_script=="") $(document).trigger("addToCartSuccessEnd",{onClose:''}); 659 }, 660 overflow: "scroll" 661 }); 662} 663 664/*** COOKIE ***/ 665function isBlockedByAdblock(selector) { 666 const el = document.querySelector(selector); 667 if (!el) return false;
668 669 const originalInlineDisplay = el.style.display; 670 const initialStyle = window.getComputedStyle(el).display; 671 672 el.style.setProperty('display', 'block', 'important'); 673 const finalStyle = window.getComputedStyle(el).display; 674 675 el.style.display = originalInlineDisplay; 676 return initialStyle === 'none' && finalStyle === 'none'; 677} 678function cookie_alert_action(close,allow_marketing,allow_statistics,allow_personalization) { 679 if (typeof allow_statistics === 'undefined') allow_statistics=allow_marketing; 680 if (typeof allow_personalization === 'undefined') allow_personalization=allow_marketing; 681 682 $(document).ready(function(){ 683 const cookieEl = $("#cookie_alert"); 684 const cookieOverlayEl = $('#overlay_cookie_alert'); 685 686 /// consent 687 if (google_consent==1 && allow_marketing!=-1) { 688 var act_consent_marketing='denied'; 689 if (allow_marketing==1) act_consent_marketing='granted'; 690 691 var act_consent_statistics='denied'; 692 if (allow_statistics==1) act_consent_statistics='granted'; 693 694 var act_consent_personalization='denied'; 695 if (allow_personalization==1) var act_consent_personalization='granted'; 696 697 gtag('consent', 'update', { 698 'ad_storage': act_consent_marketing, 699 'ad_user_data': act_consent_marketing, 700 'ad_personalization': act_consent_marketing, 701 'analytics_storage': act_consent_statistics, 702 'functionality_storage': act_consent_personalization, 703 'personalization_storage': act_consent_personalization, 704 'security_storage': 'granted' 705 }); 706 } 707 708 if (close==1) { 709 if (cookieEl.length>0) { 710 cookieEl.slideUp(300, function() { 711 cookieEl.addClass("cookie_alert_close"); 712 cookieEl.slideDown(150); 713 }); 714 } 715 if (config_plus['accessible_design']) { 716 const delay = (unas_design_ver >= 5) ? 350 : 0; /* BS offcanvas/modal transition 300ms */ 717 718 const focusWithDelay = (focusCallback) => { 719 setTimeout(focusCallback, delay); 720 }; 721 722 if (UNAS.design.active_element) { /* ha van elmentett trigger elem (cookie megnyitó gomb), akkor arra tesszük a fókuszt vissza */ 723 focusWithDelay(() => { 724 UNAS.design.active_element.focus(); 725 UNAS.design.active_element = null; 726 }); 727 } else { 728 focusWithDelay(() => { 729 document.activeElement?.blur(); 730 const firstFocusable = document.querySelector('.logo a'); 731 if (firstFocusable) { 732 firstFocusable.focus(); 733 } 734 }); 735 } 736 } 737 738 $(document).trigger("closeConsent",{}); 739 if (google_analytics==1) gtag("event", "cookie_consent_close", { }); 740 } else if (close==0) { 741 let openedBy = false; 742 743 if (allow_marketing == -1) { 744 openedBy = document.activeElement; 745 UNAS.design.active_element = openedBy; 746 } 747 if (cookieEl.length>0) { 748 cookieEl.slideUp(150, function() { 749 cookieEl.removeClass("cookie_alert_close"); 750 cookieEl.slideDown(300); 751 }); 752 setTimeout(function (){ 753 cookieEl.focus(); 754 }, 2000); 755 } else if (cookieOverlayEl.length>0) { 756 cookieOverlayEl.focus(); 757 } 758 $(document).trigger("openConsent",{ 'openedBy':openedBy }); 759 if (google_analytics==1) gtag("event", "cookie_consent_open", { }); 760 } 761 762 /// allow 763 if (allow_marketing==1 && allow_statistics==1 && allow_personalization==1) { 764 if (cookieEl.length>0) cookieEl.addClass("cookie_alert_allow"); 765 766 $(document).trigger("grantConsent",{}); 767 if (google_analytics==1) gtag("event", "cookie_consent_granted", { }); 768 } else if (allow_marketing!=-1) { 769 if (cookieEl.length>0) cookieEl.removeClass("cookie_alert_allow"); 770 771 $(document).trigger("rejectConsent",{}); 772 if (google_analytics==1) gtag("event", "cookie_consent_denied", { }); 773 } 774 775 /// save 776 $.ajax({ 777 type: "GET", 778 url: shop_url_main+"/shop_ajax/ajax_cookie_alert.php", 779 data: { 780 service_type:service_type, 781 close:close, 782 allow_marketing:allow_marketing, 783 allow_statistics:allow_statistics, 784 allow_personalization:allow_personalization, 785 get_ajax:"1" 786 }, 787 success: function(){ 788 $(document).trigger("consentSaved",{}); 789 } 790 }); 791 }); 792} 793 794/*** SET FRONTVAR ***/ 795function set_front_var(key,value,type) { 796 set_front_var_ajax_url=UNAS.shop.base_url+"/shop_ajax/ajax_set_front_var.php"; 797 if (service_type=="cms") set_front_var_ajax_url=UNAS.shop.base_url+"/ajax/ajax_set_front_var.php"; 798 799 $.ajax({ 800 type: "GET", 801 async: true, 802 url:set_front_var_ajax_url, 803 data: { 804 get_ajax:1, 805 key:key, 806 value:value, 807 type:type 808 } 809 }); 810} 811 812/*** QTY INPUT ***/ 813function qty_plus_minus(temp_this,plus_minus) { 814 //init 815 if (money_dec=="") money_dec=","; 816 if (money_dec==".") { 817 var re_dec = new RegExp("---unas---", "g"); 818 } else { 819 var re_dec = new RegExp(money_dec, "g"); 820 } 821 822 //vals 823 var temp_input=temp_this.closest(".page_qty_input_outer").find(".page_qty_input"); 824 var temp_qty_min = parseFloat(temp_input.attr('data-min')); 825 var temp_qty_max = parseFloat(temp_input.attr('data-max')); 826 var temp_qty_step = parseFloat(temp_input.attr('data-step')); 827 var temp_qty_act = parseFloat(String(temp_input.val()).replace(re_dec,'.')); 828 var temp_qty_val_change = 0; 829 var temp_qty_test = 0; 830 var temp_qty_act_temp = 0; 831 832 //action 833 if (plus_minus=='plus') { 834 temp_qty_test = Math.round((temp_qty_act + temp_qty_step)*1000000)/1000000; 835 if (!isNaN(temp_qty_act) && temp_qty_test <= temp_qty_max) { 836 temp_qty_act = temp_qty_test; 837 temp_qty_val_change=1; 838 } 839 } 840 if (plus_minus=='minus') { 841 temp_qty_test = Math.round((temp_qty_act-temp_qty_step)*1000000)/1000000; 842 if (!isNaN(temp_qty_act) && temp_qty_test >= temp_qty_min) { 843 temp_qty_act = temp_qty_test; 844 temp_qty_val_change=1; 845 } 846 } 847 848 //validation 849 if (!isNaN(temp_qty_act) && temp_qty_act > temp_qty_max) { 850 temp_qty_act = temp_qty_max; 851 temp_qty_val_change=1; 852 } 853 if (!isNaN(temp_qty_act) && temp_qty_act < temp_qty_min) { 854 temp_qty_act = temp_qty_min; 855 temp_qty_val_change=1; 856 } 857 858 temp_qty_act_temp = Math.round((temp_qty_act-temp_qty_min)/temp_qty_step)*temp_qty_step+temp_qty_min; 859 temp_qty_act_temp = Math.round(temp_qty_act_temp*1000000)/1000000; 860 if (temp_qty_act_temp>temp_qty_max) { 861 temp_qty_act_temp = Math.floor((temp_qty_act-temp_qty_min)/temp_qty_step)*temp_qty_step+temp_qty_min; 862 temp_qty_act_temp = Math.round(temp_qty_act_temp*1000000)/1000000; 863 } 864 if (temp_qty_act_temp!=temp_qty_act) { 865 temp_qty_act=temp_qty_act_temp; 866 temp_qty_val_change=1; 867 } 868 if (isNaN(temp_qty_act)) temp_qty_act=temp_input.prop("defaultValue"); 869 870 //disable 871 if (!isNaN(temp_qty_act) && Math.round((temp_qty_act + temp_qty_step)*1000000)/1000000 > temp_qty_max) { 872 temp_this.closest(".page_qty_input_outer").find(".qtyplus_common").addClass("qty_disable"); 873 } else { 874 temp_this.closest(".page_qty_input_outer").find(".qtyplus_common").removeClass("qty_disable"); 875 } 876 if (!isNaN(temp_qty_act) && Math.round((temp_qty_act - temp_qty_step)*1000000)/1000000 < temp_qty_min) { 877 temp_this.closest(".page_qty_input_outer").find(".qtyminus_common").addClass("qty_disable"); 878 } else { 879 temp_this.closest(".page_qty_input_outer").find(".qtyminus_common").removeClass("qty_disable"); 880 } 881 882 //return 883 if (temp_qty_val_change==1 && !isNaN(temp_qty_act)) { 884 if (temp_input.attr("type")=="number") { 885 temp_input.val(temp_qty_act).trigger("change"); 886 } else { 887 temp_input.val(String(temp_qty_act).replace('.', money_dec)).trigger("change"); 888 } 889 890 temp_input.trigger("changeProductQty", { operation: plus_minus }); 891 } 892 893 //global change event, +/- and typing 894 temp_input.trigger("productQtyMod"); 895} 896 897function multiplyPackageOfferItemQuantities(target, packageOfferQuantity) { 898 const packageOfferID = $(target).attr("data-package-offer-id");
899 const cartRoot = $(target).closest(".js-cart-root"); 900 const cartPackageOfferItemQuantities = cartRoot.find(`.js-cart-item-qty-value-${packageOfferID}`); 901 902 cartPackageOfferItemQuantities.each(function (index, cartPackageOfferItemQuantity) { 903 let packageOfferItemQuantityInput = $(cartPackageOfferItemQuantity); 904 let packageOfferItemQuantity = parseFloat(packageOfferItemQuantityInput.attr("step")); 905 let newPackageOfferItemQuantity = packageOfferItemQuantity * packageOfferQuantity; 906 907 packageOfferItemQuantityInput.val(isNaN(newPackageOfferItemQuantity) ? packageOfferItemQuantity : newPackageOfferItemQuantity); 908 }); 909} 910 911$(document).ready(function(){ 912 if (unas_design_ver>=3) { 913 var hovered_qty_input = null; 914 $('body').on("focus", ".page_qty_input", function(e) { 915 if ($(this).prop("readonly")!=true) hovered_qty_input = $(this); 916 }); 917 $('body').on("blur", ".page_qty_input", function(e) { 918 hovered_qty_input = null; 919 }); 920 921 $('body').on("click", ".qtyplus_common", function () { 922 qty_plus_minus($(this),'plus'); 923 }); 924 $('body').on("click", ".qtyminus_common", function () { 925 qty_plus_minus($(this),'minus'); 926 }); 927 $('body').on("blur", ".page_qty_input", function () { 928 qty_plus_minus($(this),''); 929 $(document).trigger("changeProductQtyInput", { 'input': this }); 930 }); 931 $('.page_qty_input').each(function () { 932 qty_plus_minus($(this),''); 933 }); 934 935 // (PACKAGE-OFFERS) 936 $(document).on("changeProductQty", function (event, parameters) { 937 multiplyPackageOfferItemQuantities(event.target, $(event.target).val()); 938 }); 939 940 let cartItemQuantityInput = $(".page_qty_input"); 941 942 cartItemQuantityInput.on("input change", function (event) { 943 let { target } = event; 944 let $target = $(target); 945 let max = $target.attr("data-max"); 946 let value = parseFloat($target.val()); 947 948 if (value > max) { 949 value = max; 950 $target.val(max); 951 } 952 953 multiplyPackageOfferItemQuantities(target, value); 954 }); 955 } 956}); 957 958/*** PRODUCT STAT ***/ 959function get_product_sku(temp_object) { 960 var temp_sku_return=temp_object.attr("data-sku"); 961 962 if (temp_sku_return=="") { 963 var temp_sku = temp_object.attr("class").split(" "); 964 temp_sku.forEach(function(temp_sku_val){ 965 if (temp_sku_val.indexOf("product_sku_")!=-1) { 966 temp_sku_return=temp_sku_val.replace("product_sku_",""); 967 } 968 }); 969 } 970 971 return temp_sku_return; 972} 973 974function facebook_event(event,cart,event_id) { 975 fbq('track', event, cart, event_id); 976} 977 978$(document).ready(function() { 979 if (google_analytics==1) { 980 if (typeof config_plus['google_analytics_select_promotion_disabled']==='undefined') { 981 /*if (unas_design_ver>=5) { 982 $('.js-element a, a.js-element').click(function () { 983 var _creative_name=$(this).attr("href"); 984 if ($(this).hasClass("js-element")) { 985 var _creative_slot=$(this).attr("id"); 986 } else { 987 var _creative_slot=$(this).closest(".js-element").attr("id"); 988 } 989 gtag("event", "select_promotion", { 990 'creative_name':_creative_name, 991 'creative_slot':_creative_slot 992 }); 993 }); 994 } else {*/ 995 $('.bxSlider a, .nivoSlider a, .js-element a, a.js-element').click(function () { 996 gtag("event", "select_promotion", { 997 'creative_name':$(this).attr("href"), 998 'creative_slot':'element' 999 }); 1000 }); 1001 //} 1002 } 1003 $("a[href^='mailto:']").click(function(){ 1004 gtag("event", "link_mailto", { 'href':$(this).attr("href").replace("mailto:","") }); 1005 }); 1006 $("a[href^='tel:']").click(function(){ 1007 gtag("event", "link_tel", { 'href':$(this).attr("href").replace("tel:","") }); 1008 }); 1009 //VERIFY 1010 $(document).on("clickOrderButton", function(event,params){ 1011 if (params.id=='initiate') { 1012 UNAS.getCart(function (data) { 1013 gtag('event', "begin_checkout", { 1014 "currency": UNAS.shop.currency_code, 1015 "value": data.sum, 1016 "coupon": data.coupon_id, 1017 "items": data.analytics_items 1018 }); 1019 },{
1020 'analytics_items': 1, 1021 'categories': 1 1022 }); 1023 } 1024 if (params.page=='mods' && params.direction!="back") { 1025 var analytics_payment_type=params.paymentMethod; 1026 var analytics_shipping_tier=params.shippingMethod; 1027 1028 UNAS.getCart(function (data) { 1029 gtag('event', "add_payment_info", { 1030 "currency": UNAS.shop.currency_code, 1031 "value": data.sum, 1032 "coupon": data.coupon_id, 1033 "payment_type": analytics_payment_type, 1034 "items": data.analytics_items 1035 }); 1036 gtag('event', "add_shipping_info", { 1037 "currency": UNAS.shop.currency_code, 1038 "value": data.sum, 1039 "coupon": data.coupon_id, 1040 "shipping_tier": analytics_shipping_tier, 1041 "items": data.analytics_items 1042 }); 1043 },{ 1044 'analytics_items': 1, 1045 'categories': 1 1046 }); 1047 } 1048 }); 1049 $(document).on("emptyCart", function(event, params){ 1050 gtag("event", "empty_cart", { }); 1051 }); 1052 $(document).on("removeFromCart", function(event, params){ 1053 gtag('event', 'remove_from_cart', { 1054 "items": [ 1055 { 1056 "item_id": params.sku 1057 } 1058 ] 1059 }); 1060 }); 1061 $(document).on("addToCart", function(event, product_array){ 1062 gtag('event', 'add_to_cart', { 1063 "currency": UNAS.shop.currency_code, 1064 "value": product_array.price*product_array.qty, 1065 "items": [product_array.analytics_item] 1066 }); 1067 }); 1068 $(document).on("addToFavourites", function(event, product_array){ 1069 gtag('event', 'add_to_wishlist', { 1070 "currency": UNAS.shop.currency_code, 1071 "items": [product_array.analytics_item] 1072 }); 1073 }); 1074 $(document).on("removeFromFavourites", function(event, product_array){ 1075 gtag('event', 'remove_from_wishlist', { 1076 "currency": UNAS.shop.currency_code, 1077 "items": [product_array.analytics_item] 1078 }); 1079 }); 1080 } 1081 $('#container').on("click",".product_link_promo",function () { 1082 var temp_click_sku=get_product_sku($(this)); 1083 $(document).trigger("clickProduct", {sku:temp_click_sku,type:'promo'}); 1084 if (google_analytics==1 && temp_click_sku != "" && typeof config_plus['google_analytics_select_promotion_disabled']==='undefined') { 1085 gtag('event', 'select_promotion', { 1086 'creative_name': temp_click_sku, 1087 'creative_slot': 'product', 1088 "items": [ 1089 { 1090 "item_id": temp_click_sku, 1091 } 1092 ] 1093 }); 1094 } 1095 }); 1096 $('#container').on("click",".product_link_normal",function () { 1097 var temp_click_sku=get_product_sku($(this)); 1098 $(document).trigger("clickProduct", {sku:temp_click_sku,type:'normal'}); 1099 if (google_analytics==1 && temp_click_sku != "") { 1100 gtag('event', 'select_item', { 1101 "items": [ 1102 { 1103 "item_id": temp_click_sku, 1104 } 1105 ] 1106 }); 1107 } 1108 }); 1109}); 1110 1111/*** SEARCH BOX ***/ 1112$(document).ready(function() { 1113 $(".js-search-input").on('click keyup', function (e) { 1114 let $thisElement = $(this); 1115 1116 if ($thisElement.prop('readonly') === true) { 1117 if (e.type === 'click' || (e.type === 'keyup' && e.key === 'Tab')) { 1118 $thisElement.blur(); 1119 $thisElement.prop('readonly',false); 1120 $thisElement.focus(); 1121 } 1122 } 1123 }); 1124}); 1125 1126/*** TAG FILTER ***/ 1127function filterByTag(config) { 1128 var $filterByTag = this; 1129 var $filterTag = "js-filter-by-tag"; 1130 var $filterTagInList = "js-filter-by-tag-in-list"; 1131 var $filterTagActive = "js-active-filter"; 1132 var $filterableElement = "js-filterable"; 1133 if ($("."+$filterableElement).length<0) $filterableElement = "js-fitlerable"; 1134 var $filterableElementWrapper = "js-filterable-elements-wrapper"; 1135 if ($("."+$filterableElementWrapper).length<0) $filterableElementWrapper = "js-fitlerable-elements-wrapper"; 1136 var $filterTagsWrapper = "js-tags"; 1137 var $filterClearTag = "js-clear-tag-filter"; 1138 var $page = 1; 1139 var filterTagPageId = UNAS.shop.page_id; 1140 if (typeof filterTagPageId === "undefined") filterTagPageId = $("."+$filterableElementWrapper).attr("data-filter-tag-page-id"); 1141 var $filterDo = "js-do-filter"; 1142 var $config = config || {}; 1143 1144 $filterByTag.filterInit = function () { 1145 $("."+$filterTag).on("click", function () { 1146 var _this=$(this); 1147 $filterByTag.filter(null,_this); 1148 }); 1149 } 1150 1151 $filterByTag.clearFilterInit = function() { 1152 $("."+$filterClearTag).on("click", function () { 1153 var _this=$(this); 1154 1155 $filterByTag.$page = 1; 1156 1157 $("."+$filterTag).removeClass($filterTagActive).attr('aria-pressed','false'); 1158 $filterByTag.filter({},_this); 1159 1160 (unas_design_ver>=4) ? $(_this).addClass("d-none") : $(_this).hide(); 1161 1162 document.dispatchEvent(new CustomEvent("filterByTagCleared")); 1163 }); 1164 } 1165 1166 $filterByTag.filterInitTagsInList = function () { 1167 $(document).on("click", "." + $filterTagInList, function () { 1168 var _this = $(this); 1169 var id = _this.data("filter"); 1170 1171 if (typeof id === "undefined") { 1172 return; 1173 } 1174 1175 $("#js-tag-" + _this.data("filter").replace("js-filterable-", "")).trigger("click"); 1176 }); 1177 } 1178 1179 $filterByTag.filterInitAJAX = function () { 1180 $("."+$filterTag).on("click", function () { 1181 var _this=$(this); 1182 $filterByTag.checkActiveElement(_this); 1183 $filterByTag.filter($filterByTag.getDataFilter(),_this); 1184 }); 1185 } 1186 1187 $filterByTag.checkActiveElement = function (_this) { 1188 if ($(_this).hasClass($filterTag)) { 1189 if ($(_this).hasClass($filterTagActive)) { 1190 $(_this).removeClass($filterTagActive).attr('aria-pressed','false'); 1191 } else { 1192 $(_this).addClass($filterTagActive).attr('aria-pressed','true'); 1193 } 1194 } 1195 1196 if (unas_design_ver>=4) { 1197 if ($("."+$filterTagActive).length<1) $(".js-clear-tag-filter").addClass("d-none"); else $(".js-clear-tag-filter").removeClass("d-none"); 1198 } else { 1199 if ($("."+$filterTagActive).length<1) $(".js-clear-tag-filter").css("display","none"); else $(".js-clear-tag-filter").css("display","inline-block"); 1200 } 1201 } 1202 1203 $filterByTag.filter = function (dataFilter,_this) { 1204 switch(config.type) { 1205 case "category": 1206 $filterByTag.checkActiveElement(_this); 1207 1208 $("."+$filterableElement).hide(); 1209 1210 $('.'+$filterTagsWrapper+" ."+$filterTag+"."+$filterTagActive).each(function() { 1211 var tag = $(this).attr("data-filter"); 1212 var classNames = '.' + tag; 1213 $("."+$filterableElement).filter(classNames).show(); 1214 }); 1215 1216 if ($('.'+$filterTag+'.'+$filterTagActive).length<1) $("."+$filterableElement).show(); 1217 break; 1218 case "content": 1219 if (typeof filterTagPageId === "undefined") { 1220 $(document).trigger("filterByTagError",{ 1221 filter_tags:$("."+$filterTagsWrapper), 1222 filterable_elements:$("."+$filterableElementWrapper), 1223 error:'no_page_id' 1224 }); 1225 break; 1226 } 1227 1228 loadPlusPage({ 1229 type: "filter", 1230 dataFilter: dataFilter, 1231 page_id: filterTagPageId, 1232 filter_wrapper: $filterTagsWrapper, 1233 filter_el_wrapper: $filterableElementWrapper, 1234 page_act: $filterByTag.$page 1235 }); 1236 } 1237 } 1238 1239 $filterByTag.getDataFilter = function () { 1240 var dataFilter = {}; 1241 1242 $("."+$filterTagActive).each(function(index, el) { 1243 dataFilter[index] = $(el).attr("data-filter").replace("js-filterable-","").replace("js-fitlerable-"); 1244 }); 1245 1246 return dataFilter; 1247 } 1248 1249 $filterByTag.pagination = function (page) { 1250 $filterByTag.$page = (typeof page === "undefined") ? 1 : page; 1251 $filterByTag.filter($filterByTag.getDataFilter(),null); 1252 } 1253} 1254 1255function isInViewport(element) { 1256 let EL = element; 1257 if (typeof element === 'string') { 1258 EL = document.querySelector(element); 1259 } else if (typeof element === 'object' && element instanceof jQuery) { 1260 EL = element[0]; 1261 } 1262 1263 if (!EL) return false;
1264 1265 const RECT = EL.getBoundingClientRect(); 1266 1267 let headerHeight = 0; 1268 1269 if (typeof headerCorrection === "function") { 1270 const scrollTop = window.scrollY; 1271 const elementOffset = RECT.top + window.scrollY; 1272 1273 headerHeight = headerCorrection(scrollTop, elementOffset); 1274 } 1275 1276 return ( 1277 RECT.top >= headerHeight && 1278 RECT.left >= 0 && 1279 RECT.bottom <= (window.innerHeight || document.documentElement.clientHeight) && 1280 RECT.right <= (window.innerWidth || document.documentElement.clientWidth) 1281 ); 1282} 1283 1284function add_focus_to_first_invalid(el) { 1285 const containers = document.querySelectorAll(el); 1286 if (!containers.length) return false; 1287 1288 for (const container of containers) { 1289 const firstErrorInput = container.querySelector('.is-invalid'); 1290 if (firstErrorInput) { 1291 setTimeout(() => { 1292 firstErrorInput.focus(); 1293 }, 100); 1294 return true; 1295 } 1296 } 1297 1298 return false; 1299} 1300 1301/*** SCROLL TO ELEMENT ***/ 1302function scrollToElement(el, offset = undefined, scrollIn = undefined, container = undefined, duration = 400, callback = undefined) { 1303 let element_object; 1304 1305 if (jQuery.type(el) !== 'object'){ 1306 element_object = { 1307 element: el, 1308 offset: offset, 1309 scrollIn: scrollIn, 1310 container: container, 1311 duration: duration, 1312 callback: callback 1313 }; 1314 } else { 1315 element_object = el; 1316 } 1317 let $offset = element_object.offset || 10; 1318 let $window = $(window); 1319 let $scrollIn, $scrollTop, $container, $element; 1320 1321 if (element_object.element !== undefined && element_object.element !== null && element_object.element !== '') { 1322 $element = $(element_object.element); 1323 } 1324 1325 if (element_object.scrollIn !== undefined && element_object.scrollIn !== null && element_object.scrollIn !== '') { 1326 $scrollIn = $(element_object.scrollIn); 1327 } else { 1328 $scrollIn = $('html,body'); 1329 1330 if (typeof headerCorrection === "function" ) { 1331 $offset = headerCorrection($window.scrollTop(), $element.offset().top); 1332 if (element_object.offset !== undefined && element_object.offset > 0) $offset += element_object.offset; 1333 } 1334 } 1335 1336 if (element_object.scrollIn === undefined) { 1337 $scrollTop = $element.offset().top; 1338 1339 document.documentElement.style.scrollBehavior = 'auto'; 1340 document.body.style.scrollBehavior = 'auto'; 1341 } else { 1342 if (element_object.container !== undefined && element_object.container !== null && element_object.container !== '') { 1343 $container = $(element_object.container); 1344 } 1345 1346 $scrollTop = $element.offset().top - $window.scrollTop() + $scrollIn.scrollTop() - ($container !== undefined ? (($window.height() - $container.height())/2) : 0); 1347 } 1348 1349 $scrollIn.animate({ scrollTop: $scrollTop - $offset }, element_object.duration, function() { 1350 if (element_object.callback !== undefined) { 1351 eval(element_object.callback()); 1352 } 1353 if (element_object.scrollIn === undefined) { 1354 document.documentElement.style.scrollBehavior = ''; 1355 document.body.style.scrollBehavior = ''; 1356 } 1357 }); 1358} 1359 1360/*** BOX VOTE ***/ 1361function get_month(month) { 1362 if (service_type=="cms") { 1363 $.ajax({ 1364 type: "GET", 1365 async: true, 1366 url: calendar_ajax_url, 1367 data: { 1368 home_id:home_id, 1369 lang_master:actual_lang, 1370 get_ajax:1, 1371 month:month 1372 }, 1373 success: function(result){ 1374 $("#box_calendar_content").html(result); 1375 } 1376 }); 1377 } else { 1378 $.ajax({ 1379 type: "GET", 1380 async: true, 1381 url: calendar_ajax_url, 1382 data: { 1383 shop_id:shop_id, 1384 lang_master:actual_lang, 1385 get_ajax:1, 1386 month:month 1387 }, 1388 success: function(result){ 1389 $("#box_calendar_content").html(result); 1390 } 1391 }); 1392 } 1393} 1394 1395/*** CART ***/ 1396function cart_empty() { 1397 $.ajax({ 1398 type: "GET", 1399 async: true, 1400 url: shop_url_main+"/shop_ajax/ajax_cart.php", 1401 dataType: 'json', 1402 data: { 1403 get_ajax:1, 1404 action:"empty" 1405 }, 1406 success: function(result_empty){ 1407 cart_add_finish(result_empty,""); 1408 $(document).trigger("emptyCart",{}); 1409 } 1410 }); 1411} 1412 1413function cart_delete(item) { 1414 $.ajax({ 1415 type: "GET", 1416 async: true, 1417 url: shop_url_main+"/shop_ajax/ajax_cart.php", 1418 dataType: 'json', 1419 data: { 1420 get_ajax:1, 1421 action:"delete", 1422 item:item 1423 }, 1424 success: function(result_delete){ 1425 cart_add_finish(result_delete,""); 1426 1427 if (result_delete.sku != "" && result_delete.sku != undefined) { 1428 $(document).trigger("removeFromCart", { 1429 master_key: result_delete.master_key, 1430 sku: result_delete.sku, 1431 qty: result_delete.qty, 1432 qty_of_items: result_delete.qty_of_items, 1433 qty_of_products: result_delete.qty_of_products, 1434 unit: result_delete.unit, 1435 name: result_delete.name, 1436 price: result_delete.price, 1437 variant_1_name: result_delete.variant_1_name, 1438 variant_1_value: result_delete.variant_1_value, 1439 variant_2_name: result_delete.variant_2_name, 1440 variant_2_value: result_delete.variant_2_value, 1441 variant_3_name: result_delete.variant_3_name, 1442 variant_3_value: result_delete.variant_3_value, 1443 triggered_by: 'cart_box' 1444 }); 1445 } 1446 } 1447 }); 1448} 1449 1450function cartAddFIFO(products, packageOfferID, packageOfferCartID, numberOfCartItems, index) { 1451 if (products.length) { 1452 let product = products.shift(); 1453 1454 if (index === 1) { 1455 $(".js-package-offer-" + packageOfferID + " .js-package-offer-add-to-cart-spinner").show(); 1456 1457 if (unas_design_ver < 5) { 1458 $(document).mask({ 1459 loadSpeed: 0, 1460 zIndex: 1000, 1461 opacity: 0, 1462 color: "#fff", 1463 closeOnEsc: false, 1464 closeOnClick: false, 1465 maskId: "packageOfferAddToCartExposeMask" 1466 }); 1467 } 1468 } 1469
1470 cart_add(product.sku.toString(), `package_offer_${packageOfferID}_`, product.qty, false, { 1471 variants: product.variants, 1472 variant_names: product.variant_names, 1473 package_offer_id: packageOfferID, 1474 package_offer_cart_id: packageOfferCartID, 1475 cart_item_index: index, 1476 number_of_cart_items: numberOfCartItems, 1477 finish_disabled: ((unas_design_ver > 4 && products.length > 0) ? 1 : 0) 1478 }).then(function () { 1479 cartAddFIFO(products, packageOfferID, packageOfferCartID, numberOfCartItems, ++index); 1480 }); 1481 } 1482} 1483 1484$(document).ready(function () { 1485 $(document).on("change", ".page_artlist_other_select", function (event, parameters) { 1486 let { target } = event; 1487 let $product_variant_select = $(target); 1488 let $product_variant_select_id = $product_variant_select.attr("id"); 1489 1490 if ($product_variant_select_id.indexOf("_package_offer_") < 0) { 1491 return false; 1492 } 1493 1494 let $package_offer = $product_variant_select.closest(".package-offer"); 1495 let $package_offer_id = $package_offer.attr("data-id"); 1496 let $package_offer_items = $(`.js-package-offer-item-${$package_offer_id}.js-has-variant`); 1497 1498 let variants_plus = 0; 1499 1500 if ($package_offer_items.length) { 1501 $package_offer_items.each(function (package_offer_item_index, package_offer_item) { 1502 let package_offer_quantity = parseFloat($(package_offer_item).attr("data-qty")); 1503 1504 if (isNaN(package_offer_quantity)) { 1505 package_offer_quantity = 1; 1506 } 1507 1508 $(this).find(".page_artlist_other_select").each(function (variant_select_index, variant_select) { 1509 let $variant_selected = $(variant_select).find("option:selected"); 1510 let gross = parseFloat($variant_selected.attr("data-price-gross")); 1511 1512 if (isNaN(gross)) { 1513 gross = 0; 1514 } 1515 1516 variants_plus += gross * package_offer_quantity; 1517 }); 1518 }); 1519 1520 let package_offer_price = $package_offer.find(".js-package-offer-price"); 1521 let package_offer_original_price = $package_offer.find(".js-package-offer-original-price"); 1522 let package_offer_percent = $package_offer.find(".js-package-offer-percent"); 1523 let package_offer_price_value = parseFloat(package_offer_price.attr("data-price-original")); 1524 let package_offer_price_original_value = parseFloat(package_offer_original_price.attr("data-price-raw")); 1525 1526 package_offer_price_value+=variants_plus; 1527 1528 let percent = Math.round(100 - (package_offer_price_value / package_offer_price_original_value * 100)); 1529 1530 if (percent > 0) { 1531 package_offer_original_price.show(); 1532 package_offer_percent.attr("data-percent-value", percent).show(); 1533 } else { 1534 package_offer_original_price.hide(); 1535 package_offer_percent.attr("data-percent-value", 0).hide(); 1536 } 1537 1538 package_offer_price.attr("data-price", unas_number_format(package_offer_price_value.toFixed(money_len), money_len, money_dec, money_thousend).concat(` ${UNAS.shop.currency_type}`)); 1539 package_offer_price.attr("data-price-raw", package_offer_price_value); 1540 } 1541 }); 1542}); 1543 1544function check_cust_input_live(){ 1545 $(".cust_input.required").each(function(){ 1546 const $this = $(this); 1547 const $thisID = $this.attr("id"); 1548 1549 $this.on('change blur', function(){ 1550 if (!$this.val()) { 1551 $("#page_artdet_product_param_spec_"+$thisID+", #page_artdet_product_param_spec_"+$thisID+"_value").addClass("page_artdet_product_param_spec_fault"); 1552 $this.addClass('is-invalid').attr('aria-invalid','true'); 1553 } else { 1554 $("#page_artdet_product_param_spec_"+$thisID+", #page_artdet_product_param_spec_"+$thisID+"_value").removeClass("page_artdet_product_param_spec_fault"); 1555 $this.removeClass('is-invalid').attr('aria-invalid','false'); 1556 } 1557 }); 1558 }); 1559} 1560 1561function delete_package_offer(package_offer_cart_id) { 1562 $.ajax({ 1563 type: "GET", 1564 async: true, 1565 url: shop_url_main + "/shop_ajax/ajax_cart.php", 1566 dataType: 'json', 1567 data: { 1568 get_ajax: 1, 1569 action: "delete_package_offer", 1570 package_offer_cart_id: package_offer_cart_id 1571 }, 1572 success: function (result_delete) { 1573 cart_add_finish(result_delete, ""); 1574 1575 if (Array.isArray(result_delete.products)) {
1576 result_delete.products.forEach(function (product) { 1577 if (product.sku != "" && product.sku != undefined) { 1578 $(document).trigger("removeFromCart", { 1579 is_bulk : true, 1580 master_key: product.master_key, 1581 sku: product.sku, 1582 qty: product.qty, 1583 unit: result_delete.unit, 1584 name: result_delete.name, 1585 price: result_delete.price, 1586 variant_1_name: product.variant_1_name, 1587 variant_1_value: product.variant_1_value, 1588 variant_2_name: product.variant_2_name, 1589 variant_2_value: product.variant_2_value, 1590 variant_3_name: product.variant_3_name, 1591 variant_3_value: product.variant_3_value 1592 }); 1593 } 1594 }); 1595 } 1596 1597 $(document).trigger("removeFromCartBulk", { 1598 skus: result_delete.skus, 1599 products: result_delete.products, 1600 qty_of_items: result_delete.qty_of_items, 1601 qty_of_products: result_delete.qty_of_products 1602 }); 1603 } 1604 }); 1605} 1606 1607$(document).ready(function(){ 1608 check_cust_input_live(); 1609}); 1610 1611//GLOBAL 1612function cart_add_fly(main_image) { 1613 if (typeof config_plus['cart_redirect']!=='undefined' && config_plus['cart_redirect']==1) { 1614 var main_image_fly="#box_cart_content"; 1615 if (typeof config_plus['cart_fly_id']!=='undefined' && config_plus['cart_fly_id']!="") { 1616 main_image_fly="#"+config_plus['cart_fly_id']; 1617 if (!$(main_image_fly).is(':visible') && $("#box_cart_content").is(':visible')) main_image_fly="#box_cart_content"; 1618 } 1619 if (!$(main_image_fly).is(':visible') && $("#box_cart_content2").is(':visible')) main_image_fly="#box_cart_content2"; 1620 1621 if ($(main_image_fly).length>0) { 1622 if ($("#"+main_image).length>0) { 1623 $(document).trigger("addToCartFly"); 1624 1625 var image = $("#"+main_image).offset(); 1626 var cart = $(main_image_fly).offset(); 1627 1628 $("#image_to_cart").html('<img id="image_to_cart_img" src="'+$("#"+main_image).attr('src')+'" />'); 1629 $("#image_to_cart_img").css("position","absolute"); 1630 $("#image_to_cart_img").css("top",image.top+"px"); 1631 $("#image_to_cart_img").css("left",image.left+"px"); 1632 $("#image_to_cart_img").css("opacity","0.8"); 1633 $("#image_to_cart_img").css("width",$("#"+main_image).width()+"px"); 1634 $("#image_to_cart_img").css("height",$("#"+main_image).height()+"px"); 1635 $("#image_to_cart_img").css("max-width","none"); 1636 $("#image_to_cart_img").css("max-height","none"); 1637 $("#image_to_cart").css("z-index","1000000"); 1638 $("#image_to_cart").css("display","block"); 1639 params = { 1640 top : cart.top + "px", 1641 left : cart.left + "px", 1642 opacity : 0.0, 1643 width : "20px", 1644 height : "20px", 1645 display: "none" 1646 }; 1647 $("#image_to_cart_img").animate(params, 500, function() { $("#image_to_cart_img").css("display","none"); }); 1648 } 1649 } 1650 } 1651} 1652var cart_add_warning=0; 1653function cart_add_redirect() { 1654 if (cart_add_warning!=1) { 1655 location.href=unas_shop_url+'/shop_cart.php'; 1656 $(document).trigger("addToCartRedirect"); 1657 } 1658} 1659function cart_refresh(type) { 1660 if (type==1 || typeof type == "undefined") { 1661 var cart_box_url=shop_url_main+"/shop_ajax/ajax_box_cart.php?get_ajax=1&lang_master="+actual_lang; 1662 if (typeof config_plus['unas_design']!=='undefined') cart_box_url=cart_box_url+"&unas_design="+config_plus['unas_design']; 1663 $("#box_cart_content").load(cart_box_url,function(){ $(document).trigger("cartRefreshed"); }); 1664 } 1665 1666 if (type==2 || typeof type == "undefined") { 1667 var cart_box_url2=shop_url_main+"/shop_ajax/ajax_box_cart.php?get_ajax=1&lang_master="+actual_lang+"&cart_num=2"; 1668 if (typeof config_plus['unas_design']!=='undefined') cart_box_url2=cart_box_url2+"&unas_design="+config_plus['unas_design']; 1669 $("#box_cart_content2").load(cart_box_url2); 1670 } 1671} 1672function cart_add_finish(result,main_image) { 1673 if (typeof config_plus['cart_refresh_force']!=='undefined' && config_plus['cart_refresh_force']=="1") { 1674 var cart_refresh_force=1; 1675 } else { 1676 var cart_refresh_force=0; 1677 } 1678 1679 if ($("#box_cart_content").is(':visible') || cart_refresh_force==1) cart_refresh(1); 1680 if (result.cart_box_more==1 && ($("#box_cart_content2").is(':visible') || cart_refresh_force==1)) cart_refresh(2); 1681 if (result.cart_add_callback!=null && result.cart_add_callback!="") eval(result.cart_add_callback+"();"); 1682 1683 if (result.package_offer === null || (result.package_offer !== null && result.is_last_package_offer == true)) { 1684 const alertEl = document.querySelector("#box_cart_content2 .js-cart-box-discount-alert"); 1685 1686 if (alertEl) { 1687 alertEl.classList.add('ajax-loading'); 1688 1689 fetch(unas_shop_url+"/shop_cart.php?ajax_nodesign=1&ajax_refresh=1&only_discount_total=1") 1690 .then(response => { 1691 if (!response.ok) { 1692 throw new Error('Hálózati hiba: ' + response.status); 1693 } 1694 return response.text(); 1695 }) 1696 .then(result => { 1697 if (result !== '' && result !== 'no') { 1698 alertEl.classList.remove('ajax-loading', 'd-none'); 1699 alertEl.classList.add('ajax-loaded'); 1700 var textEl = alertEl.querySelector('.cart-box__discount-alert-text'); 1701 if (textEl) { 1702 textEl.innerHTML = result; 1703 } 1704 } 1705 }) 1706 .catch(error => { 1707 console.error('AJAX hiba:', error); 1708 alertEl.classList.remove('ajax-loading'); 1709 }); 1710 } 1711 } 1712 1713 if ($(".container_shipping_cost").length>0 || $(".container_shipping_free").length>0) { 1714 var container_shipping_data={ 1715 get_ajax:1, 1716 shop_id:shop_id, 1717 lang_master:actual_lang 1718 } 1719 if (typeof config_plus['unas_design']!=='undefined') container_shipping_data['unas_design']=config_plus['unas_design']; 1720 1721 $.ajax({ 1722 type: "GET", 1723 sync: true, 1724 url: shop_url_main+"/shop_ajax/ajax_shipping.php", 1725 dataType: "json", 1726 data: container_shipping_data, 1727 success: function(result2){ 1728 $(".container_shipping_cost").html(result2.cost); 1729 $(".container_shipping_free").html(result2.free); 1730 } 1731 }); 1732 } 1733 1734 if (result.package_offer === null || (result.package_offer != "" && result.is_last_package_offer)) { 1735 if (result.overlay!="" && result.overlay!=undefined) { 1736 $("#overlay_cart_add").html(result.overlay); 1737 if (result.cart_onclose!="" && result.cart_redirect==0) { 1738 $("#overlay_cart_add").bind("onClose", function () { 1739 eval(result.cart_onclose); 1740 $(document).trigger("addToCartSuccessEnd",{onClose:result.cart_onclose}); 1741 }); 1742 } else { 1743 $("#overlay_cart_add").unbind("onClose"); 1744 if (result.qty_add>0) { 1745 $("#overlay_cart_add").bind("onClose", function () { 1746 $(document).trigger("addToCartSuccessEnd",{onClose:''}); 1747 }); 1748 } 1749 } 1750 $("#overlay_cart_add").overlay().load(); 1751 } else { 1752 if (result.cart_onclose!=undefined) { 1753 if (result.cart_onclose!="") { 1754 eval(result.cart_onclose); 1755 $(document).trigger("addToCartSuccessEnd",{onClose:result.cart_onclose}); 1756 } else { 1757 $(document).trigger("addToCartSuccessEnd",{onClose:''}); 1758 } 1759 } 1760 } 1761 } 1762} 1763 1764async function cart_add() { 1765 var sku=arguments[0]; 1766 var cart_prefix=arguments[1] 1767 var is_artdet=arguments[3] 1768 if ($("#ud_shop_artdet").length>0 && $("#db_"+cart_prefix+sku).val()!=undefined && is_artdet<1) is_artdet=1; 1769 var sku_orig=sku.replace(/__unas__/g,"-"); 1770 1771 var main_image="main_image_"+cart_prefix+sku; 1772 1773 if (!$("#"+main_image).is(":visible")) main_image=main_image+'_mobile'; 1774 1775 var qty=$("#db_"+cart_prefix+sku).val(); 1776 if (arguments[2]!=null) qty=arguments[2];
1777 if (qty<=0 || qty==null || qty==undefined) qty=1; 1778 1779 var cart_config=arguments[4]; 1780 1781 var variant_name1=$("#egyeb_nev1_"+cart_prefix+sku).val(); 1782 var variant_list1=$("#egyeb_list1_"+cart_prefix+sku).val(); 1783 var variant_name2=$("#egyeb_nev2_"+cart_prefix+sku).val(); 1784 var variant_list2=$("#egyeb_list2_"+cart_prefix+sku).val(); 1785 var variant_name3=$("#egyeb_nev3_"+cart_prefix+sku).val(); 1786 var variant_list3=$("#egyeb_list3_"+cart_prefix+sku).val(); 1787 1788 if (is_artdet>0 && $("#db_"+cart_prefix+sku).val()==undefined && unas_design_ver < 4) { 1789 variant_name1=document.form_temp_artdet.egyeb_nev1.value; 1790 variant_list1=document.form_temp_artdet.egyeb_list1.value; 1791 variant_name2=document.form_temp_artdet.egyeb_nev2.value; 1792 variant_list2=document.form_temp_artdet.egyeb_list2.value; 1793 variant_name3=document.form_temp_artdet.egyeb_nev3.value; 1794 variant_list3=document.form_temp_artdet.egyeb_list3.value; 1795 qty=document.form_temp_artdet.db.value; 1796 } 1797 1798 if (is_artdet>0) { 1799 if (variant_name1==undefined && $("#temp_egyeb_nev1").val()!="") variant_name1=$("#temp_egyeb_nev1").val(); 1800 if (variant_list1==undefined && $("#temp_egyeb_list1").val()!="") variant_list1=$("#temp_egyeb_list1").val(); 1801 if (variant_name2==undefined && $("#temp_egyeb_nev2").val()!="") variant_name2=$("#temp_egyeb_nev2").val(); 1802 if (variant_list2==undefined && $("#temp_egyeb_list2").val()!="") variant_list2=$("#temp_egyeb_list2").val(); 1803 if (variant_name3==undefined && $("#temp_egyeb_nev3").val()!="") variant_name3=$("#temp_egyeb_nev3").val(); 1804 if (variant_list3==undefined && $("#temp_egyeb_list3").val()!="") variant_list3=$("#temp_egyeb_list3").val(); 1805 } 1806 1807 let cartConfigIsSet = typeof cart_config !== "undefined"; 1808 let isPackageOfferItem = cartConfigIsSet && typeof cart_config["package_offer_cart_id"] !== "undefined"; 1809 let notPackageOffer = cartConfigIsSet && typeof cart_config["package_offer_cart_id"] === "undefined"; 1810 1811 if (isPackageOfferItem && typeof cart_config["variants"] !== "undefined") { 1812 variant_list1 = cart_config["variants"][0]; 1813 variant_list2 = cart_config["variants"][1]; 1814 variant_list3 = cart_config["variants"][2]; 1815 1816 variant_name1 = cart_config["variant_names"][0]; 1817 variant_name2 = cart_config["variant_names"][1]; 1818 variant_name3 = cart_config["variant_names"][2]; 1819 } 1820 1821 var error=0; 1822 var service_plus=""; 1823 if (is_artdet>0) { 1824 let artdet_type = "details" 1825 if (is_artdet == 2) artdet_type = "tooltip"; 1826 error = check_cust_input(sku_orig,artdet_type); 1827 main_image="main_image"; 1828 service_plus=$(".service_plus_radio input:checked").val(); 1829 } 1830 1831 if (is_artdet==2){ 1832 main_image="main_image_tooltip"; 1833 } 1834 1835 let subscription_period=""; 1836 if (is_artdet == 2) { 1837 subscription_period = $('input[name="tooltip_subscription_period"]:checked').val(); 1838 } else { 1839 subscription_period = $('input[name="subscription_period"]:checked').val(); 1840 } 1841 1842 if (error==1){ 1843 if (is_artdet==1) overlay_load("warning",lang_text_warning,lang_text_required_fields_missing); 1844 } else { 1845 var cust_input_file_random = Math.floor(Math.random()*(10000-1+1)+1); 1846 1847 ajax_async = true; 1848 if (cust_input_file_exists==1) { 1849 ajax_async = false; 1850 cart_file_submit(cust_input_file_random, sku_orig); 1851 } 1852 if (typeof cart_config !== "undefined" && typeof cart_config["ajax_sync"] !== "undefined" && cart_config["ajax_sync"]==1) ajax_async = false; 1853 1854 var product_param_temp; 1855 if(typeof is_artdet!=="undefined"){ 1856 product_param_temp = product_param.filter(Boolean).join("|"); 1857 } 1858 1859 var is_last_package_offer = false; 1860 1861 if (typeof cart_config !== "undefined" && typeof cart_config["cart_item_index"] !== "undefined" && typeof cart_config["number_of_cart_items"] !== "undefined" && cart_config["cart_item_index"] === cart_config["number_of_cart_items"]) { 1862 is_last_package_offer = true; 1863 $(".js-package-offer-add-to-cart-spinner").hide(); 1864 if (unas_design_ver < 5) { 1865 $.mask.close(); 1866 } 1867 $('body').css("overflow",""); 1868 } 1869 1870 let $data = { 1871 get_ajax:1, 1872 result_type:"json", 1873 lang_master:actual_lang, 1874 action:"add", 1875 sku:sku, 1876 qty:qty, 1877 variant_name1:variant_name1, 1878 variant_list1:variant_list1, 1879 variant_name2:variant_name2, 1880 variant_list2:variant_list2, 1881 variant_name3:variant_name3, 1882 variant_list3:variant_list3, 1883 service_plus:service_plus, 1884 subscription_period:subscription_period, 1885 product_param:product_param_temp, 1886 item_random_number:cust_input_file_random, 1887 cart_config:cart_config, 1888 is_last_package_offer: is_last_package_offer 1889 }; 1890 1891 return await $.ajax({ 1892 type: "POST", 1893 async: ajax_async, 1894 url: shop_url_main+"/shop_ajax/ajax_cart.php", 1895 dataType: 'json', 1896 data: $data, 1897 success: function(result){ 1898 let isPackageOfferItemAndLastPackageOfferItem = cartConfigIsSet && $data["cart_config"]["package_offer_cart_id"] !== "" && $data["cart_config"]["cart_item_index"] === $data["cart_config"]["number_of_cart_items"]; 1899 1900 result.is_last_package_offer = isPackageOfferItemAndLastPackageOfferItem; 1901 1902 let temp_product_array = { 1903 error: result.error, 1904 sku: sku_orig, 1905 master_key: result.master_key, 1906 name: result.name, 1907 url: result.url, 1908 unit: result.unit, 1909 event_id: result.event_id, 1910 category: result.category, 1911 price: result.price, 1912 qty: qty, 1913 qty_all: result.qty_all, 1914 qty_add: result.qty_add, 1915 variant_name1: variant_name1, 1916 variant_list1: variant_list1, 1917 variant_name2: variant_name2, 1918 variant_list2: variant_list2, 1919 variant_name3: variant_name3, 1920 variant_list3: variant_list3, 1921 cart_onclose: result.cart_onclose, 1922 package_offer: result.package_offer, 1923 is_last_package_offer_item: isPackageOfferItemAndLastPackageOfferItem, 1924 qty_of_items: result.qty_of_items, 1925 qty_of_products: result.qty_of_products,
1926 analytics_item: result.analytics_item, 1927 }; 1928 1929 $(document).trigger("addToCart", temp_product_array); 1930 1931 if (result["cart_success"] == 1) { 1932 $(document).trigger("addToCartSuccess", temp_product_array); 1933 1934 cart_add_fly(main_image); 1935 1936 $faultInVariants = false; 1937 } 1938 1939 if (result["finish_disabled"] != 1) { 1940 cart_add_finish(result, main_image); 1941 } 1942 } 1943 }); 1944 } 1945} 1946 1947var quick_order_in_progress = false; 1948function quick_order_start(eval_script) { 1949 cart_box_order(); 1950 quick_order_in_progress = true; 1951 1952 if (eval_script!="") { 1953 $(document).on("addToCartSuccessEnd",function() { 1954 location.href=unas_shop_url+"/shop_order_mods.php?quick_order=1"; 1955 }); 1956 eval(eval_script); 1957 } else { 1958 location.href=unas_shop_url+"/shop_order_mods.php?quick_order=1"; 1959 } 1960} 1961 1962function cart_box_order() { 1963 $(document).trigger("clickOrderButton", {id:"initiate",page:"cart_box"}); 1964} 1965 1966/*** PRODUCT PARAM INPUT ***/ 1967var product_param=[]; 1968var cust_input_file_exists=0; 1969 1970/*check customer inputs*/ 1971function check_cust_input(sku_orig,origin){ 1972 var has_error=0; 1973 var temp_values = []; 1974 cust_input_file_exists = 0; 1975 1976 let prefix = "#page_artdet_content " 1977 if (origin === "tooltip") { 1978 prefix = (unas_design_ver >= 5) ? "#page_tooltip " : "#page_PopupContainer_tooltip "; 1979 } 1980 1981 $(prefix+'.cust_input').each(function(){ 1982 var $this=$(this); 1983 var id=$this.attr("id"); 1984 var add_to_sku_only = $this.attr("data-add-to-sku-only"); 1985 var value=""; 1986 1987 $("#page_artdet_product_param_spec_"+id).removeClass("page_artdet_product_param_spec_fault"); 1988 $("#page_artdet_product_param_spec_"+id+"_value").removeClass("page_artdet_product_param_spec_fault"); 1989 $this.removeClass("is-invalid"); /*1900*/ 1990 1991 if($this.hasClass('cust_input_select')){ /*cust_input_select*/ 1992 value = $this.find("option:selected").val(); 1993 } else { /*cust_input_text or cust_input_file*/ 1994 value = $this.val(); 1995 if($this.hasClass("cust_input_file")) { 1996 $this.siblings(".custom-file-label").find(".form-control").removeClass("is-invalid"); 1997 if ( add_to_sku_only !== undefined && add_to_sku_only !== false) { /* param has 'add_to_sku_only' attribute */ 1998 if (add_to_sku_only === sku_orig) { /* attribute is equal with actual product which added to cart, set file upload exists ONLY to this! */ 1999 cust_input_file_exists = 1; 2000 } 2001 } else { 2002 cust_input_file_exists = 1; /* DEFAULT behavior, file upload exists */ 2003 } 2004 } 2005 } 2006 2007 if ($this.hasClass("required") && value === "") { 2008 has_error=1; 2009 $("#page_artdet_product_param_spec_"+id).addClass("page_artdet_product_param_spec_fault"); 2010 $("#page_artdet_product_param_spec_"+id+"_value").addClass("page_artdet_product_param_spec_fault"); 2011 $this.addClass("is-invalid").attr('aria-invalid','true'); 2012 $this.siblings(".custom-file-label").find(".form-control").addClass("is-invalid"); 2013 } 2014 if (value !== "") { 2015 if ( add_to_sku_only !== undefined && add_to_sku_only !== false) { /* param has 'add_to_sku_only' attribute */ 2016 if (add_to_sku_only === sku_orig) { /* attribute is equal with actual product which added to cart, so push parameter ONLY to this! */ 2017 temp_values.push(id+"¤"+value); 2018 } 2019 } else { 2020 temp_values.push(id+"¤"+value); /* DEFAULT behavior, param has no attribute */ 2021 } 2022 } 2023 }); 2024 2025 /*if there is no error in input params, temp array becomes real array */ 2026 if (has_error === 0) product_param = temp_values; 2027 2028 return has_error; 2029} 2030 2031/*** JS API ***/ 2032var UNAS = UNAS || {}; 2033 2034UNAS.data=new Array(); 2035function get_ajax_api(handleData,action,data) { 2036 if (UNAS.data[action]!=undefined && data=="") { 2037 handleData(UNAS.data[action]); 2038 } else { 2039 $.ajax({ 2040 type: "GET", 2041 async: true, 2042 dataType: 'json', 2043 url: shop_url_main+'/shop_ajax/api.php', 2044 data: { 2045 get_ajax:1, 2046 api_auth:UNAS.api_auth, 2047 action:action, 2048 data:data 2049 }, 2050 success: function(result) { 2051 UNAS.data[action]=result; 2052 handleData(UNAS.data[action]); 2053 } 2054 }); 2055 } 2056} 2057 2058function die(message = "") { 2059 throw(message); 2060} 2061 2062UNAS.onLoadPage = function (api_function) { $(document).on("loadPage",api_function); }; 2063 2064UNAS.onAddToCart = function (api_function) { $(document).on("addToCart",api_function); }; 2065UNAS.onRemoveFromCart = function (api_function) { $(document).on("removeFromCart",api_function); }; 2066UNAS.onModifyCart = function (api_function) { $(document).on("modifyCart",api_function); }; 2067UNAS.onEmptyCart = function (api_function) { $(document).on("emptyCart",api_function); }; 2068 2069UNAS.onClickOrderButton = function (api_function) { $(document).on("clickOrderButton",api_function); }; 2070UNAS.onClickProduct = function (api_function) { $(document).on("clickProduct",api_function); }; 2071 2072UNAS.onChangeProductQty = function (api_function) { $(document).on("changeProductQty",api_function); }; 2073UNAS.onChangeVariant = function (api_function) { $(document).on("changeVariant",api_function); }; 2074UNAS.onChangePaymentType = function (api_function) { $(document).on("changePaymentType",api_function); }; 2075UNAS.onChangeShippingType = function (api_function) { $(document).on("changeShippingType",api_function); }; 2076 2077UNAS.onGrantConsent = function (api_function) { $(document).on("grantConsent",api_function); };
2078UNAS.onRejectConsent = function (api_function) { $(document).on("rejectConsent",api_function); }; 2079 2080UNAS.onPopupOpen = function (api_function) { $(document).on("popupOpen",api_function); }; 2081UNAS.onOverlayOpen = function (api_function) { $(document).on("overlayOpen",api_function); }; 2082//UNAS.onOverlayAjaxLoaded = function (api_function) { $(document).on("overlayAjaxLoaded",api_function); }; 2083 2084//get 2085UNAS.getShop = function(handleData) { handleData(UNAS.shop); }; 2086UNAS.getCustomer = function(handleData) { get_ajax_api(handleData,"getCustomer",""); }; 2087UNAS.getCart = function(handleData,data) { get_ajax_api(handleData,"getCart",data); }; 2088UNAS.getOrder = function(handleData,data) { if (typeof UNAS.shop["last_order_key"] !== 'undefined') get_ajax_api(handleData,"getOrder",data); }; 2089UNAS.getProduct = function(handleData,data) { get_ajax_api(handleData,"getProduct",data); }; 2090 2091/*** RECAPTCHA ***/ 2092function recaptcha_load(render = "") { 2093 if ($("#recaptchaScript").length==0) { 2094 var head = document.getElementsByTagName('head')[0]; 2095 var recaptchaScript = document.createElement('script'); 2096 recaptchaScript.id = 'recaptchaScript'; 2097 recaptchaScript.type = 'text/javascript'; 2098 recaptchaScript.src = 'https://www.google.com/recaptcha/api.js?site_key=6Lfd5tEpAAAAAEkw2zgv0GdlNI3Sl7BApfgg4Pi_' + (render !== '' ? '&render=' + render : ""); 2099 head.appendChild(recaptchaScript); 2100 } 2101} 2102 2103/*** UTILITY ***/ 2104function embedObject(script_file,script_width,script_height) {
2105 document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"'+script_width+'\" height=\"'+script_height+'\" id=\"head_menu\">' + 2106 ' <param name=\"movie\" value=\"'+script_file+'\">' + 2107 ' <param name=\"quality\" value=\"high\">' + 2108 ' <param name=\"wmode\" value=\"opaque\">' + 2109 ' <embed src=\"'+script_file+'\" quality=\"high\" wmode=\"opaque\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"'+script_width+'\" height=\"'+script_height+'\"></embed>' + 2110 ' </object>'); 2111 2112} 2113 2114function embedObject_trans(script_file,script_width,script_height) { 2115 document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"'+script_width+'\" height=\"'+script_height+'\" id=\"head_menu\">' + 2116 ' <param name=\"movie\" value=\"'+script_file+'\">' + 2117 ' <param name=\"quality\" value=\"high\">' + 2118 ' <param name=\"wmode\" value=\"transparent\">' + 2119 ' <embed src=\"'+script_file+'\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"'+script_width+'\" height=\"'+script_height+'\"></embed>' + 2120 ' </object>'); 2121 2122} 2123 2124///////////////////////////////////////////////////////////////////// 2125//tinymce media embed 2126 2127function writeFlash(p) { 2128 writeEmbed( 2129 'D27CDB6E-AE6D-11cf-96B8-444553540000', 2130 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', 2131 'application/x-shockwave-flash', 2132 p 2133 ); 2134} 2135 2136function writeShockWave(p) { 2137 writeEmbed( 2138 '166B1BCA-3F9C-11CF-8075-444553540000', 2139 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0', 2140 'application/x-director', 2141 p 2142 ); 2143} 2144 2145function writeQuickTime(p) { 2146 writeEmbed( 2147 '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B', 2148 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0', 2149 'video/quicktime', 2150 p 2151 ); 2152} 2153 2154function writeRealMedia(p) { 2155 writeEmbed( 2156 'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA', 2157 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0', 2158 'audio/x-pn-realaudio-plugin', 2159 p 2160 ); 2161} 2162 2163function writeWindowsMedia(p) { 2164 p.url = p.src; 2165 writeEmbed( 2166 '6BF52A52-394A-11D3-B153-00C04F79FAA6', 2167 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701', 2168 'application/x-mplayer2', 2169 p 2170 ); 2171} 2172 2173function writeEmbed(cls, cb, mt, p) { 2174 var h = '', n; 2175 2176 h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"'; 2177 h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : ''; 2178 h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : ''; 2179 h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : ''; 2180 h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : ''; 2181 h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : ''; 2182 h += '>'; 2183 2184 for (n in p) 2185 h += '<param name="' + n + '" value="' + p[n] + '">'; 2186 2187 h += '<param name="wmode" value="opaque">'; 2188 h += '<embed type="' + mt + '"'; 2189 2190 for (n in p) 2191 h += n + '="' + p[n] + '" '; 2192 2193 h += 'wmode="opaque" '; 2194 h += '></embed></object>'; 2195 2196 document.write(h); 2197} 2198 2199/*** QUESTION ***/ 2200function question_send(cikk) { 2201 let successMessageEl = $("#recommend_error_msg"); 2202 if (unas_design_ver >= 5) { 2203 successMessageEl = $("#question-success-message"); 2204 successMessageEl.addClass('d-none'); 2205 } else { 2206 successMessageEl.hide(); 2207 } 2208 $.ajax({ 2209 type: "POST", 2210 url: unas_shop_url+"/shop_question.php", 2211 data: "get_ajax=1&change_lang="+actual_lang+"&action=send&cikk="+cikk+"&question_name="+$("#question_name").val()+"&question_email="+$("#question_email").val()+"&question_phone="+$("#question_phone").val()+"&question_message="+$("#question_message").val()+"&question_privacy_policy="+$("#question_privacy_policy").prop("checked")+"&recaptcha_response="+grecaptcha.getResponse(recaptcha_id_question), 2212 dataType: 'json', 2213 success: function (result) { 2214 for (const field in result) { 2215 if (result.hasOwnProperty(field) && field !== "status") { // Ne vizsgáljuk a 'status' mezőt, mert ez hibajelző flag 2216 const fieldValue = result[field]; 2217 const fieldElement = $('#question_' + field); 2218 2219 if (fieldValue === 1) { 2220 fieldElement.removeClass("recommend_fault is-invalid"); 2221 fieldElement.closest(".recommend_label_input").removeClass("recommend_label_fault"); 2222 } else { 2223 fieldElement.addClass("recommend_fault is-invalid"); 2224 fieldElement.closest(".recommend_label_input").addClass("recommend_label_fault"); 2225 } 2226 } 2227 } 2228 2229 if(result.status=="ok") { 2230 $(document).trigger("questionSent"); 2231 2232 if (google_analytics==1) gtag("event", "question_sent", { }); 2233 if (facebook_pixel==1) fbq('track', 'Contact'); 2234 2235 if (unas_design_ver >= 5) { 2236 successMessageEl.removeClass('d-none'); 2237 2238 setTimeout(function () { 2239 $.shop_popup("close"); 2240 }, 1500); 2241 } else { 2242 successMessageEl.show(500, function () { 2243 setTimeout(function () { 2244 $.shop_popup("close"); 2245 }, 1500); 2246 }); 2247 } 2248 } 2249 } 2250 }); 2251} 2252 2253function popup_question_dialog(cikk) { 2254 recaptcha_load(); 2255 2256 var temp_ajax_data="cikk="+cikk+"&change_lang="+actual_lang+"&get_ajax=1"; 2257 if (typeof config_plus['unas_design']!=='undefined') temp_ajax_data=temp_ajax_data+"&unas_design="+config_plus['unas_design']; 2258 2259 $.shop_popup("open",{ 2260 ajax_url:unas_shop_url+"/shop_question.php", 2261 ajax_data:temp_ajax_data, 2262 width: 580, 2263 height: 420, 2264 modal:0.6, 2265 popupId:'question', 2266 class:"shop_popup_question shop_popup_artdet", 2267 overflow: "auto" 2268 }); 2269} 2270 2271function get_url_param(name){ 2272 let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 2273 if (results === null) return null; 2274 2275 try { 2276 return decodeURI(results[1]); 2277 } catch(e) { 2278 return 0; 2279 } 2280} 2281 2282function loadPlusPage(config) { 2283 let ajax_url = UNAS.shop.base_url+"/shop_ajax/ajax_content.php"; 2284 if (service_type=="cms") ajax_url=UNAS.shop.base_url+"/ajax/ajax_content.php"; 2285 2286 let url_state = UNAS.shop.canonical_url; 2287 2288 if (url_state !== "") { 2289 if (!$.isEmptyObject(config.dataFilter)) { 2290 url_state += url_state.indexOf("?") === -1 ? "?" : "&"; 2291 url_state += "filter_tags=[" + Object.values(config.dataFilter).join(",") + "]"; 2292 } 2293 2294 if (config.type === "load_more_content") { 2295 url_state += url_state.indexOf("?") === -1 ? "?" : "&"; 2296 url_state += "infinite_page=" + config.page_act; 2297 } 2298 2299 history.replaceState("", "", url_state); 2300 } 2301 2302 $.ajax({ 2303 type: "POST", 2304 url: ajax_url, 2305 data: { 2306 change_lang: actual_lang, 2307 get_ajax: 1, 2308 action: "filter", 2309 page: config.page_id, 2310 ajax_nodesign: 1, 2311 ajax_nodesign_element_render: 1, 2312 shop_id: shop_id, 2313 filter_tags: config.dataFilter, 2314 page_act_ajax: config.page_act, 2315 ajax_paging: config.type === "load_more_content" ? 1 : 0, 2316 url_state: url_state 2317 }, 2318 beforeSend: config.type === "load_more_content" ? "" : function () { 2319 $("."+config.filter_el_wrapper).addClass('loading').html(""); 2320 $(document).trigger("filterByTagLoading",{ 2321 filter_tags:$("."+config.filter_wrapper), 2322 filterable_elements:$("."+config.filter_el_wrapper), 2323 filtered_tags: config.dataFilter, 2324 page_id: config.page_id 2325 }); 2326 }, 2327 success: function (response) { 2328 if (url_state !== "") { 2329 history.replaceState("", "", url_state); 2330 } 2331 2332 if (config.type === "load_more_content") { 2333 let wrapper = $('.js-load-more-content'); 2334 2335 wrapper.before(response); 2336 $('.js-load-more-content-spinner').removeClass('is-visible'); 2337 2338 if (config.page_act !== config.page_max) { 2339 $(config.btn).attr('data-page-next', config.page_act + 1).removeClass('disabled').prop('disabled', false); 2340 } else { 2341 wrapper.addClass('d-none'); 2342 } 2343 } 2344 2345 if (config.type === "filter") { 2346 $("." + config.filter_el_wrapper).removeClass('loading').html(response); 2347 2348 document.dispatchEvent(new CustomEvent("filterByTagLoaded", { 2349 detail: { 2350 filter_tags: config.filter_wrapper, 2351 filterable_elements: config.filter_el_wrapper, 2352 filtered_tags: config.dataFilter, 2353 page_id: config.page_id 2354 } 2355 })); 2356 } 2357 2358 if ($('.page_content_with_form_type').length > 0) { 2359 $('.page_content_with_form_type form').each(function () { 2360 if ($('input[name="success_url"]', this).length === 0) { 2361 $(this).find('input[name="back_url"]').attr('value', url_state); 2362 } 2363 }); 2364 } 2365 2366 if ($('.page_content--blog').length > 0) { 2367 $('.js-filterable-elements-wrapper').addClass('blog-list has-blog-list'); 2368 } 2369 } 2370 }); 2371} 2372 2373function loadMoreContent(btn) { 2374 let el = $(btn); 2375 el.addClass('disabled').prop('disabled',true); 2376 $('.js-load-more-content-spinner').addClass('is-visible'); 2377 2378 let dataFilter = {}; 2379 2380 $(".js-active-filter").each(function(index, el) { 2381 dataFilter[index] = $(el).attr("data-filter").replace("js-filterable-","").replace("js-fitlerable-"); 2382 }); 2383 2384 loadPlusPage({ 2385 type: "load_more_content", 2386 dataFilter: dataFilter, 2387 page_id: UNAS.shop.page_id, 2388 page_act: parseInt(el.attr('data-page-next')), 2389 page_max: parseInt(el.attr('data-page-max')), 2390 btn: el 2391 }); 2392} 2393 2394let galleryFilesLoaded = false;
2395async function loadGalleryFiles() { 2396 if (galleryFilesLoaded) return; 2397 2398 if (!galleryFilesLoaded) { 2399 let promises = []; 2400 2401 let pswpAssets = [ 2402 unas_shop_url + "/!common_packages/jquery/plugins/photoswipe/css/default-skin.min.css", 2403 unas_shop_url + "/!common_packages/jquery/plugins/photoswipe/css/photoswipe.min.css", 2404 unas_shop_url + "/!common_packages/jquery/plugins/photoswipe/photoswipe.min.js", 2405 unas_shop_url + "/!common_packages/jquery/plugins/photoswipe/photoswipe-ui-default.min.js" 2406 ]; 2407 2408 let flickityAssets = [ 2409 unas_shop_url + "/!common_packages/jquery/plugins/flickity/v3/flickity.min.css", 2410 unas_shop_url + "/!common_packages/jquery/plugins/flickity/v3/flickity.pkgd.min.js" 2411 ] 2412 2413 if (typeof Flickity === 'undefined') { 2414 $(flickityAssets).each(function (key, value) { 2415 promises.push( loadResourceFile(value, value.includes('.css') ? "style" : "script") ); 2416 }); 2417 } 2418 2419 if (typeof PhotoSwipe === 'undefined') { 2420 $(pswpAssets).each(function (key, value) { 2421 promises.push( loadResourceFile(value, value.includes('.css') ? "style" : "script") ); 2422 }); 2423 } 2424 2425 await Promise.all(promises); 2426 2427 galleryFilesLoaded = true; 2428 } 2429} 2430 2431function loadResourceFile(url, type) { 2432 return new Promise((resolve, reject) => { 2433 let el; 2434 2435 if (type === "script") { 2436 el = document.createElement('script'); 2437 el.src = url; 2438 el.type = 'text/javascript'; 2439 } else { 2440 el = document.createElement('link'); 2441 el.rel = 'stylesheet'; 2442 el.type = 'text/css'; 2443 el.href = url; 2444 } 2445 2446 el.onload = () => resolve(el); 2447 el.onerror = () => reject(new Error(`Failed to load: ${url}`)); 2448 2449 document.head.appendChild(el); 2450 }); 2451} 2452 2453function initPhotoSwipeFromDOMGallery(datas) { 2454 var $pswp = $(".pswp")[0]; 2455 var $psDatas = $(datas); 2456 2457 $psDatas.each( function() { 2458 var $pics = $(this), 2459 getItems = function() { 2460 var items = []; 2461 $pics.find("a").each(function() { 2462 var $this = $(this); 2463 var $href = $this.attr("href"), 2464 $size = $this.data("size").split("x"), 2465 $width = $size[0], 2466 $height = $size[1], 2467 $title = $this.data("caption") 2468 2469 var item = { 2470 src : $href, 2471 w : $width, 2472 h : $height, 2473 title: $title 2474 }; 2475 2476 items.push(item); 2477 }); 2478 return items; 2479 }; 2480 2481 var items = getItems(); 2482 2483 $(".gallery__img-link", $pics).on('click', async function(event) { 2484 event.preventDefault(); 2485 2486 await loadGalleryFiles(); 2487 2488 var $index = $(this).index(); 2489 var options = { 2490 index: $index, 2491 history: false, 2492 bgOpacity: 0.8, 2493 preventHide: true, 2494 shareEl: false, 2495 showHideOpacity: true, 2496 getDoubleTapZoom: function(isMouseClick, item) { 2497 if(isMouseClick) { 2498 return 1; 2499 } else { 2500 return item.initialZoomLevel < 0.7 ? 1 : 1.5; 2501 } 2502 }, 2503 addCaptionHTMLFn: function(item, captionEl, isFake) { 2504 if(!item.title) { 2505 captionEl.children[0].innerText = ""; 2506 return false; 2507 } 2508 captionEl.children[0].innerHTML = item.title; 2509 return true; 2510 } 2511 }; 2512 2513 var photoSwipe = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options); 2514 2515 2516 if (config_plus['accessible_design']) { 2517 photoSwipe.listen('afterInit', () => { 2518 $pswp.removeAttribute("aria-hidden"); 2519 const handleFocusOut = (e) => { 2520 const newFocusTarget = e.relatedTarget; 2521 2522 if (newFocusTarget && !$pswp.contains(newFocusTarget)) { 2523 photoSwipe.close(); 2524 } 2525 }; 2526 $pswp.addEventListener('focusout', handleFocusOut); 2527 photoSwipe.listen('destroy', () => { 2528 $pswp.removeEventListener('focusout', handleFocusOut); 2529 announceToScreenReader?.('modalClose'); 2530 }); 2531 }); 2532 photoSwipe.listen('close', () => { 2533 if (UNAS.design.active_element && typeof UNAS.design.active_element.focus === 'function') { 2534 UNAS.design.active_element.focus(); 2535 UNAS.design.active_element = null; 2536 } 2537 setTimeout(() => { 2538 $pswp.setAttribute("aria-hidden", "true"); 2539 }, 100); 2540 }); 2541 } 2542 2543 photoSwipe.init(); 2544 }); 2545 2546 }); 2547} 2548 2549$(document).on('click', '.faq-container.is-accordion .js-faq-title', function () { 2550 $(this).toggleClass('active').attr('aria-expanded',($(this).hasClass('active') ? "true" : "false")); 2551 $('.js-faq-content[data-id="' + $(this).data('id') + '"]').slideToggle(); 2552}); 2553 2554function openIntelligentContent(params) { 2555 if ($.type(params) === 'object'){ 2556 if (params['appearance'] === "offcanvas") { 2557 loadExitpopupOffcanvas(params); 2558 } else { 2559 $.shop_popup("open", { 2560 ajax_url: shop_url_main + "/shop_ajax/ajax_exitpopup.php", 2561 ajax_data: "offer_id=" + params['id'] + "&change_lang=" + actual_lang + "&get_ajax=1", 2562 ajax_loader: false, 2563 width: "content", 2564 height: "content", 2565 offsetWidth: -19, 2566 offsetHeight: -99, 2567 offsetMaxWidth: -70, 2568 offsetMaxHeight: -70, 2569 modal: 0.6, 2570 contentId: "page_exitpopup", 2571 exposeMaskID: "exposeMaskExitpopup", 2572 popupId: "exitpopup", 2573 class: "shop_popup_exitpopup exitpopup-type-" + params['type'], 2574 overflow: "hidden", 2575 id: "PopupContainer", 2576 closeEsc: !params['close_restrict_esc'], 2577 closeClick: !params['close_restrict_click'] 2578 }); 2579 2580 if (!params['close_restrict_x']) { 2581 if (unas_design_ver >= 5) {
2582 $("#modal-exitpopup").removeClass("without-close-button"); 2583 } else { 2584 $(".shop_popup_exitpopup a.close").css("display", "block"); 2585 } 2586 } else { 2587 if (unas_design_ver >= 5) { 2588 $("#modal-exitpopup").addClass("without-close-button"); 2589 } else { 2590 $(".shop_popup_exitpopup a.close").css("display", "none"); 2591 } 2592 } 2593 } 2594 2595 if (params['google_analytics']) { 2596 gtag("event", "intelligent_popup_show", { 2597 'offer_id': params['id'] 2598 }); 2599 } 2600 } 2601} 2602 2603var offcanvasExitpopup; 2604function loadExitpopupOffcanvas(params) { 2605 $.ajax({ 2606 type: "GET", 2607 url: shop_url_main + "/shop_ajax/ajax_exitpopup.php", 2608 data: { 2609 offer_id: params['id'], 2610 change_lang: actual_lang, 2611 get_ajax: 1, 2612 action: params['action'] 2613 }, 2614 success: function(result) { 2615 let timeout = 300; 2616 if ($("#offcanvas-exitpopup").length < 1) { 2617 let offcanvasContent = `<div class="offcanvas" tabindex="-1" id="offcanvas-exitpopup" aria-labelledby="offcanvas-exitpopup-label"></div>`; 2618 $('#offcanvases').append(offcanvasContent); 2619 offcanvasExitpopup = new bootstrap.Offcanvas(document.getElementById("offcanvas-exitpopup")); 2620 timeout = 0; 2621 } 2622 2623 $("#offcanvas-exitpopup").removeClass('offcanvas-start offcanvas-end offcanvas-top offcanvas-bottom').attr('data-type', params['type']).attr('data-id', params['id']).addClass('offcanvas-' + params['direction']).html(result); 2624 if (params['max_width'] !== "") { 2625 $("#offcanvas-exitpopup").attr('style', '--max-width: '+params['max_width']+'px;').attr('data-max-width', params['max_width']); 2626 } else { 2627 $("#offcanvas-exitpopup").removeAttr('style').removeAttr('data-max-width'); 2628 } 2629 2630 setTimeout(function(){ 2631 offcanvasExitpopup.show(); 2632 }, timeout); 2633 } 2634 }); 2635 2636 if (params['google_analytics']) { 2637 gtag("event", "intelligent_popup_show", { 2638 'offer_id': params['id'] 2639 }); 2640 } 2641} 2642 2643$(document).on('click', '.js-pic-zoom', function(){ 2644 openZoom(this); 2645}); 2646 2647function openZoom(image) { 2648 let rect = image.getBoundingClientRect(); 2649 2650 let overlay = document.createElement('div'); 2651 overlay.className = 'pic-zoom-overlay'; 2652 2653 Object.assign(overlay.style, { 2654 position: 'fixed', 2655 inset: '0', 2656 zIndex: '10050', 2657 background: 'rgba(0, 0, 0, 0)', 2658 transition: 'background 300ms ease', 2659 cursor: 'zoom-out', 2660 display: 'block' 2661 }); 2662 2663 let clone = image.cloneNode(true); 2664 clone.classList = ''; 2665 2666 Object.assign(clone.style, { 2667 position: 'fixed', 2668 zIndex: '10051', 2669 margin: '0', 2670 left: `${rect.left}px`, 2671 top: `${rect.top}px`, 2672 width: `${rect.width}px`, 2673 height: `${rect.height}px`, 2674 objectFit: getComputedStyle(image).objectFit || 'cover', 2675 transition: 'all 400ms cubic-bezier(0.22, 1, 0.36, 1)', 2676 cursor: 'zoom-out', 2677 display: 'block' 2678 }); 2679 2680 let naturalWidth = image.naturalWidth; 2681 let naturalHeight = image.naturalHeight; 2682 2683 let aspectRatio = 2684 naturalWidth && naturalHeight 2685 ? naturalWidth / naturalHeight 2686 : rect.width / rect.height; 2687 2688 let maxWidth = window.innerWidth * 0.9; 2689 let maxHeight = window.innerHeight * 0.9; 2690 2691 let targetWidth = naturalWidth; 2692 let targetHeight = naturalHeight; 2693 2694 if (targetWidth > maxWidth || targetHeight > maxHeight) { 2695 let scale = Math.min( 2696 maxWidth / targetWidth, 2697 maxHeight / targetHeight 2698 ); 2699 2700 targetWidth *= scale; 2701 targetHeight *= scale; 2702 } 2703 2704 if (!targetWidth || !targetHeight) { 2705 targetWidth = Math.min(rect.width * 2, maxWidth); 2706 targetHeight = targetWidth / aspectRatio; 2707 } 2708 2709 let targetLeft = (window.innerWidth - targetWidth) / 2; 2710 let targetTop = (window.innerHeight - targetHeight) / 2; 2711 2712 overlay.appendChild(clone); 2713 document.body.appendChild(overlay); 2714 2715 document.body.style.overflow = 'hidden'; 2716 2717 requestAnimationFrame(() => { 2718 overlay.style.background = 'rgba(0, 0, 0, 0.45)'; 2719 2720 Object.assign(clone.style, { 2721 left: `${targetLeft}px`, 2722 top: `${targetTop}px`, 2723 width: `${targetWidth}px`, 2724 height: `${targetHeight}px` 2725 }); 2726 }); 2727
2728 let closeZoom = (event) => { 2729 event?.stopPropagation(); 2730 2731 overlay.style.background = 'rgba(0, 0, 0, 0)'; 2732 2733 Object.assign(clone.style, { 2734 left: `${rect.left}px`, 2735 top: `${rect.top}px`, 2736 width: `${rect.width}px`, 2737 height: `${rect.height}px` 2738 }); 2739 2740 clone.addEventListener( 2741 'transitionend', 2742 () => { 2743 overlay.remove(); 2744 document.body.style.overflow = ''; 2745 }, 2746 {once: true} 2747 ); 2748 2749 setTimeout(() => { 2750 if (overlay.parentNode) { 2751 overlay.remove(); 2752 document.body.style.overflow = ''; 2753 } 2754 }, 500); 2755 }; 2756 2757 overlay.addEventListener('click', closeZoom); 2758 clone.addEventListener('click', closeZoom); 2759 2760 let handleEscape = (event) => { 2761 if (event.key === 'Escape') { 2762 closeZoom(event); 2763 document.removeEventListener('keydown', handleEscape); 2764 } 2765 }; 2766 2767 document.addEventListener('keydown', handleEscape); 2768}
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.