1var initAECC = function($,showModal){ 2 3 4 //para llamar a la función para que se muestre el layer con textos 5 // showModal("hola","desc"); 6 7 8 // if(aedecT == "actividades"){ 9 // showModal("Aviso","Debido a la situación de crisis que estamos viviendo por el COVID-19, estamos trabajando en un calendario de eventos online que pondremos a vuestra disposición próximamente"); 10 // } 11 12 13 14 console.log("init common"); 15 16 if($(".logged").length > 0){ 17 $(".logged").on('click',function(e){ 18 if (lang_code=="es"){ 19 window.location="/es/area-privada/" 20 } 21 }); 22 } 23 24 25 //#### TIENDA PASO 1 26 if($("#frmTiendaPaso1").length > 0){ 27 //CARGAMOS EL CARRITO 28 //alert("load:::"+load_carrito); 29 if(customer_type && customer_type != "undefined"){ 30 $("input[name=tipo_cliente][value=" + customer_type + "]").prop('checked', true); 31 } 32 //$("input[name='tipo_cliente'] option[value='"+customer_type+"']").attr("checked",true);//hora_publicacion SELECT 33 34 var v = $("input[name='tipo_cliente']:checked").val(); 35 36 console.log("Tipo cliente = "+v); 37 console.log("customer_type ==="+customer_type); 38 $.post("/getCart",{tc:v},function(data){ 39 var json; 40 try{ 41 json = eval("("+data+")"); 42 }catch(e){ 43 json={error:0}; 44 } 45 //alert(json.error); 46 //typeof json =="object" && 47 if(json.error == 1){ 48 $(".cesta-compra").html(''); 49 showModal(cart_error_1_title,cart_error_1_msg); 50 } 51 else{ 52 $(".cesta-compra").html(data); 53 } 54 }); 55 56 57 //CHANGE DEL COMBO DE TIPO CLIENTE 58 59 $("input[name='tipo_cliente']").on('click',function(e){ 60 //e.preventDefault(); 61 var v = $("input[name='tipo_cliente']:checked").val(); 62 console.log("Tipo cliente = "+v); 63 console.log("customer_type ==="+customer_type); 64 65 if(v!=""){ //&& v != customer_type 66 $.post("/getCart",{tc:v},function(data){ 67 var json; 68 try{ 69 json = eval("("+data+")"); 70 }catch(e){ 71 json={error:0}; 72 } 73 //alert(json.error); 74 //typeof json =="object" && 75 if(json.error == 1){ 76 $(".cesta-compra").html(''); 77 showModal(cart_error_1_title,cart_error_1_msg); 78 } 79 else{ 80 $(".cesta-compra").html(data); 81 } 82 }); 83 } 84 else{ 85 $(".cesta-compra").html(''); 86 showModal(cart_error_2_title,cart_error_2_msg); 87 } 88 //return false; 89 }); 90 //BOTON MAS o MENOS EN EL CARRITO //carrito_content debe exisitr en el pageload y luego delegamos en el click dinamico 91 $('.publicaciones__shop__content').on('click', '[id^="mas_"]', function(e){ 92 //$('.cesta-compra').on("click", "[id^='mas_']", function(e){ 93 console.log("Click en MAS"); 94 e.preventDefault(); 95 var v = $.trim($(this).attr('id')); 96 console.log(v); 97 arr_v = v.split("_"); 98 if($.trim(arr_v[1])!=""){ 99 cur_cant = $("#cantidad_"+arr_v[1]).val(); 100 next_cant = parseInt(cur_cant,10)+1; 101 if(next_cant <=999){ 102 103 $("#cantidad_"+arr_v[1]).val(next_cant); 104 $.post("/addToCart/",{i:arr_v[1],o:"mas"},function(data){ 105 json = eval("("+data+")"); 106 if(json.error==1){ 107 showModal(cart_error_1_title,cart_error_1_msg); 108 } 109 else{ 110 //v = $("#tipo_cliente").val(); 111 v = $("input[name='tipo_cliente']:checked").val(); 112 //alert("tipo_cliente:::"+v); 113 $.post("/getCart",{tc:v},function(data){ 114 var json; 115 try{ 116 json = eval("("+data+")"); 117 }catch(e){ 118 json={error:0}; 119 } 120 //alert(json.error); 121 //typeof json =="object" && 122 if(json.error == 1){ 123 $(".cesta-compra").html(''); 124 showModal(cart_error_1_title,cart_error_1_msg); 125 } 126 else{ 127 $(".cesta-compra").html(data); 128 } 129 });
130 } 131 132 }); 133 } 134 } 135 return false; 136 }); 137 138 //menos_ 139 $('.publicaciones__shop__content').on('click', '[id^="menos_"]', function(e){ 140 //$('.cesta-compra').on("click", "[id^='menos_']", function(e){ 141 console.log("Click en MENOS"); 142 e.preventDefault(); 143 var v = $.trim($(this).attr('id')); 144 console.log(v); 145 arr_v = v.split("_"); 146 if($.trim(arr_v[1])!=""){ 147 cur_cant = $("#cantidad_"+arr_v[1]).val(); 148 next_cant = parseInt(cur_cant,10)-1; 149 if(next_cant >= 0){ 150 151 $("#cantidad_"+arr_v[1]).val(next_cant); 152 $.post("/addToCart/",{i:arr_v[1],o:"menos"},function(data){ 153 json = eval("("+data+")"); 154 if(json.error==1){ 155 showModal(cart_error_1_title,cart_error_1_msg); 156 } 157 else{ 158 //v = $("#tipo_cliente").val(); 159 v = $("input[name='tipo_cliente']:checked").val(); 160 //alert("tipo_cliente:::"+v); 161 $.post("/getCart",{tc:v},function(data){ 162 var json; 163 try{ 164 json = eval("("+data+")"); 165 }catch(e){ 166 json={error:0}; 167 } 168 //alert(json.error); 169 //typeof json =="object" && 170 if(json.error == 1){ 171 $(".cesta-compra").html(''); 172 showModal(cart_error_1_title,cart_error_1_msg); 173 } 174 else{ 175 $(".cesta-compra").html(data); 176 } 177 });
178 } 179 180 }); 181 } 182 } 183 return false; 184 }); 185 186 } 187 188 //#### TIENDA PASO 2 189 if($("#frmTiendaPaso2").length > 0){ 190 console.log(parseInt(formStep2_factura)); 191 if(parseInt(formStep2_factura) == 1){$("#invoiceBlock").toggle('slow');console.log("trigger click");} 192 193 var countrySel = $('#pais').val(); 194 var countrySelRel = $('#pais').find('option:selected').attr("rel"); 195 if(parseInt(countrySel) == 1){ 196 $("#provincia").prop('required',true); 197 } 198 199 var countryFacSel = $('#paisfactura').val(); 200 console.log("countryFacSel="+countryFacSel); 201 var countryFacSelRel = $('#paisfactura').find('option:selected').attr("rel"); 202 console.log("countryFacSelRel==="+countryFacSelRel); 203 if(parseInt(countryFacSel) == 1 && $("#factura").cheked){ 204 $("#provinciafactura").prop('required',true); 205 } 206 //DESPLEGADO DEL OTRO FORMULARIO 207 $("#factura").click(function(e){ 208 209 invoiceChecked = this.checked; 210 var requiredValue = false; 211 if(invoiceChecked){ 212 requiredValue = true; 213 } 214 215 $("#nombrefactura").prop('required',requiredValue); 216 $("#cifnif_factura").prop('required',requiredValue); 217 $("#direccionfactura").prop('required',requiredValue); 218 $("#cpfactura").prop('required',requiredValue); 219 $("#localidadfactura").prop('required',requiredValue); 220 $("#paisfactura").prop('required',requiredValue); 221 222 223 224 $("#invoiceBlock").toggle('slow'); 225 //vaciamos los valores 226 if($("#nombrefactura").val() == "" && $("#cifnif_factura").val() == "" && $("#direccionfactura").val() == "" && $("#cpfactura").val() == "" && $("#localidadfactura").val() == "" ){ 227 $("#nombrefactura").val(''); 228 $("#cifnif_factura").val(''); 229 $("#direccionfactura").val(''); 230 $("#cpfactura").val(''); 231 $("#localidadfactura").val(''); 232 233 $("#paisfactura option[value='"+$("#paisfactura").val()+"']").attr("selected",fal
233se); 234 $("#paisfactura option[value='']").attr("selected",true); 235 236 $("#provinciafactura option[value='"+$("#provinciafactura").val()+"']").attr("selected",false); 237 $("#provinciafactura option[value='']").attr("selected",true); 238 239 } 240 241 }); 242 243 $("#factura_coincide").click(function(e){ 244 if(this.checked){ 245 $("#nombrefactura").val($("#empresa").val()); 246 $("#cifnif_factura").val($("#cifnif").val()); 247 $("#direccionfactura").val($("#direccion").val()); 248 $("#cpfactura").val($("#cp").val()); 249 $("#localidadfactura").val($("#localidad").val()); 250 251 $("#paisfactura option[value='"+$("#paisfactura").val()+"']").attr("selected",false); 252 $("#paisfactura option[value='"+$('#pais').val()+"']").attr("selected",true); 253 254 $("#provinciafactura option[value='"+$("#provinciafactura").val()+"']").attr("selected",false); 255 $("#provinciafactura option[value='"+$('#provincia').val()+"']").attr("selected",true); 256 } 257 }); 258 259 $('form[id^="frmTiendaPaso2"]').on("submit",function(e) { 260 e.preventDefault(); 261 console.log("submit frm:::"+$(this).attr("id"));//desktop o mobile 262 var thtFrm = $(this); 263 //comprobamos si el formulario esta validado via HTML5 264 if( thtFrm.get(0).checkValidity() ){ 265 console.log("Form OK"); 266 $(".msg-error").html(""); 267 268 $.ajax({type:'POST' 269 ,url : root_path + 'saveCartContent/' 270 ,dataType: 'json' //si loponemos asi, no hace falta hacer el eval de la respuesta 271 ,data: thtFrm.serialize() 272 ,success: function(data){ 273 //alert(data.toSource()); 274 var num_error = (typeof data.num_error!="undefined" && null!=data.num_error) ? parseInt(data.num_error,10) : -1; 275 var title_error = (typeof data.result_title!="undefined" && null!=data.result_title) ? $.trim(data.result_title) : ''; 276 var msg_error = (typeof data.result_msg!="undefined" && null!=data.result_msg) ? $.trim(data.result_msg) : ''; 277 278 if(num_error == 0){ 279 document.location.href = $("#btnStep3").attr("href"); 280 }else{ 281 282 //QUITAMOS LOADING Y MOSTRAMOS MENSAJE DE RESPUESTA 283 //1) funcion que quita el loading y resetea el form si todo ok 284 var resetF = function(){ 285 //alert("num_error::" + num_error); 286 if(num_error==0){ //TODO OK,borramos el formulario 287 thtFrm.get(0).reset(); //TAMBIEN VALE thtFrm[0].reset(); 288 } 289 //$(document).loading('LoaderOut'); 290 } 291 //2) function que lanza el mensaje de respuesta 292 var showAlert = function (){ 293 showModal(title_error,msg_error); 294 } 295 //3) ejecucion de las fucniones en elintervalo de tiempo especificado 296 var funcs = [resetF, showAlert], 297 i = 0, 298 timer = setInterval(callFuncs, 200); 299 300 function callFuncs() { 301 funcs[i++](); 302 if (i === funcs.length) clearInterval(timer); 303 } 304 } 305 } 306 }); 307 308 }else{ 309 console.log("Form KO"); 310 $(".msg-error").html(formStep2_error); 311 } 312 }); 313 //BOTON DE ENVIO DE LA INFORMACION 314 $("#btnStep3").click(function(e){ 315 e.preventDefault(); 316 $("#envioPaso2").trigger("click"); 317 //$("#frmTiendaPaso2").submit(); 318 return false; 319 }); 320 321 $('#pais').on("change",function(e) { 322 countrySel = $(this).val(); 323 var elementOptionSel = $(this).find('option:selected'); 324 countrySelRel = elementOptionSel.attr("rel"); 325 $("#provincia").prop('required',false); 326 if(parseInt(countrySel) == 1){ 327 $("#provincia").prop('required',true); 328 } 329 330 if(parseInt(countrySelRel) == 0){ 331 $("#recogida_0").prop('checked', true); 332 } 333 if(parseInt(countrySelRel) == 2){ 334 $("#recogida_3").prop('checked', true); 335 } 336 if(parseInt(countrySelRel) == 3){ 337 $("#recogida_4").prop('checked', true); 338 } 339 }); 340 $('#provincia').on("change",function(e) { 341 provinceSel = $(this).val(); 342 if(parseInt(countrySel) == 1 && (parseInt(provinceSel) == 35 || parseInt(provinceSel) == 38)){ 343 $("#recogida_1").prop('checked', true); 344 } 345 }); 346 347 $('#paisfactura').on("change",function(e) { 348 countryFacSel = $(this).val(); 349 var elementOptionSel = $(this).find('option:selected'); 350 countryFacSelRel = elementOptionSel.attr("rel"); 351 $("#provinciafactura").prop('required',false); 352 if(parseInt(countryFacSel) == 1){ 353 $("#provinciafactura").prop('required',true); 354 } 355 }); 356 357 358 } 359 360 361 //#### TIENDA PASO 3 362 if($("#frmTiendaPaso3").length > 0){ 363 $('form[id^="frmTiendaPaso3"]').on("submit",function(e) { 364 e.preventDefault(); 365 console.log("submit frm:::"+$(this).attr("id"));//desktop o mobile 366 var thtFrm = $(this); 367 //comprobamos si el formulario esta validado via HTML5 368 if( thtFrm.get(0).checkValidity() ){ 369 console.log("Form OK"); 370 $(".msg-error").html(""); 371 372 $.ajax({type:'POST' 373 ,url : root_path + 'createOrder/' 374 ,dataType: 'json' //si loponemos asi, no hace falta hacer el eval de la respuesta 375 ,data: thtFrm.serialize() 376 ,success: function(data){ 377 //alert(data.toSource()); 378 var num_error = (typeof data.num_error!="undefined" && null!=data.num_error) ? parseInt(data.num_error,10) :
378-1; 379 var title_error = (typeof data.result_title!="undefined" && null!=data.result_title) ? $.trim(data.result_title) : ''; 380 var msg_error = (typeof data.result_msg!="undefined" && null!=data.result_msg) ? $.trim(data.result_msg) : ''; 381 382 if(num_error == 0){ 383 document.location.href = $("#finalizar_pedido").attr("href"); 384 }else{ 385 386 //QUITAMOS LOADING Y MOSTRAMOS MENSAJE DE RESPUESTA 387 //1) funcion que quita el loading y resetea el form si todo ok 388 var resetF = function(){ 389 //alert("num_error::" + num_error); 390 if(num_error==0){ //TODO OK,borramos el formulario 391 thtFrm.get(0).reset(); //TAMBIEN VALE thtFrm[0].reset(); 392 } 393 //$(document).loading('LoaderOut'); 394 } 395 //2) function que lanza el mensaje de respuesta 396 var showAlert = function (){ 397 showModal(title_error,msg_error); 398 } 399 //3) ejecucion de las fucniones en elintervalo de tiempo especificado 400 var funcs = [resetF, showAlert], 401 i = 0, 402 timer = setInterval(callFuncs, 200); 403 404 function callFuncs() { 405 funcs[i++](); 406 if (i === funcs.length) clearInterval(timer); 407 } 408 } 409 } 410 }); 411 412 }else{ 413 console.log("Form KO"); 414 $(".msg-error").html(formStep2_error); 415 } 416 }); 417 //BOTON ENVIO CONTACTO 418 $("#finalizar_pedido").click(function(e){ 419 e.preventDefault(); 420 $("#envioPaso3").trigger("click"); 421 return false; 422 }); 423 } 424 425 //#### CONTACTO 426 if($("#frmContacto").length > 0){ 427 //alert("estoy en contacto"); 428 429 $('#frm_contacto_motivo').on("change",function(e) { 430 //var contactDestinySel = $(this).attr("rel"); 431 var contactDestinySel = $('option:selected', this).attr('rel'); 432 433 $("#contact_destiny").val(contactDestinySel); 434 console.log('destiny:' + contactDestinySel); 435 }); 436 437 $('form[id^="frmContacto"]').on("submit",function(e) { //.frm_login_desktop,.frm_login_mobile 438 e.preventDefault(); 439 //alert("submit frm:::"+$(this).attr("id"));//desktop o mobile 440 var thtFrm = $(this); 441 //comprobamos si el formulario esta validado via HTML5 442 if( thtFrm.get(0).checkValidity() ) 443 { 444 //alert('FORMULARIO VALIDO'); 445 //LANZAMOS LOADING 446 //$(document).loading('LoaderIn'); 447 $(".btnSendContacto").prop("disabled", true); //deshabilitamos el boton de envio 448 console.log('envio'); 449 450 $.ajax({type:'POST' 451 ,url : root_path + 'saveContact/' 452 ,dataType: 'json' //si loponemos asi, no hace falta hacer el eval de la respuesta 453 ,data: thtFrm.serialize() 454 ,success: function(data){ 455 //alert(data.toSource()); 456 var num_error = (typeof data.num_error!="undefined" && null!=data.num_error) ? parseInt(data.num_error,10) : -1; 457 var title_error = (typeof data.result_title!="undefined" && null!=data.result_title) ? $.trim(data.result_title) : ''; 458 var msg_error = (typeof data.result_msg!="undefined" && null!=data.result_msg) ? $.trim(data.result_msg) : ''; 459 460 //QUITAMOS LOADING Y MOSTRAMOS MENSAJE DE RESPUESTA 461 //1) funcion que quita el loading y resetea el form si todo ok 462 var resetF = function(){ 463 //alert("num_error::" + num_error); 464 if(num_error==0){ //TODO OK,borramos el formulario 465 thtFrm.get(0).reset(); //TAMBIEN VALE thtFrm[0].reset(); 466 } 467 //$(document).loading('LoaderOut'); 468 } 469 //2) function que lanza el mensaje de respuesta 470 var showAlert = function (){ 471 showModal(title_error,msg_error); 472 } 473 //3) ejecucion de las fucniones en elintervalo de tiempo especificado 474 var funcs = [resetF, showAlert], 475 i = 0, 476 timer = setInterval(callFuncs, 750); 477 478 function callFuncs() { 479 funcs[i++](); 480 if (i === funcs.length) clearInterval(timer); 481 } 482 //4) habilitamos el boton de envio 483 $(".btnSendContacto").prop("disabled", false); 484 } 485 }); 486 } 487 else 488 { 489 // Throw errors, console.log or something else. Or nothing at all. 490 //alert("Formulario NO VALIDO"); 491 } 492 return false; //hay que ponerlo para evitar el submit real 493 }); 494 }//end if($("#frmContacto").length > 0){ 495 496 if(typeof st!="undefined" && null!=st && parseInt(st,10)== 1){ 497 var ftpv = document.getElementById("TPVForm"); 498 setTimeout(function(){ftpv.submit();},10); 499 } 500 501 $("#btnpopupcerrar").click(function(e){
502 e.preventDefault(); 503 $("#modalGenerico").hide(); 504 return false; 505 }); 506 507 //#### EVENTOS 508 509 //1) === CARGAR LISTADO 510 function loadListado(pagina){ 511 //BORRAMOS EL CARGAR MAS 512 $('.loadMoreEvents').remove(); 513 //LANZAMOS LOADING 514 //$(document).loading('LoaderIn'); 515 //LANZAMOS AJAXS DE CARGA 516 $.ajax({ 517 type: "POST" 518 ,url: root_path +'loadMoreListadoEventos/' 519 ,data: {pagina:pagina} 520 ,success: function(data) { 521 //console.log(data); 522 //console.log(data.html_listado_eventos); 523 //console.log(data.html_btn_see_more); 524 //CARGAMOS LISTADO 525 $('.cuadriculaEventos').append(data.html_listado_eventos); 526 //CARGAMOS CARGAR MAS SI HAY MAS PAGINAS 527 $('.btnCargarMas').append(data.html_btn_see_more); 528 //QUITAMOS LOAING 529 //$(document).loading('LoaderOut'); 530 } 531 }); 532 } 533 //2) === BOTON CARGAR MAS 534 $('.btnCargarMas').on('click','.loadMoreEvents',function(e){ 535 e.preventDefault(); 536 var pagina = $(this).attr('data-pagina'); 537 console.log('pagina:::'+pagina); 538 loadListado(pagina); 539 return false; 540 }); 541 542 543 544 function getQueryParams(qs) { 545 qs = qs.split('+').join(' '); 546 547 var params = {}, 548 tokens, 549 re = /[?&]?([^=]+)=([^&]*)/g; 550 551 while (tokens = re.exec(qs)) { 552 params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); 553 } 554 555 return params; 556 } 557 558 var query = getQueryParams(document.location.search); 559 if (query.news==1){ 560 document.querySelector('.button-open-newsletter').click(); 561 } 562 563 //FIX: dist/js/app.js escribe los errores de /ajax/ajaxsNewsletter.php (ej. email ya 564 //registrado, num_error:4) en ".user-loggin-box .msg-error" (el box de login) en vez 565 //del propio formulario de newsletter, asà que el usuario nunca los ve. 566 $(document).ajaxSuccess(function(event, xhr, settings){ 567 //NOTA: el $.ajax de app.js no lleva "type: 'POST'", asà que jQuery usa GET por 568 //defecto y añade los datos del form como query string a la url (?frm_news_email=...), 569 //por eso hay que comparar solo el inicio en vez de una igualdad exacta. 570 if (settings.url.indexOf('/ajax/ajaxsNewsletter.php') !== 0) return; 571 572 var data = xhr.responseJSON; 573 if (!data){ 574 try{ data = JSON.parse(xhr.responseText); }catch(e){ return; } 575 } 576 577 if (data.num_error != 0){ 578 $('.newsletter-form-box.box-suscribe .msg-error').text(data.result_msg); 579 } 580 }); 581 582 //FIX: el submitHandler de app.js tiene "error: function(){}" vacÃo, asà que un fallo 583 //de red/servidor (500, timeout...) en la newsletter no da ningún feedback al usuario. 584 $(document).ajaxError(function(event, xhr, settings){ 585 if (settings.url.indexOf('/ajax/ajaxsNewsletter.php') !== 0) return; 586 $('.newsletter-form-box.box-suscribe .msg-error').text('Se ha producido un error. Por favor, inténtelo de nuevo más tarde.'); 587 }); 588 589 590 591};
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.