1function busRapida() { 2 var form = document.formBusRapida; 3 4 if (form.palabrasBusqueda.value == "") { 5 alertModal(introPalBusqueda, "times-circle"); 6 form.palabrasBusqueda.focus(); 7 return false; 8 } 9 10 return true; 11} 12 13 14function soloEbook() { 15 var form = document.formBusRapida; 16 17 if (form.tipoArticulo.checked == true) { 18 form.tipoBus.value = "soloEbooks"; 19 } 20 else { 21 form.tipoBus.value = "full"; 22 } 23} 24 25 26function abre_ventana(elemento, ancho, alto, scroll) { 27 var ventana = window.open(elemento.href, "_blank", "width=" + ancho + "px, height=" + alto + "px, scrollbars=" + scroll); 28 return ventana == undefined; 29} 30 31 32function validarEmail(input) { 33 if (!isEmail(input.value)) { 34 alertModal(emailIncorrecto, input); 35 return false; 36 } 37 return true; 38} 39 40 41function modifier_moneda(precio, param_moneda) 42{ 43 precio = precio.toString().replace(",", "."); 44 45 var parametros = String(param_moneda).split("|"); 46 47 var simboloMoneda = parametros[0]; 48 var posicionMoneda = parametros[1]; 49 var length = parametros[2]; 50 var dec = parametros[3]; 51 var mil = parametros[4]; 52 53 switch(posicionMoneda) 54 { 55 case "I": 56 return simboloMoneda+" "+number_format(precio, length, dec, mil); 57 break; 58 default: 59 return number_format(precio, length, dec, mil)+" "+simboloMoneda; 60 } 61} 62 63 64function number_format( number, decimals, dec_point, thousands_sep ) 65{ 66 var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; 67 var d = dec_point == undefined ? "," : dec_point; 68 var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : ""; 69 var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; 70 return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); 71} 72 73function sumarCantidad(codArticulo, cnt) { 74 var idInpCnt = "inp_cnt_" + codArticulo; 75 if ($("#" + idInpCnt).length) { 76 cantidad = $("#" + idInpCnt).val(); 77 console.log("(parseInt(cantidad) - cnt <= 0: " + (parseInt(cantidad) - cnt)); 78 console.log("parseInt(cantidad) % cnt > 0: " + (parseInt(cantidad) % cnt)); 79 if (cantidad == "" || !isNumeric(cantidad) || parseInt(cantidad) <= 0 || (cnt < 0 && parseInt(cantidad) + cnt <= 0) || (parseInt(cantidad) % cnt > 0)) { 80 $("#" + idInpCnt).val(Math.abs(cnt)); 81 } 82 else { 83 $("#" + idInpCnt).val(parseInt(cantidad) + cnt); 84 } 85 } 86 87 return false; 88} 89 90function insMiniCar(codArticulo) { 91 var cantidad = 1; 92 var idInpCnt = "inp_cnt_" + codArticulo; 93 if ($("#" + idInpCnt).length) { 94 cantidad = $("#" + idInpCnt).val(); 95 if (cantidad == "" || !isNumeric(cantidad) || parseInt(cantidad) <= 0) { 96 cantidad = 1; 97 } 98 } 99 $.ajax({ 100 url: rutaHtml + "/cesta/insCarrito.ajax.php?codArticulo=" + codArticulo + "&cantidad=" + cantidad, 101 async: true, 102 contentType: "application/x-www-form-urlencoded", 103 dataType: "json", 104 error: function (e, transport, otroobj) { 105 alert("No se ha podido realizar correctamente la petición AJAX de insertar en carrito"); 106 console.log(e, transport); 107 }, 108 global: true, 109 ifModified: false, 110 processData: true, 111 success: function (result) { 112 if (result["correcto"]) { 113 //alert(result["link_portada"]); 114 var htmlArt = 115 '<div class="miniCesta-article" id="miniCesta_articulo' + totalArticulosCesta + '">' + 116 '<div class="info-book">' + 117 '<img title="' + result["descripcion"] + '" src="' + result["link_portada"] + '" width="40" />' + 118 '<a href="' + result["link"] + '">' + result["descripcion"] + '</a>'; 119 120 if (result["tipo_articulo"] == 'E') { 121 htmlArt += '<div class="wraper_ebook"><span class="ico_ebook">ebook</span></div>'; 122 } 123 else if (false && result["tipo_articulo"] == 'I') { 124 htmlArt += '<div class="wraper_idm"><span class="icon-print"> POD</span></div>'; 125 } 126 127 htmlArt += 128 '</div>' + 129 '<div class="quantity">' + 130 '<span id="miniCesta_can' + totalArticulosCesta + '">1</span>' + 131 '</div>' + 132 '<div class="miniCesta-total">
132' + 133 // modifier_moneda(result["pvp_euros"], paramMoneda) + 134 (result["descuento"] > 0 && result["precio_descuento"] < result["pvp_euros"] ? 135 (modifier_moneda(result["precio_descuento"], paramMoneda)) 136 : 137 modifier_moneda(result["pvp_euros"], paramMoneda) 138 ) + 139 '<a class="delete icon-remove-sign" href="javascript:void(0)" onclick="delArticulo(' + totalArticulosCesta + ', \'' + result["codigo"] + '\')"></a>' + 140 '</div>' + 141 '</div>'; 142 143 //alert(htmlArt); 144 $("#miniCesta").html($("#miniCesta").html() + htmlArt); 145 146 $(".numArticulos").html(result["num_articulos"]); 147 $("#precioTotalMiniCesta").html(modifier_moneda(result["precio_total"], paramMoneda)); 148 totalArticulosCesta++; 149 150 if (facebookPixel != "") { 151 // Facebook Pixel Code AddToCart 152 fbq('track', 'AddToCart', { 153 content_name: result["descripcion"], 154 content_ids: [codArticulo], 155 content_type: 'product', // product o product_group 156 value: result["pvp_euros"], 157 currency: divisa // EUR, MXN, USD 158 }); 159 //console.log('Pixel de facebook: ' + facebookPixel + ' Divisa: ' + divisa); 160 } 161 162 // Notificacion 163 //show_stack_bar_top('success', '<span class="icon-ok-sign"></span>'+artInsCestaOK+' <a href="'+rutaHtml+'/cesta/cestaCompra.php">'+verCesta+'</a>.'); 164 alertInsCarrito(artInsCestaOK, "check-circle", result); 165 166 if (GTM != "") { 167 addToCart_GA4(result, 1); 168 } 169 } 170 else { 171 alertModal(result["mensaje"], "info-circle"); 172 } 173 }, 174 timeout: 10000, 175 type: "GET" 176 }); 177} 178 179 180function delArticulo(i, codArticulo) { 181 $.ajax({ 182 url: rutaHtml + "/cesta/delArticulo.ajax.php?codArticulo=" + codArticulo, 183 async: true, 184 contentType: "application/x-www-form-urlencoded", 185 dataType: "json", 186 error: function (e, transport, otroobj) { 187 alert("No se ha podido realizar correctamente la petición AJAX de borrar del carrito"); 188 console.log(e, transport); 189 }, 190 global: true, 191 ifModified: false, 192 processData: true, 193 success: function (result) { 194 if (result["correcto"]) { 195 $("#miniCesta_articulo" + i).hide(); 196 197 $(".numArticulos").html(result["num_articulos"]); 198 $("#precioTotalMiniCesta").html(modifier_moneda(result["precio_total"], paramMoneda)); 199 totalArticulosCesta--; 200 } 201 else { 202 alertModal(result["mensaje"], null); 203 } 204 }, 205 timeout: 10000, 206 type: "GET" 207 }); 208} 209 210 211function cambiaCantidad(incrementar, i, codArticulo) { 212 $.ajax({ 213 url: rutaHtml + "/cesta/cantidad.ajax.php?codArticulo=" + codArticulo + "&incrementar=" + incrementar, 214 async: true, 215 contentType: "application/x-www-form-urlencoded", 216 dataType: "json", 217 error: function (e, transport, otroobj) { 218 alert("No se ha podido realizar correctamente la petición AJAX de cambiar cantidad en carrito"); 219 console.log(e, transport); 220 }, 221 global: true, 222 ifModified: false, 223 processData: true, 224 success: function (result) { 225 if (result["correcto"]) { 226 $("#miniCesta_can" + i).html(result["nueva_cantidad"]); 227 228 $("#numArticulos").html(result["num_articulos"] + "x"); 229 $("#precioTotalMiniCesta").html(modifier_moneda(result["precio_total"], paramMoneda)); 230 } 231 else { 232 alertModal(result["mensaje"], null); 233 } 234 }, 235 timeout: 10000, 236 type: "GET" 237 }); 238} 239 240 241var stack_bar_top = { "dir1": "down", "dir2": "right", "push": "top", "spacing1": 0, "spacing2": 0 }; 242function show_stack_bar_top(type, msg) { 243 var opts = { 244 //title: "Over Here", 245 text: "<div class=\"center-box\"><strong>Información</strong>.</div>", 246 addclass: "stack-bar-top", 247 cornerclass: "", 248 width: "100%", 249 delay: 4000, 250 history: false, 251 icon: false, 252 sticker: false, 253 closer: false, 254 stack: stack_bar_top 255 }; 256 switch (type) { 257 case 'error': 258 //opts.title = "Oh No"; 259 opts.text = "<div class=\"center-box\">" + msg + "</div>"; 260 opts.type = "error"; 261 break; 262 case 'info': 263 //opts.title = "Breaking News"; 264 opts.text = "<div class=\"center-box\">" + msg + "</div>"; 265 opts.type = "info"; 266 break; 267 case 'success':
268 //opts.title = "Good News Everyone"; 269 opts.text = "<div class=\"center-box\">" + msg + "</div>"; 270 opts.type = "success"; 271 break; 272 } 273 $.pnotify(opts); 274} 275 276 277/** Tabs **/ 278$(document).ready(function () { 279 if (paginaActual == "detalle.php") { 280 //console.log("ficha Detalle: S"); 281 $("#detnavtab").idTabs(); 282 } 283}); 284 285 286/** Buscador **/ 287$(document).ready(function () { 288 if (autocomplete) { 289 valorAutocomplete = ""; 290 $("#autocompleta").autocomplete({ 291 position: { my: "left top" }, 292 source: rutaHtml + "/busqueda/resultsAutocomplete.ajax.php", 293 open: function () { $('ul.ui-autocomplete').hide().fadeIn(400) }, 294 close: function () { $('ul.ui-autocomplete').show().fadeOut(100) }, 295 minLength: 2, 296 focus: function (event, ui) { 297 if (ui.item[0] != "titulo" && ui.item[0] != "todos" && ui.item[0] != "aproximada") 298 $("#autocompleta").val(ui.item[0]); 299 return false; 300 }, 301 select: function (event, ui) { 302 if (ui.item[0] != "titulo" && ui.item[0] != "todos" && ui.item[0] != 'aproximada') { 303 $("#autocompleta").val(ui.item[0]); 304 } 305 return false; 306 } 307 }).data("ui-autocomplete")._renderItem = function (ul, item) { 308 if (item[0] == 'titulo') 309 return $("<span class='autocomplete-title'></span>") 310 .data("item.autocomplete", item) 311 .append("<span>" + item[1] + "</span>") 312 .appendTo(ul); 313 else if (item[0] == 'todos') 314 return $("<span class='autocomplete-more'></span>") 315 .data("item.autocomplete", item) 316 .append("<a href=" + item[1] + ">" + verTodos + "</a>") 317 .appendTo(ul); 318 else if (item[0] == 'aproximada') { 319 if (item[1] == 'S') { 320 $("#aproximada").val('S'); 321 return $("<li class='no-result'></li>") 322 .data("item.autocomplete", item) 323 .append("<i class='icon-info' aria-hidden='true'></i> " + resultsAprox) 324 .appendTo(ul); 325 } else { 326 $("#aproximada").val('N'); 327 return $("<li></li>") 328 .data("item.autocomplete", item) 329 .append(" ") 330 .appendTo(ul); 331 } 332 } else 333 return $("<li></li>") 334 .data("item.autocomplete", item) 335 .append("<a href=" + item[1] + " class='autocomplete-item'><img src=" + item[3] + " width='25' height='37'><div><span class='titulo'>" + item[0] + "</span><span class='autor'>" + item[2] + "</span></div></a>") 336 .appendTo(ul); 337 }; 338 339 $('#autocompleta').click(function () { 340 if (valorAutocomplete != 'aproximada') { 341 $("#autocompleta").val(valorAutocomplete); 342 } 343 }); 344 $('#autocompleta').keyup(function () { 345 valorAutocomplete = $("#autocompleta").val(); 346 }); 347 } 348}); 349 350 351/** Carrito compra **/ 352var timeout = 500; 353var closetimer = 0; 354var ddmenuitem = 0; 355 356function jsddm_openCesta() { 357 if (totalArticulosCesta > 0) { 358 jsddm_canceltimer(); 359 jsddm_close(); 360 ddmenuitem = $(this).find('#contentMiniCesta').eq(0).css('visibility', 'visible'); 361 } 362} 363 364 365function jsddm_open() { 366 jsddm_canceltimer(); 367 jsddm_close(); 368 ddmenuitem = $(this).find('#contentMiniCesta').eq(0).css('visibility', 'visible'); 369} 370 371 372function jsddm_close() { 373 if (ddmenuitem) ddmenuitem.css('visibility', 'hidden'); 374} 375 376 377function jsddm_timer() { 378 closetimer = window.setTimeout(jsddm_close, timeout); 379} 380 381 382function jsddm_canceltimer() { 383 if (closetimer) { 384 window.clearTimeout(closetimer); 385 closetimer = null; 386 } 387} 388 389 390$(document).ready(function () { 391 $('#jsddm > li').bind('mouseover', jsddm_open); 392 $('#jsddm > li').bind('mouseout', jsddm_timer); 393 394 $('#jsddm_menucab > li').bind('mouseover', jsddm_open); 395 $('#jsddm_menucab > li').bind('mouseout', jsddm_timer); 396 397 if (paginaActual != "cestaCompra.php") { 398 $('#cart-fixed').bind('mouseover', jsddm_openCesta); 399 $('#cart-fixed').bind('mouseout', jsddm_timer); 400 } 401}); 402 403 404/** Enlace ver más/menos filtros facetado **/ 405$(document).ready(function () { 406 407 if (paginaActual == "listaLibros.php" || paginaActual == "dispatcherMateria.php" || paginaActual == "listaLibrosAutor.php" || paginaActual == "listaLibrosMateria.php") { 408 // Ver mas 409 if ($('.show-filters').length > 0) { 410 $('.show-filters').click(function () { 411 $(this).parent().parent().find('.sidebar-hidden-filter').slideToggle(); 412 $(this).css('display', 'none'); 413 414 var id = $(this).attr('id'); 415 id = id.substring(0, id.length - 1); 416 //alert(id); 417 $('#' + id + 'H').show(); 418 419 return false;
420 }); 421 } 422 423 // Ver menos 424 if ($('.hide-filters').length > 0) { 425 $('.hide-filters').click(function () { 426 $(this).parent().parent().find('.sidebar-hidden-filter').slideToggle(200); 427 $(this).css('display', 'none'); 428 429 var id = $(this).attr('id'); 430 id = id.substring(0, id.length - 1); 431 //alert(id); 432 $('#' + id + 'S').show(); 433 434 return false; 435 }); 436 } 437 } 438 439}); 440 441 442function generaSesion(parametro, valor) { 443 $.ajax({ 444 url: rutaHtml + "/generaSesion.ajax.php?pm=" + parametro + "&valor=" + escape(valor), 445 async: true, 446 contentType: "application/x-www-form-urlencoded", 447 dataType: "json", 448 error: function (e, transport, otroobj) { 449 alert("No se ha podido realizar correctamente la petición AJAX de afiliado"); 450 console.log(e, transport); 451 }, 452 global: true, 453 ifModified: false, 454 processData: true, 455 success: function (result) { 456 if (result != "OK") { 457 alertModal("No ha podido generarse la sesion para el afiliado", null); 458 } 459 }, 460 timeout: 10000, 461 type: "GET" 462 }) 463 ; 464} 465 466 467$(document).ready(function () { 468 if (afiliado != "") { 469 generaSesion("AFILIADO", afiliado); 470 } 471}); 472 473 474/** Cerrar ventana cookies **/ 475$(document).ready(function () { 476 $("#close-cookies-message").click(function () { 477 $("#cookie-compliant").css("display", "none"); 478 }); 479}); 480 481 482$(document).ready(function () { 483 window.name = 'parentwindow'; 484}); 485 486 487/** Filters mobile **/ 488$(document).ready(function () { 489 $('#btn-filters').click(function () { 490 $(this).toggleClass('open'); 491 $('.filters-selects').slideToggle('fast'); 492 }); 493}); 494 495 496/** List display mode **/ 497$(document).ready(function () { 498 $("a.switcher").bind("click", function (e) { 499 e.preventDefault(); 500 501 var theid = $(this).attr("id"); 502 var theproducts = $(".books"); 503 var active = $(".switcher.active").attr('data-bs-value'); //Clase del elemento activo 504 505 if ($(this).hasClass("active")) { 506 return false; 507 } else { 508 509 var cols = $(this).attr('data-bs-value'); //Clase a aplicar 510 511 if (theid == "gridview") { 512 $(this).addClass("active"); 513 $("#listview").removeClass("active"); 514 515 theproducts.removeClass(active); 516 theproducts.addClass(cols); 517 } 518 else if (theid == "listview") { 519 $(this).addClass("active"); 520 $("#gridview").removeClass("active"); 521 522 theproducts.removeClass(active); 523 theproducts.addClass(cols); 524 } 525 } 526 }); 527}); 528 529 530/** Modales **/ 531// Modal genérica que muestra mensaje 532function mostrarMensaje(titulo, mensaje, ejecutar, parametro) { 533 BootstrapDialog.show({ 534 type: BootstrapDialog.TYPE_DEFAULT, 535 title: titulo, 536 message: $('<div></div>').load('/includes/mensaje.php?mensaje=' + escape(mensaje)), 537 draggable: true, 538 buttons: [ 539 { 540 label: 'Cerrar', 541 cssClass: 'btn-primary', 542 action: function (dialogItself) { 543 dialogItself.close(); 544 if (ejecutar != '' && ejecutar != null) 545 ejecutar(parametro); 546 } 547 } 548 ] 549 }); 550} 551 552 553function alertModal(mensaje, icono) { 554 var $textAndIcon = $('<div></div>'); 555 $textAndIcon.append('<i class="fa fa-' + icono + '" aria-hidden="true"></i>'); 556 $textAndIcon.append('<h2>' + mensaje + '</h2>'); 557 558 BootstrapDialog.show({ 559 type: BootstrapDialog.TYPE_DEFAULT, 560 size: BootstrapDialog.SIZE_NORMAL, 561 cssClass: 'alertModal-dialog modal-no-header modal-no-footer ' + icono, 562 message: $textAndIcon 563 }); 564 565 setTimeout(function () { $('.alertModal-dialog').modal('hide'); }, 5000); 566} 567 568 569function alertInsCarrito(mensaje, icono, result) { 570 var $textAndIcon = $('<div></div>'); 571 $textAndIcon.append('<i class="fa fa-' + icono + '" aria-hidden="true"></i>'); 572 $textAndIcon.append('<h2>' + mensaje + ' <small>(' + totalArticulosCesta + ' en total)</small></h2>'); 573 console.log(result); 574 // Pasar a float 575 /* 576 result["descuento"] = parseFloat(result["descuento"]); 577 result["precio_descuento"] = parseFloat(result["precio_descuento"]); 578 result["pvp_euros"] = parseFloat(result["pvp_euros"]); 579 */ 580 var precioFinal = (result["descuento"] > 0 && result["precio_descuento"] < result["pvp_euros"] ? 581 result["precio_descuento"] : 582 result["pvp_euros"] 583 ); 584 585 console.log("descuento: " + result["descuento"] + " precio_descuento: " + result["precio_descuento"] + " pvp_euros: " + result["pvp_euros"]); 586 $textAndIcon.append( 587 '<div class="info-book">' + 588 '<a href="' + result["link"] + '"><img title="' + result["descripcion"] + '" src="' + result["link_portada"] + '"></a>' + 589 '<p class="titulo"><a href="' + result["link"] + '">' + result["descripcion"] + '</a></p><p class="autor">' + result["autor"] + '</p>' + 590 '<p class="precio">' + 591 //modifier_moneda(result["pvp_euros"], paramMoneda) + 592 modifier_moneda(precioFinal, paramMoneda) + 593 '</p>' + 594 '</div>' 595 ); 596 597 BootstrapDialog.show({ 598 type: BootstrapDialog.TYPE_DEFAULT, 599 size: BootstrapDialog.SIZE_NORMAL, 600 cssClass: 'alertCarrito-dialog modal-no-header modal-no-footer ' + icono, 601 message: $textAndIcon,
602 buttons: [{ 603 label: seguirComprando, 604 action: function (dialogRef) { 605 dialogRef.close(); 606 } 607 }, { 608 label: verCesta, 609 cssClass: 'btn-primary', 610 action: function (dialogRef) { 611 $(location).attr('href', rutaHtml + (checkout ? '/checkout/checkout.php' : '/cesta/cestaCompra.php')); 612 } 613 }] 614 }); 615} 616 617 618function confirmModal(mensaje, icono, element) { 619 var $textAndIcon = $('<div></div>'); 620 $textAndIcon.append('<i class="fa fa-' + icono + '" aria-hidden="true"></i>'); 621 $textAndIcon.append('<h2>' + mensaje + '</h2>'); 622 623 BootstrapDialog.show({ 624 type: BootstrapDialog.TYPE_DEFAULT, 625 cssClass: 'confirmModal-dialog modal-no-header ' + icono, 626 message: $textAndIcon, 627 buttons: [{ 628 label: cancelar, 629 action: function (dialogRef) { 630 dialogRef.close(); 631 } 632 }, { 633 label: aceptar, 634 cssClass: 'btn-primary', 635 action: function (dialogRef) { 636 var eId = element.attr('id'); 637 $(location).attr('href', element.attr('href')); 638 } 639 }] 640 }); 641} 642 643 644function notificacion() { 645 if (notifOK != "") { 646 alertModal(notifOK, "check-circle"); 647 } 648 else if (notifERR != "") { 649 alertModal(notifERR, "times-circle"); 650 } 651 else if (notifINFO != "") { 652 alertModal(notifINFO, "info-circle"); 653 } 654} 655 656 657/** Labelauty **/ 658$(document).ready(function () { 659 $(".labelauty").labelauty({ 660 // Development Mode 661 // This will activate console debug messages 662 development: false, 663 664 // Trigger Class 665 // This class will be used to apply styles 666 class: "labelauty", 667 668 // Use text label ? 669 // If false, then only an icon represents the input 670 label: true, 671 672 // Separator between labels' messages 673 // If you use this separator for anything, choose a new one 674 separator: "|", 675 676 // Default Checked Message 677 // This message will be visible when input is checked 678 checked_label: "Checked", 679 680 // Default UnChecked Message 681 // This message will be visible when input is unchecked 682 unchecked_label: "Unchecked", 683 684 // Minimum Label Width 685 // This value will be used to apply a minimum width to the text labels 686 minimum_width: false, 687 688 // Use the greatest width between two text labels ? 689 // If this has a true value, then label width will be the greatest between labels 690 same_width: true 691 }); 692 693 notificacion(); 694}); 695 696 697$('.btn-cart').click(function () { 698 var numArticulos = $('.numArticulos').html(); 699 if (numArticulos == 0) { 700 $(this).removeAttr("href"); 701 alertModal(noArticulosCesta, "info-circle"); 702 } 703}); 704 705 706/** Sticy Header / Scrolltop **/ 707$(document).ready(function ($) { 708 if (stickyHeader) { 709 $(window).scroll(function () { 710 var scroll = $(window).scrollTop(); 711 var width = $(window).width(); 712 var sticky_ini = 180; 713 714 if ($('header.header-2').length) { 715 sticky_ini = 1; 716 } 717 718 if (scroll >= sticky_ini && width > 767) { 719 $('header').addClass('sticky'); 720 $('header.sticky .header-middle').attr('data-aos', 'fade-up'); 721 $('header.sticky .header-middle').attr('data-aos-duration', '550'); 722 $('.ui-autocomplete').fadeOut(); 723 } 724 else { 725 $('header').removeClass('sticky'); 726 $('header .header-middle').removeAttr('data-aos'); 727 $('header .header-middle').removeAttr('data-aos-duration'); 728 } 729 }); 730 } 731}); 732 733 734/** Scrollto **/ 735$(document).ready(function () { 736 $(window).scroll(function () { 737 if ($(this).scrollTop() > 55) { 738 $('.scrollToTop').fadeIn(); 739 } else { 740 $('.scrollToTop').fadeOut(); 741 } 742 }); 743 744 $('.scrollToTop').click(function () { 745 $('html, body').animate({ scrollTop: 0 }, 800); 746 return false;
747 }); 748 749 $('.page-detalle a[href^="#"]').on('click', function (event) { 750 var target = $(this.getAttribute('href')); 751 if (target.length) { 752 var width = $(window).width(); //Ancho de la ventana 753 if (width < 767) { 754 var targetPosition = (target.offset().top) - 100; //Si el ancho es menor a 767 el ancla se posiciona más arriba para no tapar 755 } 756 else { 757 var targetPosition = (target.offset().top) - 120; 758 } 759 760 event.preventDefault(); 761 $('html, body').stop().animate({ 762 scrollTop: targetPosition 763 }, 500); 764 } 765 }); 766}); 767 768 769/** Checkbox links **/ 770$(document).ready(function () { 771 $('.list-group-item').click(function (e) { 772 e.stopPropagation(); 773 774 var $this = $(this).find("[type=checkbox]"); 775 if ($this.is(":checked")) { 776 $this.prop("checked", false); 777 $this.val(1); 778 } 779 else { 780 $this.prop("checked", true); 781 $this.val("") 782 } 783 }); 784}); 785 786 787/** Tooltips/Popover **/ 788$(document).ready(function () { 789 $('[data-bs-toggle="tooltip"]').tooltip({ 790 trigger: 'hover', 791 container: 'body', 792 animated: 'fade', 793 }); 794 795 $(function () { 796 $('[data-bs-toggle="popover"]').popover() 797 }) 798}); 799 800 801/** Promociones **/ 802$(document).ready(function () { 803 $('.grupoCestaOfertaImpar').last().css('border-bottom', '10px solid #fdfdfd'); 804 $('.grupoCestaOfertaPar').last().css('border-bottom', '10px solid #fdfdfd'); 805}); 806 807 808/** Disponibilidad on-line listados */ 809$(document).ready(function () { 810 let ids = []; 811 let pattern = /^.*\_(.+)$/; 812 $('[id^="dispo_"]').each(function () { 813 let match = this.id.match(pattern) 814 if (match.length > 1) { 815 let id = match[1] 816 ids.push(id) 817 } 818 }) 819 if (ids.length > 0) disponibilidadListadoMiniFichas(ids) // ids.forEach(disponibilidadListadoMiniFicha) 820}); 821 822 823function disponibilidadListadoMiniFichas(ids) { 824 //console.log("ids: " + ids); 825 //let listadoCodigos = ids.map(s => s.trim()).join(',') 826 let listadoCodigos = ids.join(','); 827 //console.log("listadoCodigos: " + listadoCodigos); 828 return $.ajax({ 829 url: rutaHtml + '/busqueda/disponibilidad.ajax.php?codigo=' + listadoCodigos, 830 async: true, 831 contentType: 'application/x-www-form-urlencoded', 832 dataType: 'json', 833 error: function (jqXhr, textStatus, errorThrown) { 834 console.error(textStatus, errorThrown, jqXhr) 835 }, 836 global: true, 837 ifModified: false, 838 processData: true, 839 success: function (resultList) { 840 if (resultList.length) { 841 resultList.forEach(function (result) { 842 let codigo = result.codigo 843 if (!!result.descripcion) { 844 let idCapa = '#dispo_' + codigo 845 $(idCapa).show() 846 $(idCapa).html(result.descripcion) 847 let botonComprar = $('#href_dispo_' + codigo) 848 if (result.vendible === 'S' && botonComprar.length) { 849 botonComprar.show(); 850 if ($("#inputQuantity_" + codigo).length) { 851 $("#inputQuantity_" + codigo).show(); 852 } 853 } 854 } 855 }) 856 } else { 857 let codigo = resultList.codigo 858 if (!!resultList.descripcion) { 859 let idCapa = '#dispo_' + codigo 860 $(idCapa).show() 861 $(idCapa).html(resultList.descripcion) 862 let botonComprar = $('#href_dispo_' + codigo) 863 if (resultList.vendible === 'S' && botonComprar.length) { 864 botonComprar.show(); 865 if ($("#inputQuantity_" + codigo).length) { 866 $("#inputQuantity_" + codigo).show(); 867 } 868 } 869 } 870 } 871 }, 872 timeout: 30000, 873 type: 'GET' 874 }) 875} 876 877 878function disponibilidadMiniFicha(id) { 879 var idCapa = '#' + id; 880 var codArticulo = id.substring(id.indexOf('_') + 1); 881 882 $.ajax({ 883 url: rutaHtml + '/busqueda/disponibilidad.ajax.php?codigo=' + codArticulo, 884 async: true, 885 contentType: 'application/x-www-form-urlencoded', 886 dataType: 'json', 887 error: function (jqXhr, textStatus, errorThrown) { 888 console.error(textStatus, errorThrown, jqXhr) 889 }, 890 global: true, 891 ifModified: false, 892 processData: true, 893 success: function (result) { 894 if (!!result.descripcion) { 895 $(idCapa).show() 896 $(idCapa).html(result.descripcion) 897 let botonComprar = $('#href_dispo_' + codArticulo) 898 if (result.vendible === 'S' && botonComprar.length) botonComprar.show(); 899 } 900 }, 901 timeout: 10000, 902 type: 'GET' 903 }) 904} 905 906 907/** Paneles **/ 908$(document).ready(function () { 909 $('.collapse').on('show.bs.collapse', function () { 910 var id = $(this).attr('id'); 911 $('a[href="#' + id + '"] .panel-title span').html('<i class="fa fa-minus"></i>'); 912 }); 913 $('.collapse').on('hide.bs.collapse', function () { 914 var id = $(this).attr('id'); 915 $('a[href="#' + id + '"] .panel-title span').html('<i class="fa fa-plus"></i>'); 916 }); 917}); 918 919 920/** jsSocials **/ 921if (paginaActual == "detalle.php") { 922 $("#share-links").jsSocials({ 923 shareIn: "popup", 924 showLabel: false, 925 showCount: false, 926 shares: ["facebook", "twitter", "linkedin", "pinterest", "whatsapp", "email"] 927 }); 928 929 /*if($(window).width() > 767) { 930 $('.btn-compartir').hover(function () { 931 $(this).find('.jssocials').slideToggle(200); 932 }); 933 } 934 if($(window).width() <= 767) { 935 $('.btn-compartir').click(function () { 936 $(this).find('.jssocials').slideToggle(200); 937 $(this).toggleClass('active'); 938 }); 939 }*/ 940} 941 942 943/** Sliders / Carruseles - Swiper **/ 944$(document).ready(function () { 945 const swiper1 = new Swiper('.slider', { 946 direction: 'horizontal', 947 loop: true, 948 effect: 'fade', 949 crossFade: true, 950 autoplay: { 951 delay: 5000, 952 disableOnInteraction: false, 953 pauseOnMouseEnter: true, 954 }, 955 pagination: { 956 el: '.swiper-pagination', 957 clickable: true, 958 dynamicBullets: true, 959 }, 960 navigation: { 961 nextEl: '.swiper-button-next', 962 prevEl: '.swiper-button-prev', 963 }, 964 scrollbar: { 965 el: '.swiper-scrollbar', 966 }, 967 grabCursor: true, 968 }); 969 970 $('.swiper-container').each(function (index, element) { 971 var $container = $(this); 972 var swiper2 = new Swiper($container.find('.books-slider')[0], { 973 direction: 'horizontal', 974 loop: true, 975 autoplay: { 976 delay: 2500, 977 disableOnInteraction: true, 978 pauseOnMouseEnter: true, 979 }, 980 spaceBetween: 30, 981 982 navigation: { 983 nextEl: $container.find('.swiper-button-next')[0], 984 prevEl: $container.find('.swiper-button-prev')[0], 985 }, 986 987 breakpoints: { 988 320: { 989 slidesPerView: 2, 990 }, 991 480: { 992 slidesPerView: 3, 993 }, 994 768: { 995 slidesPerView: 3, 996 autoplay: false, 997 }, 998 1024: { 999 slidesPerView: 4, 1000 autoplay: false, 1001 }, 1002 1200: { 1003 slidesPerView: 5, 1004 autoplay: false, 1005 }, 1006 1400: { 1007 slidesPerView: 6, 1008 autoplay: false, 1009 } 1010 } 1011 }); 1012 }); 1013 1014 $('.swiper-container').each(function (index, element) { 1015 var $container = $(this);
1016 var swiper3 = new Swiper($container.find('.detalle-slider')[0], { 1017 direction: 'horizontal', 1018 loop: true, 1019 autoplay: { 1020 delay: 2500, 1021 disableOnInteraction: true, 1022 pauseOnMouseEnter: true, 1023 }, 1024 spaceBetween: 30, 1025 1026 navigation: { 1027 nextEl: $container.find('.swiper-button-next')[0], 1028 prevEl: $container.find('.swiper-button-prev')[0], 1029 }, 1030 1031 breakpoints: { 1032 320: { 1033 slidesPerView: 2, 1034 }, 1035 480: { 1036 slidesPerView: 3, 1037 }, 1038 768: { 1039 slidesPerView: 3, 1040 autoplay: false, 1041 }, 1042 1024: { 1043 slidesPerView: 4, 1044 autoplay: false, 1045 }, 1046 1200: { 1047 slidesPerView: 5, 1048 autoplay: false, 1049 }, 1050 1400: { 1051 slidesPerView: 6, 1052 autoplay: false, 1053 } 1054 } 1055 }); 1056 }); 1057 1058 1059 const swiper5 = new Swiper('.gallery', { 1060 direction: 'horizontal', 1061 loop: false, 1062 slidesPerView: 4, 1063 spaceBetween: 10, 1064 1065 pagination: { 1066 el: '.swiper-pagination', 1067 }, 1068 1069 navigation: { 1070 nextEl: '.buttons-gallery .swiper-button-next', 1071 prevEl: '.buttons-gallery .swiper-button-prev', 1072 }, 1073 1074 scrollbar: { 1075 el: '.swiper-scrollbar', 1076 }, 1077 }); 1078}); 1079 1080$(document).ready(function () { 1081 // ofuscación de Añadir a Favoritos 1082 $('.nomesigas').on('click', function () { 1083 window.location.href = window.atob($(this).attr("data-link")); 1084 return false; 1085 }); 1086 1087 // 1088 $('#botonComprar, #botonComprar2, .botonComprar, #botonComprarPOD').on('click', function () { 1089 insMiniCar($(this).attr("data-id")); 1090 return false; 1091 }); 1092}); 1093 1094$(document).ready(function () { 1095 $('.btn_desgloseIVA').click(function () { 1096 $('#desgloseIVA_importes').slideToggle(200); 1097 }); 1098}); 1099 1100 1101function addToCart_GA4(result, cantidad) { 1102 //console.log("addToCart_GA4() dataLayer: " + dataLayer); 1103 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 1104 dataLayer.push({ 1105 event: "add_to_cart", 1106 ecommerce: { 1107 items: [{ 1108 item_name: result["descripcion"], // Name or ID is required. 1109 item_id: result["codigo"], 1110 price: result["pvp_euros"], 1111 item_brand: result["familia"], 1112 item_category: result["materia_principal"], 1113 item_category2: result["materia_nivel2"], 1114 item_category3: result["materia_nivel3"], 1115 item_category4: result["materia_nivel4"], 1116 quantity: cantidad 1117 }] 1118 } 1119 }); 1120 1121 //console.log("addToCart_GA4() dataLayer2: " + dataLayer); 1122} 1123 1124$(document).ready(function () { 1125 // evento select_item GA4 1126 $('.productClick').on('click', function () { 1127 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 1128 dataLayer.push({ 1129 event: "select_item", 1130 ecommerce: { 1131 items: [{ 1132 item_name: $(this).data("name"), // Name or ID is required. 1133 item_id: $(this).data("id"), 1134 item_brand: $(this).data("brand") 1135 }] 1136 } 1137 }); 1138 //console.log("select_item_GA4(): id: " + $(this).data("id") + " brand: " + $(this).data("brand") + " name:" + $(this).data("name")); 1139 }); 1140}); 1141 1142 1143/** Efectos AOS **/ 1144$(document).ready(function () { 1145 AOS.init(); 1146}); 1147 1148 1149/** Lightbox **/ 1150$(document).ready(function () { 1151 lightbox.option({ 1152 'resizeDuration': 200, 1153 'wrapAround': true, 1154 'disableScrolling': true, 1155 'showImageNumberLabel': false, 1156 //'albumLabel': '%1/%2', 1157 }); 1158}); 1159 1160 1161/** Modificar contenido de iframes **/ 1162$(document).ready(function () { 1163 $('#ifrDirecciones').on('load', function () {
1164 var iframeContent = $(this).contents(); 1165 1166 iframeContent.find('.form-box').css({ 1167 'box-shadow': 'none', 1168 'border': '0', 1169 'padding': '2rem 1rem 0', 1170 }); 1171 }); 1172}); 1173 1174 1175/** Sticky bar detalle **/ 1176$(document).ready(function () { 1177 if (paginaActual == "detalle.php") { 1178 $.fn.isInViewport = function () { 1179 var header = $(".header-middle").height(); 1180 var elementTop = $(this).offset().top; 1181 var elementBottom = elementTop + $(this).outerHeight(); 1182 1183 var viewportTop = $(window).scrollTop() + header; 1184 var viewportBottom = viewportTop + $(window).height(); 1185 1186 return elementBottom > viewportTop && elementTop < viewportBottom; 1187 }; 1188 1189 $(window).on('resize scroll', function () { 1190 1191 boton = $(".price-col #botonComprar"); 1192 1193 if ($(boton).is(":visible")) { 1194 if ($(boton).isInViewport()) { 1195 $('.sticky-bar.detalle').slideUp(200); 1196 } else { 1197 $('.sticky-bar.detalle').slideDown(250); 1198 } 1199 1200 if ($('.sticky-bar.detalle').is(":visible")) { 1201 $('body').css('padding-bottom', '85px'); 1202 } 1203 else { 1204 $('body').css('padding-bottom', '0'); 1205 } 1206 } 1207 }); 1208 } 1209}); 1210 1211 1212 1213/** Sticky bar checkout **/ 1214$(document).ready(function () { 1215 if (paginaActual == "checkout.php") { 1216 $.fn.isInViewport = function () { 1217 var header = $(".header-middle").height(); 1218 var elementTop = $(this).offset().top; 1219 var elementBottom = elementTop + $(this).outerHeight(); 1220 1221 var viewportTop = $(window).scrollTop() + header; 1222 var viewportBottom = viewportTop + $(window).height(); 1223 1224 return elementBottom > viewportTop && elementTop < viewportBottom; 1225 }; 1226 1227 if($(window).width() > 991) { 1228 $(window).on('resize scroll', function () { 1229 1230 capa = $(".checkout-section.resumen"); 1231 1232 if ($(capa).is(":visible")) { 1233 if ($(capa).isInViewport()) { 1234 $('.sticky-bar.checkout').slideUp(200); 1235 } else { 1236 $('.sticky-bar.checkout').slideDown(250); 1237 } 1238 1239 if ($('.sticky-bar.checkout').is(":visible")) { 1240 $('body').css('padding-bottom', '70px'); 1241 } 1242 else { 1243 $('body').css('padding-bottom', '0'); 1244 } 1245 } 1246 }); 1247 } 1248 } 1249}); 1250 1251 1252/** Uned **/ 1253$(document).ready(function () { 1254 $(".page-articulos .filters-search h4").click(function () { 1255 if ($(this).next().is(':visible')) { 1256 $(this).next().slideUp(400); 1257 } 1258 else { 1259 $(".page-articulos .filters-search ul").slideUp(300); 1260 $(this).next().slideToggle(400); 1261 } 1262 }); 1263}); 1264 1265 1266/** Menu offcanvas **/ 1267function darken_screen(yesno) { 1268 if (yesno == true) { 1269 $('.screen-darken').addClass('active'); 1270 } else if (yesno == false) { 1271 $('.screen-darken').removeClass('active'); 1272 } 1273} 1274 1275function close_offcanvas() { 1276 darken_screen(false); 1277 $('#offcanvas.show').removeClass('show'); 1278} 1279 1280function show_offcanvas(offcanvas_id) { 1281 darken_screen(true); 1282 $('#' + offcanvas_id).addClass('show'); 1283} 1284 1285$(document).ready(function () { 1286 $('[data-trigger]').each(function () { 1287 let offcanvas_id = $(this).attr('data-trigger'); 1288 1289 $(this).on('click', function (e) { 1290 e.preventDefault(); 1291 show_offcanvas(offcanvas_id); 1292 }); 1293 }); 1294 1295 $('.close').each(function () { 1296 $(this).on('click', function (e) { 1297 e.preventDefault(); 1298 close_offcanvas(); 1299 }); 1300 }); 1301 1302 $('.screen-darken').on('click', function () { 1303 close_offcanvas(); 1304 }); 1305 1306}); 1307 1308$(document).ready(function() { 1309 var width = $(window).width(); 1310 if (width <= 992) { 1311 $('.dropdown-submenu a.dropdown-submenu-toggle span').on("click", function(e){ 1312 e.stopPropagation(); 1313 e.preventDefault(); 1314 1315 let $ul = $(this).closest('a').next('ul'); 1316 1317 // Cerramos otros submenús abiertos 1318 $('.navbar .navbar-nav .dropdown-menu ul').not($ul).attr('style', 'display: none !important;'); 1319 $('.navbar .navbar-nav .dropdown-submenu-toggle span').not(this).removeClass('rotate'); // Quitamos rotación de otros Ãconos 1320 1321 // Alternamos el submenú actual 1322 if ($ul.is(':visible')) { 1323 $ul.attr('style', 'display: none !important;'); 1324 $(this).removeClass('rotate'); // Quitamos rotación si se cierra 1325 } else { 1326 $ul.attr('style', 'display: block !important;'); 1327 $(this).addClass('rotate'); // Añadimos rotación si se abre 1328 } 1329 1330 // Clear Submenu Dropdowns on hidden event 1331 $('#offcanvas').on('hidden.bs.dropdown', function () { 1332 $('.navbar-nav .dropdown-submenu ul.dropdown-menu').removeAttr('style'); 1333 $('.dropdown-submenu a.dropdown-submenu-toggle span').removeClass('rotate'); 1334 }); 1335 }); 1336 } 1337}); 1338 1339 1340function goLinkOfuscado(objSelect) { 1341 if (objSelect[objSelect.selectedIndex].value != "" && objSelect[objSelect.selectedIndex].value != '#') { 1342 window.location.href = window.atob(objSelect[objSelect.selectedIndex].value); 1343 } 1344} 1345 1346 1347document.fonts.ready.then(() => { 1348 document.body.classList.add('material-fonts-loaded'); 1349});
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.