const navText = [ '', '' ]; class Web { static init() { Web.initDynamicBG(); $(document).ready(function(e) { $.each($("#cookiesWeb .btnStandard, .bloqueLegalCookies .btnStandard"), function (i, e) { const txt = $(e).text(); $(e).html(''+txt+''); }); const btnSubir = $("#btn-subir"); let toScroll = null; $(window).scroll(function () { let scrollPosition = $(window).scrollTop(); if (scrollPosition > 300) { clearTimeout(toScroll); toScroll = setTimeout(function () { btnSubir.removeClass("d-none"); }, 100); } else { clearTimeout(toScroll); btnSubir.addClass("d-none"); } btnSubir.click(function () { clearTimeout(toScroll); window.scrollTo({top: 0, behavior: 'smooth'}); $(this).addClass("d-none"); }); }); new WOW( { boxClass: "title-animation", offset: 50, callback: function(box) { $(box).addClass("animate"); } } ).init(); }); } static initInicio() { } static initFichaArea() { $(document).ready(function () { const elementCarouselFotosPrincipal = $("#ficha-area-foto-principal"); let numItems = elementCarouselFotosPrincipal.find(".item-foto").length; elementCarouselFotosPrincipal.owlCarousel({ margin: 18, nav: false, dots: false, stagePadding: 1, lazyLoad: true, items: 1, loop: numItems > 1, drag: numItems > 1 }); const elementCarouselFotosSecundarias = $("#ficha-area-fotos-secundarias"); let numItemsSec = elementCarouselFotosSecundarias.find(".item-foto").length; elementCarouselFotosSecundarias.owlCarousel({ margin: 24, nav: true, navText: navText, dots: false, stagePadding: 1, lazyLoad: true, items: 1, responsive: { 0: { items: 3, loop: numItemsSec > 3, }, 576: { items: 4, loop: numItemsSec > 4, } } }); elementCarouselFotosPrincipal.on("click", ".item-foto", function (e) { e.preventDefault(); const fotoId = $(this).data("foto"); const $item = $("#gallery-dimbox").find(`a[data-foto="${fotoId}"]`); if ($item.length === 0) return; dimbox.open($item[0]); }); elementCarouselFotosPrincipal.on("translated.owl.carousel", function (e) { if (elementCarouselFotosSecundarias.length === 0) return; const $fotoActual = elementCarouselFotosPrincipal.find(".owl-item.active:not(.cloned) .item-foto").first(); const fotoId = $fotoActual.data("foto"); elementCarouselFotosSecundarias.find(".item-foto").removeClass("active"); elementCarouselFotosSecundarias.find(`.item-foto[data-foto="${fotoId}"]`).addClass("active"); }); elementCarouselFotosSecundarias.on("click", ".item-foto", function (e) { e.preventDefault(); const fotoId = $(this).data("foto"); const $itemsPrincipales = elementCarouselFotosPrincipal.find(".owl-item:not(.cloned) .item-foto"); let indexReal = -1; $itemsPrincipales.each(function (i) { if ($(this).data("foto") == fotoId) { indexReal = i; return false; } }); elementCarouselFotosSecundarias.find(".item-foto").removeClass("active"); $(this).addClass("active"); elementCarouselFotosPrincipal.trigger("to.owl.carousel", [indexReal, 300, true]); }); }); } static initCarouselAreas() { $(document).ready(function () { const elementCarousel = $("#carousel-areas-produccion"); if (elementCarousel.length === 0) return; let numItems = elementCarousel.find(".item-area").length; elementCarousel.owlCarousel({ loop: true, margin: 24, nav: false, dots: false, navText: navText, responsive: { 0: { items: 1, loop: numItems > 1, stagePadding: numItems > 1 ? 40 : 0 }, 576: { items: 2, loop: numItems > 2, stagePadding: numItems > 2 ? 20 : 0 }, 768: { items: 2, loop: numItems > 2, stagePadding: numItems > 2 ? 90 : 0 }, 992: { items: 3, loop: numItems > 3, stagePadding: numItems > 3 ? 70 : 0 }, 1200: { items: 4, loop: numItems > 4, } } }); }) } static initDynamicBG() { $(document).ready(function () { new WOW( { boxClass: "dynamic-bg", //offset: 200, callback: function(box) { $(box).addClass("loaded"); }, } ).init(); }); } static initTexto() { $("document").ready(function() { //$(".textoSeccion a").attr("target", "_blank"); $(".textoSeccion a[href^='tel']").removeAttr("target"); $(".textoSeccion img[style^='float: left'], .textoSeccion img[style^='float:left']").addClass("margin-right-20 margin-bottom-20 img-float"); $(".textoSeccion img[style^='float: right'], .textoSeccion img[style^='float:right']").addClass("margin-left-20 margin-bottom-20 img-float"); $(".textoSeccion img:not(.imagenDerecha)").addClass("img-fluid").css("max-width", "100%").css("height", "auto").css("object-fit", "cover"); }); } static initBanner() { $(document).ready(function () { if ($('#carousel-banner').length) { $('#carousel-banner').owlCarousel({ animateOut: 'fadeOut', animateIn: 'fadeIn', loop:true, lazyLoad:true, margin:0, nav:true, navText: navText, dots:false, mouseDrag: false, smartSpeed: 900, autoplay: true, autoplayTimeout: 7000, items:1, }); } }); } static initContacto() { $(document).ready(function(e) { $("#btnEnviarContacto").click(enviarFormulario); }); function enviarFormulario(event) { event.preventDefault(); var extraMsg = ""; if (!$("#politica").is(":checked")) { extraMsg = $("#politica").attr("title"); } Utils.sendStandardAjax("formContacto", "https://www.prodeintec.es/ajax/Contacto.enviar.php", { extraErroresForm: extraMsg, successCallback: null, resetFormOnSuccess: true }); } } } function findPos(obj) { var curtop = 0; if (obj.offsetParent) { do { curtop += obj.offsetTop; } while (obj = obj.offsetParent); return [curtop]; } } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } /* ClassBlockUI.abrirBlockUIEstandar(contenedorIDAMostrar[, accionCerrar, headerText, extraClass, restaurarElemento]); ClassBlockUI.abrirBlockUIEstandarMensaje(mensaje[, isAlertOrButtons, onClose]); ClassBlockUI.abrirBlockUIConfirm(mensaje, textoBotonAceptar, accionBotonAceptar, textoBotonCancelar[, accionBotonCancelar]); //accionBotonCancelar="close" ClassBlockUI.abrirBlockUIEsperePorFavor:([mensaje]); */ var ClassBlockUI = { restaurarElemento: function() { var data = $("body").data('blockUIEstandar.history'); if (data) { data.el.style.display = data.display; data.el.style.position = data.position; if (data.parent) data.parent.appendChild(data.el); $("body").removeData('blockUIEstandar.history'); $("#"+data.generatedId).remove(); } }, abrirBlockUIEstandar: function(contenedorIDAMostrar, accionCerrar, headerText, extraClass, restaurarElemento) { if(restaurarElemento || restaurarElemento == undefined) { ClassBlockUI.restaurarElemento(); } $(".modalAutoHide").modal("hide"); if($(".modal").length>0){$("body").addClass("modal-open")} if(contenedorIDAMostrar == undefined || $("#"+contenedorIDAMostrar).length == 0){return;} //var blockUIId="blockUI_"+new Date().getTime(); var blockUIId="blockUI_"+contenedorIDAMostrar; extraClass = extraClass == undefined ? "" : extraClass; //modal-lg var object = $("#"+contenedorIDAMostrar); var node = object[0]; var data = {}; $("body").data('blockUIEstandar.history', data); data.el = node; data.parent = node.parentNode; data.display = node.style.display; data.position = node.style.position; data.generatedId = blockUIId; data.object = object; if (data.parent) data.parent.removeChild(node); var header = headerText != undefined ? headerText : ""; var message = ''+ ''; $("body").append(message); var modal = $("#"+blockUIId); modal.find(".modal-body").append(node); modal.find(".modal-dialog").addClass("fadeIn"); modal.on('hidden.bs.modal', function () { ClassBlockUI.restaurarElemento(); }) var myModal = new bootstrap.Modal($(modal)[0], { keyboard: false }) myModal.show(); if(accionCerrar==undefined) //boton cerrar tiene accion por defecto { $("#"+blockUIId+" .btnCerrarModalEquis").click(function(){ myModal.hide(); if($(".modal").length>0){$("body").addClass("modal-open")} }); } else if(accionCerrar==false) //oculta el boton cerrar { $("#"+blockUIId+" .btnCerrarModalEquis").hide(); } else //boton cerrar con accion especial { $("#"+blockUIId+" .btnCerrarModalEquis").click(accionCerrar); } return modal; }, abrirBlockUIEstandarMensaje: function(mensaje, isAlertOrButtons, onClose, extraClass, title) { $(".modalAutoHide").modal("hide"); if($(".modal").length>0){$("body").addClass("modal-open")} var blockUIId="blockUI_"+new Date().getTime(); extraClass = extraClass == null || extraClass == undefined ? "" : extraClass; //modal-lg title = title == null || title == undefined ? "Aviso" : title; if(isAlertOrButtons==undefined) isAlertOrButtons=false; if(onClose==undefined) onClose=false; var botonera = ""; var botoneraEspecial = false; if(isAlertOrButtons === false) { botonera = ""; } else if (isAlertOrButtons === true) { let textoBoton = "Aceptar"; botonera = `
`; } else { botoneraEspecial = true; botonera = "
"; for(var index in isAlertOrButtons) { botonera += " "+isAlertOrButtons[index]["text"]+" "; } botonera += "
"; } var message = ''; message += ''; $("body").append(message); var modal = $("#"+blockUIId); modal.find(".modal-dialog").css("animation-duration", "500ms").addClass("zoomIn"); modal.on('hidden.bs.modal', function () { modal.remove(); }) var myModal = new bootstrap.Modal($(modal)[0], { keyboard: false }); myModal.show(); //Acciones de los botones especiales if(botoneraEspecial) { for(var index in isAlertOrButtons) { if(isAlertOrButtons[index]["action"] == "close") { isAlertOrButtons[index]["action"] = function(){ myModal.hide(); if($(".modal").length>0){$("body").addClass("modal-open")} }; } $("#"+blockUIId+" ."+index).unbind("click").click(isAlertOrButtons[index]["action"]); } } var fnOnClose; if(onClose==false) { fnOnClose = function(){ myModal.hide(); if($(".modal").length>0){$("body").addClass("modal-open")} }; } else if (typeof onClose === "function") { fnOnClose = function(){onClose()}; } else if (onClose == "location") { fnOnClose = function(){window.location.reload()}; } else if (onClose == "back") { fnOnClose = function(){history.go(-1);}; } else { fnOnClose = function(){window.location = onClose}; } $("#"+blockUIId+" .btnCerrarBlockUIAlert, #"+blockUIId+" .btnCerrarModalEquis").unbind("click").click(fnOnClose); return modal; }, abrirBlockUIConfirm: function(mensaje, textoAceptar, accionAceptar, textoCancelar, accionCancelar, extraClass, title) { accionCancelar = accionCancelar == undefined ? "close" : accionCancelar; extraClass = extraClass == null || extraClass == undefined ? "" : extraClass; var buttons = { "btnAceptarBUI_CONFIRM": { "text": textoAceptar, "action": accionAceptar }, "btnCancelarBUI_CONFIRM": { "text": textoCancelar, "action": accionCancelar } }; return ClassBlockUI.abrirBlockUIEstandarMensaje(mensaje, buttons, false, extraClass, title); }, abrirBlockUIEsperePorFavor: function(mensaje) { if(mensaje == undefined){ mensaje = "
Espere por favor...
"; }; return ClassBlockUI.abrirBlockUIEstandarMensaje(mensaje, undefined, false, "modalEspere"); } };