$(document).ready(function() { $.extend( $.fn.dataTable.defaults, { "language" : { "sProcessing": "Procesando...", "sLengthMenu": "Mostrar _MENU_", "sZeroRecords": "No se han encontrado resultados", "sEmptyTable": "Sin datos todavía", "sInfo": "Mostrando _END_ de un total de _TOTAL_ entradas", "sInfoEmpty": "No hay ninguna entrada", "sInfoFiltered": "(filtrado de _MENU_ entradas)", "sSearchPlaceholder": "Buscar", "sInfoPostFix": "", "sSearch": "", "sUrl": "", "oPaginate": { "sFirst": " ", "sPrevious": " ", "sNext": " ", "sLast": " " } } }); }); function preparaLugar(pais, provincia, poblacion, idInputPais,idInputProvincia, idInputLocalidad) { if(pais > 0) { actualizaProvincias(idInputLocalidad,idInputProvincia, idInputPais, provincia, pais, provincia, poblacion, undefined); } $("#"+idInputPais).change(function() { actualizaProvincias(idInputLocalidad,idInputProvincia, idInputPais, provincia); }); if(provincia > 0) { actualizaCiudades(idInputLocalidad, idInputProvincia, idInputPais,poblacion, pais, provincia, poblacion, $("#"+idInputProvincia).val()*1); } $("#"+idInputProvincia).change(function() { actualizaCiudades(idInputLocalidad, idInputProvincia, idInputPais, undefined, $("#"+idInputPais).val()*1, $("#"+idInputProvincia).val()*1); }); } function actualizaProvincias(idCampoLocalidad, idCampoRegion, idCampoPais, idRegionPreEstablecida, forceIdPais, forceIdRegion,forceIdLocalidad, onFinish, textoSelect, textoLoading) { if(forceIdPais == undefined) { forceIdPais = $("#"+idCampoPais).val(); } if(forceIdRegion == undefined) { forceIdRegion = $("#"+idCampoRegion).val(); } if(forceIdLocalidad == undefined) { forceIdLocalidad = $("#"+idCampoLocalidad).val(); } if(textoSelect == undefined) { textoSelect = ""; } if(textoLoading == undefined) { textoLoading = "Cargando..."; } var data = { idPais: forceIdPais }; $("#"+idCampoRegion).empty(); $("#"+idCampoRegion).append( ""); var returned = $.ajax( { url: "ajax/Ubicacion.listadoRegiones.php?CSRF="+CSRF, type: "POST", dataType : "json", data : data, error: function(XMLHttpRequest, textStatus, errorThrown) { //ClassBlockUI.abrirBlockUIEstandarMensaje(XMLHttpRequest.responseText, true); }, success: function(data) { $("#"+idCampoRegion).empty(); $("#"+idCampoRegion).append( ""); for(var index in data) { $("#"+idCampoRegion).append( "" ); } if(idRegionPreEstablecida!=undefined) { $("#"+idCampoRegion).val(idRegionPreEstablecida); } if(onFinish != undefined && typeof(onFinish) == "function") { onFinish(); } } }); } function actualizaCiudades(idCampoLocalidad, idCampoRegion, idCampoPais, idLocalidadPreEstablecida, forceIdPais, forceIdRegion,forceIdLocalidad, onFinish, textoSelect, textoLoading) { if(forceIdPais == undefined) { forceIdPais = $("#"+idCampoPais).val(); } if(forceIdRegion == undefined) { forceIdRegion = $("#"+idCampoRegion).val(); } if(forceIdLocalidad == undefined) { forceIdLocalidad = $("#"+idCampoLocalidad).val(); } if(textoSelect == undefined) { textoSelect = ""; } if(textoLoading == undefined) { textoLoading = "Cargando..."; } var data = { idPais: forceIdPais, idRegion: forceIdRegion }; $("#"+idCampoLocalidad).empty(); $("#"+idCampoLocalidad).append( ""); var returned = $.ajax( { url: "ajax/Ubicacion.listadoCiudades.php?CSRF="+CSRF, type: "POST", dataType : "json", data : data, error: function(XMLHttpRequest, textStatus, errorThrown) { //ClassBlockUI.abrirBlockUIEstandarMensaje(XMLHttpRequest.responseText, true); }, success: function(data) { $("#"+idCampoLocalidad).empty(); $("#"+idCampoLocalidad).append( ""); for(var index in data) { $("#"+idCampoLocalidad).append( "" ); } if(idLocalidadPreEstablecida!=undefined) { $("#"+idCampoLocalidad).val(idLocalidadPreEstablecida); } if(onFinish != undefined && typeof(onFinish) == "function") { onFinish(); } } }); } function preparaMarcaModeloAnyoCoche(marca, modelo, anyo, idInputMarca,idInputModelo, idInputAnyo) { if(marca > 0) { actualizaModelos(idInputAnyo,idInputModelo, idInputMarca, modelo, marca, modelo, anyo, undefined); } $("#"+idInputMarca).unbind("change").change(function() { actualizaModelos(idInputAnyo,idInputModelo, idInputMarca, modelo); }); if(modelo > 0) { actualizaAnyos(idInputAnyo, idInputModelo, idInputMarca,anyo, marca, modelo, anyo, $("#"+idInputModelo).val()*1); } $("#"+idInputModelo).unbind("change").change(function() { actualizaAnyos(idInputAnyo, idInputModelo, idInputMarca, undefined, $("#"+idInputMarca).val()*1, $("#"+idInputModelo).val()*1); }); } function actualizaModelos(idCampoAnyo, idCampoModelo, idCampoMarca, idModeloPreEstablecida, forceIdMarca, forceIdModelo,forceIdAnyo, onFinish, textoSelect, textoLoading) { if(forceIdMarca == undefined) { forceIdMarca = $("#"+idCampoMarca).val(); } if(forceIdModelo == undefined) { forceIdModelo = $("#"+idCampoModelo).val(); } if(forceIdAnyo == undefined) { forceAnyo = $("#"+idCampoAnyo).val(); } if(textoSelect == undefined) { textoSelect = "Modelo"; } if(textoLoading == undefined) { textoLoading = "Cargando..."; } var data = { idMarca: forceIdMarca }; $("#"+idCampoModelo).empty(); $("#"+idCampoModelo).append( ""); var returned = $.ajax( { url: "ajax/Coches.listadoModelos.php?CSRF="+CSRF, type: "POST", dataType : "json", data : data, error: function(XMLHttpRequest, textStatus, errorThrown) { //ClassBlockUI.abrirBlockUIEstandarMensaje(XMLHttpRequest.responseText, true); }, success: function(data) { $("#"+idCampoModelo).empty(); $("#"+idCampoModelo).append( ""); for(var index in data) { $("#"+idCampoModelo).append( "" ); } if(idModeloPreEstablecida!=undefined) { $("#"+idCampoModelo).val(idModeloPreEstablecida); } if(onFinish != undefined && typeof(onFinish) == "function") { onFinish(); } } }); } function actualizaAnyos(idCampoAnyo, idCampoModelo, idCampoMarca, idAnyoPreEstablecida, forceIdMarca, forceIdModelo,forceIdAnyo, onFinish, textoSelect, textoLoading) { if(forceIdMarca == undefined) { forceIdMarca = $("#"+idCampoMarca).val(); } if(forceIdModelo == undefined) { forceIdModelo = $("#"+idCampoModelo).val(); } if(forceIdAnyo == undefined) { forceIdAnyo = $("#"+idCampoAnyo).val(); } if(textoSelect == undefined) { textoSelect = "Año"; } if(textoLoading == undefined) { textoLoading = "Cargando..."; } var data = { idMarca: forceIdMarca, idModelo: forceIdModelo }; $("#"+idCampoAnyo).empty(); $("#"+idCampoAnyo).append( ""); var returned = $.ajax( { url: "ajax/Coches.listadoAnyos.php?CSRF="+CSRF, type: "POST", dataType : "json", data : data, error: function(XMLHttpRequest, textStatus, errorThrown) { //ClassBlockUI.abrirBlockUIEstandarMensaje(XMLHttpRequest.responseText, true); }, success: function(data) { $("#"+idCampoAnyo).empty(); $("#"+idCampoAnyo).append( ""); for(var index in data) { $("#"+idCampoAnyo).append( "" ); } if(idAnyoPreEstablecida!=undefined) { $("#"+idCampoAnyo).val(idAnyoPreEstablecida); } if(onFinish != undefined && typeof(onFinish) == "function") { onFinish(); } } }); } /* 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").size()>0){$("body").addClass("modal-open")} if(contenedorIDAMostrar == undefined || $("#"+contenedorIDAMostrar).size() == 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); $("#"+contenedorIDAMostrar).show(); modal.find(".modal-dialog").addClass("zoomInDown"); modal.modal({backdrop: false}); modal.on('hidden.bs.modal', function () { ClassBlockUI.restaurarElemento(); }) if(accionCerrar==undefined) //boton cerrar tiene accion por defecto { $("#"+blockUIId+" .btnCerrarModalEquis").makeTagLink(function(){ modal.modal("hide"); if($(".modal").size()>0){$("body").addClass("modal-open")} }); } else if(accionCerrar==false) //oculta el boton cerrar { $("#"+blockUIId+" .btnCerrarModalEquis").hide(); } else //boton cerrar con accion especial { $("#"+blockUIId+" .btnCerrarModalEquis").makeTagLink(accionCerrar); } return modal; }, abrirBlockUIEstandarMensaje: function(mensaje, isAlertOrButtons, onClose, extraClass) { $(".modalAutoHide").modal("hide"); if($(".modal").size()>0){$("body").addClass("modal-open")} var blockUIId="blockUI_"+new Date().getTime(); extraClass = extraClass == null || extraClass == undefined ? "" : extraClass; //modal-lg if(isAlertOrButtons==undefined) isAlertOrButtons=false; if(onClose==undefined) onClose=false; var botonera = ""; var botoneraEspecial = false; if(isAlertOrButtons === false) { botonera = ""; } else if (isAlertOrButtons === true) { botonera = "
Aceptar
"; } 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").addClass("zoomInDown"); modal.modal({backdrop: false}); modal.on('hidden.bs.modal', function () { modal.remove(); }) //Acciones de los botones especiales if(botoneraEspecial) { for(var index in isAlertOrButtons) { if(isAlertOrButtons[index]["action"] == "close") { isAlertOrButtons[index]["action"] = function(){ modal.modal("hide"); if($(".modal").size()>0){$("body").addClass("modal-open")} }; } $("#"+blockUIId+" ."+index).unbind("click").makeTagLink(isAlertOrButtons[index]["action"]); } } var fnOnClose; if(onClose==false) { fnOnClose = function(){ modal.modal("hide"); if($(".modal").size()>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 { if(onClose.indexOf("/") !=0 && onClose.indexOf("http") !=0) { onClose = "/"+onClose; } fnOnClose = function(){window.location = onClose}; } $("#"+blockUIId+" .btnCerrarBlockUIAlert, #"+blockUIId+" .btnCerrarModalEquis").unbind("click").makeTagLink(fnOnClose); return modal; }, abrirBlockUIConfirm: function(mensaje, textoAceptar, accionAceptar, textoCancelar, accionCancelar) { accionCancelar = accionCancelar == undefined ? "close" : accionCancelar; var buttons = { "btnAceptarBUI_CONFIRM": { "text": textoAceptar, "action": accionAceptar }, "btnCancelarBUI_CONFIRM": { "text": textoCancelar, "action": accionCancelar } }; return ClassBlockUI.abrirBlockUIEstandarMensaje(mensaje, buttons, false, ""); }, abrirBlockUIEsperePorFavor: function(mensaje) { if(mensaje == undefined){ mensaje = "
Loading ... Espere por favor...
"; }; return ClassBlockUI.abrirBlockUIEstandarMensaje(mensaje, undefined, false, "modalStandard"); } }; var ClassMarcas = { init: function(loopCarousel) { $("body").on("click",".contieneMarca",function(event) { ClassMarcas.actualizarDatosMarcaSeleccionada($(this)); }); // Owl Carousel var $owlCarousel = $(".owl-carousel"); $owlCarousel.on("translated.owl.carousel", function(event) { $(".owl-stage .owl-item:not(:eq("+event.item.index+"))").removeClass("owl-selected"); var current = $(".owl-stage .owl-item:eq("+event.item.index+")"); current.addClass("owl-selected"); current.find(".contieneMarca").trigger("click"); }); if( $owlCarousel.length ){ $owlCarousel.each(function() { var items = parseInt( $(this).attr("data-owl-items"), 10); if( !items ) items = 1; var nav = parseInt( $(this).attr("data-owl-nav"), 2); if( !nav ) nav = 0; var dots = parseInt( $(this).attr("data-owl-dots"), 2); if( !dots ) dots = 0; var center = parseInt( $(this).attr("data-owl-center"), 2); if( !center ) center = 0; var loop = loopCarousel; var margin = parseInt( $(this).attr("data-owl-margin"), 2); if( !margin ) margin = 0; var autoWidth = parseInt( $(this).attr("data-owl-auto-width"), 2); if( !autoWidth ) autoWidth = 0; var navContainer = $(this).attr("data-owl-nav-container"); if( !navContainer ) navContainer = 0; var autoplay = parseInt( $(this).attr("data-owl-autoplay"), 2); if( !autoplay ) autoplay = 0; var autoplayTimeOut = parseInt( $(this).attr("data-owl-autoplay-timeout"), 10); if( !autoplayTimeOut ) autoplayTimeOut = 5000; var autoplayHoverPause = parseInt( $(this).attr("data-owl-autoplay-hover-pause"), 0); if( !autoplayHoverPause ) autoplayTimeOut = false; var autoHeight = parseInt( $(this).attr("data-owl-auto-height"), 2); if( !autoHeight ) autoHeight = 0; var fadeOut = $(this).attr("data-owl-fadeout"); if( !fadeOut ) fadeOut = 0; else fadeOut = "fadeOut"; if( $("body").hasClass("rtl") ) var rtl = true; else rtl = false; if( items === 1 ){ $(this).owlCarousel({ autoplay: 0, center: center, loop: 0, margin: 0, items: 1, nav: false, dots: false, }); } else { $(this).owlCarousel({ //center: loop == 1 ? true : false, loop: loop, autoplay: autoplay, autoplayTimeout: autoplayTimeOut, //autoplayHoverPause:autoplayHoverPause, lazyLoad:true, margin: 0, items: 1, nav: true, navText: ["", ""], dots: false, dotsEach: true, responsive: { 1368: { items: items }, 992: { items: 5 }, 768: { items: 4 }, 450: { items: 2 }, 0: { items: 1 } } }); } if( $(this).find(".owl-item").length === 1 ){ $(this).find(".owl-nav").css( { "opacity": 0,"pointer-events": "none"} ); } }); } }, actualizarDatosMarcaSeleccionada:function(e) { tituloMarcaSeleccionada = e.attr("data-titulo"); $(".logoMarcaSeleccionada img").attr("src", e.attr("data-logo")).attr("alt", tituloMarcaSeleccionada).attr("title", tituloMarcaSeleccionada); if(e.attr("data-tipoBanner") == 1) { imagenBanner = ''+tituloMarcaSeleccionada+''; $(".IMGBannerMarcaSeleccionada").html(imagenBanner); } else { videoBanner = ''; $(".IMGBannerMarcaSeleccionada").html(videoBanner); } $(".tituloBannerMarcaSeleccionada").html(tituloMarcaSeleccionada); $(".enlaceBannerMarcaSeleccionada").attr("href", e.attr("data-enlace")); } }; var ClassAccesoriosWeb = { init: function(loopCarousel,offset, limit,idFamiliaAccesorio) { $(".ts-image-foto").each(function () { var $this = $(this); if ($this.attr("data-bg-image") !== undefined) { $this.css("background-image", "url(" + $this.attr("data-bg-image") + ")"); $this.css("background-size", $this.attr("data-bg-size")); $this.css("background-repeat", $this.attr("data-bg-repeat")); $this.css("background-position", $this.attr("data-bg-position")); $this.css("background-blend-mode", $this.attr("data-bg-blend-mode")); } }); var $pphoto = $('a[data-gal^="prettyPhoto[gallery]"]'); if ($pphoto.length) { $pphoto.prettyPhoto({ hook: 'data-gal', show_title: false, deeplinking: false, social_tools: false, default_width: 1000, default_height: 1000 }); } // Owl Carousel var $owlCarousel = $(".owl-carousel"); if( $owlCarousel.length ){ $owlCarousel.each(function() { var items = parseInt( $(this).attr("data-owl-items"), 10); if( !items ) items = 1; var nav = parseInt( $(this).attr("data-owl-nav"), 2); if( !nav ) nav = 0; var dots = parseInt( $(this).attr("data-owl-dots"), 2); if( !dots ) dots = 0; var center = parseInt( $(this).attr("data-owl-center"), 2); if( !center ) center = 0; var loop = loopCarousel; var margin = parseInt( $(this).attr("data-owl-margin"), 2); if( !margin ) margin = 0; var autoWidth = parseInt( $(this).attr("data-owl-auto-width"), 2); if( !autoWidth ) autoWidth = 0; var navContainer = $(this).attr("data-owl-nav-container"); if( !navContainer ) navContainer = 0; var autoplay = parseInt( $(this).attr("data-owl-autoplay"), 2); if( !autoplay ) autoplay = 0; var autoplayTimeOut = parseInt( $(this).attr("data-owl-autoplay-timeout"), 10); if( !autoplayTimeOut ) autoplayTimeOut = 5000; var autoHeight = parseInt( $(this).attr("data-owl-auto-height"), 2); if( !autoHeight ) autoHeight = 0; var fadeOut = $(this).attr("data-owl-fadeout"); if( !fadeOut ) fadeOut = 0; else fadeOut = "fadeOut"; if( $("body").hasClass("rtl") ) var rtl = true; else rtl = false; if( items === 1 ){ $(this).owlCarousel({ autoplay: 0, center: center, loop: 0, margin: 0, items: 1, nav: false, dots: false, }); } else { $(this).owlCarousel({ //center: loop == 1 ? true : false, loop: loop, lazyLoad:true, margin: 5, items: 1, nav: false, navText: ["", ""], dots: false, dotsEach: true, responsive: { 1368: { items: items }, 992: { items: 6 }, 450: { items: 4 }, 0: { items: 2 } } }); } if( $(this).find(".owl-item").length === 1 ){ $(this).find(".owl-nav").css( { "opacity": 0,"pointer-events": "none"} ); } }); } } }; var ClassAccesoriosWebDetalle = { init: function(loopCarousel,offset, limit,idFamiliaAccesorio) { $("body").on("click",".imgAccesorioS",function(event) { ClassAccesoriosWebDetalle.actualizarFotoGrande($(this)); }); ClassAccesoriosWebDetalle.setPrettyPhoto(); // Owl Carousel var $owlCarousel = $(".owl-carousel"); if( $owlCarousel.length ){ $owlCarousel.each(function() { var items = parseInt( $(this).attr("data-owl-items"), 10); if( !items ) items = 1; var nav = parseInt( $(this).attr("data-owl-nav"), 2); if( !nav ) nav = 0; var dots = parseInt( $(this).attr("data-owl-dots"), 2); if( !dots ) dots = 0; var center = parseInt( $(this).attr("data-owl-center"), 2); if( !center ) center = 0; var loop = loopCarousel; var margin = parseInt( $(this).attr("data-owl-margin"), 2); if( !margin ) margin = 0; var autoWidth = parseInt( $(this).attr("data-owl-auto-width"), 2); if( !autoWidth ) autoWidth = 0; var navContainer = $(this).attr("data-owl-nav-container"); if( !navContainer ) navContainer = 0; var autoplay = parseInt( $(this).attr("data-owl-autoplay"), 2); if( !autoplay ) autoplay = 0; var autoplayTimeOut = parseInt( $(this).attr("data-owl-autoplay-timeout"), 10); if( !autoplayTimeOut ) autoplayTimeOut = 5000; var autoHeight = parseInt( $(this).attr("data-owl-auto-height"), 2); if( !autoHeight ) autoHeight = 0; var fadeOut = $(this).attr("data-owl-fadeout"); if( !fadeOut ) fadeOut = 0; else fadeOut = "fadeOut"; if( $("body").hasClass("rtl") ) var rtl = true; else rtl = false; if( items === 1 ){ $(this).owlCarousel({ autoplay: 0, center: center, loop: 0, margin: 0, items: 1, nav: false, dots: false, }); } else { $(this).owlCarousel({ //center: loop == 1 ? true : false, loop: loop, lazyLoad:true, margin: 5, items: 1, nav: false, navText: ["", ""], dots: false, dotsEach: true, responsive: { 1368: { items: items }, 992: { items: 6 }, 450: { items: 4 }, 0: { items: 2 } } }); } if( $(this).find(".owl-item").length === 1 ){ $(this).find(".owl-nav").css( { "opacity": 0,"pointer-events": "none"} ); } }); } }, actualizarFotoGrande:function(elemento) { //e.preventDefault(); idFoto = elemento.attr("data-idfoto"); //console.log(idFoto, "img/accesorios/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG img").attr("src","img/accesorios/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG").attr("data-bg-image","img/accesorios/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG").attr("href","img/accesorios/"+zero_fill(idFoto,5)+"SG.jpg"); //Activamos todos los antiguos $(".imagenGaleria").removeClass("prettyPhotoDisabled"); //Desactivamos el de ahora $(".imagenGaleria" + idFoto).addClass("prettyPhotoDisabled"); //Cambiamos la imagen grande /* $(".imgAccesorioG").attr("href", $(this).parents(".itemFoto").children(".imagenGaleria").attr("href")); $(".imgAccesorioG img").attr("src", $(this).parents(".itemFoto").find("img").attr("src"));*/ //Volvemos a cagar las iamgenes ClassAccesoriosWebDetalle.setPrettyPhoto(); }, setPrettyPhoto:function() { var $pphoto = $('a[data-gal^="prettyPhoto[gallery]"]:not(.prettyPhotoDisabled)'); //.imgAccesorioG , .itemFoto if ($pphoto.length) { $pphoto.prettyPhoto({ hook: 'data-gal', show_title: false, deeplinking: false, social_tools: false, default_width: 1000, default_height: 1000 }); } } }; var ClassModelosAcabados = { init: function(loopCarousel, offset, limit, idMarca, novedades, dedicadas, promociones, outlet) { // Owl Carousel var $owlCarousel = $(".owl-carousel"); if( $owlCarousel.length ){ $owlCarousel.each(function() { var items = parseInt( $(this).attr("data-owl-items"), 10); if( !items ) items = 1; var nav = parseInt( $(this).attr("data-owl-nav"), 2); if( !nav ) nav = 0; var dots = parseInt( $(this).attr("data-owl-dots"), 2); if( !dots ) dots = 0; var center = parseInt( $(this).attr("data-owl-center"), 2); if( !center ) center = 0; var loop = loopCarousel; var margin = parseInt( $(this).attr("data-owl-margin"), 2); if( !margin ) margin = 0; var autoWidth = parseInt( $(this).attr("data-owl-auto-width"), 2); if( !autoWidth ) autoWidth = 0; var navContainer = $(this).attr("data-owl-nav-container"); if( !navContainer ) navContainer = 0; var autoplay = parseInt( $(this).attr("data-owl-autoplay"), 2); if( !autoplay ) autoplay = 0; var autoplayTimeOut = parseInt( $(this).attr("data-owl-autoplay-timeout"), 10); if( !autoplayTimeOut ) autoplayTimeOut = 5000; var autoplayHoverPause = parseInt( $(this).attr("data-owl-autoplay-hover-pause"), 0); if( !autoplayHoverPause ) autoplayTimeOut = false; var autoHeight = parseInt( $(this).attr("data-owl-auto-height"), 2); if( !autoHeight ) autoHeight = 0; var fadeOut = $(this).attr("data-owl-fadeout"); if( !fadeOut ) fadeOut = 0; else fadeOut = "fadeOut"; if( $("body").hasClass("rtl") ) var rtl = true; else rtl = false; if( items === 1 ){ $(this).owlCarousel({ autoplay: 0, center: center, loop: 0, margin: 0, items: 1, nav: false, dots: false, }); } else { $(this).owlCarousel({ //center: loop == 1 ? true : false, loop: loop, lazyLoad:true, autoplay: autoplay, autoplayTimeout: autoplayTimeOut, //autoplayHoverPause:autoplayHoverPause, margin: 20, items: 1, nav: true, navText: ["", ""], dots: false, dotsEach: true, responsive: { 1368: { items: items }, 992: { items: 3 }, 450: { items: 2 }, 0: { items: 1 } } }); } if( $(this).find(".owl-item").length === 1 ){ $(this).find(".owl-nav").css( { "opacity": 0,"pointer-events": "none"} ); } }); } } }; var ClassModelosAcabadosDetalle = { init: function(loopCarousel) { $("body").on("click",".imgAccesorioS",function(event) { ClassModelosAcabadosDetalle.actualizarFotoGrande($(this)); }); ClassModelosAcabadosDetalle.setPrettyPhoto(); // Owl Carousel var $owlCarousel = $(".owl-carousel"); if( $owlCarousel.length ){ $owlCarousel.each(function() { var items = parseInt( $(this).attr("data-owl-items"), 10); if( !items ) items = 1; var nav = parseInt( $(this).attr("data-owl-nav"), 2); if( !nav ) nav = 0; var dots = parseInt( $(this).attr("data-owl-dots"), 2); if( !dots ) dots = 0; var center = parseInt( $(this).attr("data-owl-center"), 2); if( !center ) center = 0; var loop = loopCarousel; var margin = parseInt( $(this).attr("data-owl-margin"), 2); if( !margin ) margin = 0; var autoWidth = parseInt( $(this).attr("data-owl-auto-width"), 2); if( !autoWidth ) autoWidth = 0; var navContainer = $(this).attr("data-owl-nav-container"); if( !navContainer ) navContainer = 0; var autoplay = parseInt( $(this).attr("data-owl-autoplay"), 2); if( !autoplay ) autoplay = 0; var autoplayTimeOut = parseInt( $(this).attr("data-owl-autoplay-timeout"), 10); if( !autoplayTimeOut ) autoplayTimeOut = 5000; var autoplayHoverPause = parseInt( $(this).attr("data-owl-autoplay-hover-pause"), 0); if( !autoplayHoverPause ) autoplayTimeOut = false; var autoHeight = parseInt( $(this).attr("data-owl-auto-height"), 2); if( !autoHeight ) autoHeight = 0; var fadeOut = $(this).attr("data-owl-fadeout"); if( !fadeOut ) fadeOut = 0; else fadeOut = "fadeOut"; if( $("body").hasClass("rtl") ) var rtl = true; else rtl = false; if( items === 1 ){ $(this).owlCarousel({ autoplay: 0, center: center, loop: 0, margin: 0, items: 1, nav: false, dots: false, }); } else { $(this).owlCarousel({ //center: loop == 1 ? true : false, loop: loop, lazyLoad:true, autoplay: autoplay, autoplayTimeout: autoplayTimeOut, //autoplayHoverPause:autoplayHoverPause, margin: 20, items: 1, nav: true, navText: ["", ""], dots: false, dotsEach: true, responsive: { 1368: { items: items }, 992: { items: 3 }, 450: { items: 2 }, 0: { items: 1 } } }); } if( $(this).find(".owl-item").length === 1 ){ $(this).find(".owl-nav").css( { "opacity": 0,"pointer-events": "none"} ); } }); } }, actualizarFotoGrande:function(elemento) { //e.preventDefault(); idFoto = elemento.attr("data-idfoto"); //console.log(idFoto, "img/llantas/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG img").attr("src","img/llantas/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG").attr("data-bg-image","img/llantas/"+zero_fill(idFoto,5)+"G.jpg"); $(".imgAccesorioG").attr("href","img/llantas/"+zero_fill(idFoto,5)+"SG.jpg"); //Activamos todos los antiguos $(".imagenGaleria").removeClass("prettyPhotoDisabled"); //Desactivamos el de ahora $(".imagenGaleria" + idFoto).addClass("prettyPhotoDisabled"); //Cambiamos la imagen grande /* $(".imgAccesorioG").attr("href", $(this).parents(".itemFoto").children(".imagenGaleria").attr("href")); $(".imgAccesorioG img").attr("src", $(this).parents(".itemFoto").find("img").attr("src"));*/ //Volvemos a cagar las iamgenes ClassModelosAcabadosDetalle.setPrettyPhoto(); }, setPrettyPhoto:function() { var $pphoto = $('a[data-gal^="prettyPhoto[gallery]"]:not(.prettyPhotoDisabled)'); //.imgAccesorioG , .itemFoto if ($pphoto.length) { $pphoto.prettyPhoto({ hook: 'data-gal', show_title: false, deeplinking: false, social_tools: false, default_width: 900, default_height: 900 }); } } }; var ClassGaleria = { init: function(tipo) { switch(tipo) { default: case "1": default_width = 1000; default_height = 1000; break; case "2": default_width = 1000; default_height = 1000; break; case "3": default_width = 1000; default_height = 1000; break; } $(".ts-image").each(function () { var $this = $(this); if ($this.attr("data-bg-image") !== undefined) { $this.css("background-image", "url(" + $this.attr("data-bg-image") + ")"); $this.css("background-size", $this.attr("data-bg-size")); $this.css("background-repeat", $this.attr("data-bg-repeat")); $this.css("background-position", $this.attr("data-bg-position")); $this.css("background-blend-mode", $this.attr("data-bg-blend-mode")); } }); var $pphoto = $('a[data-gal^="prettyPhoto[gallery2]"]'); if ($pphoto.length) { $pphoto.prettyPhoto({ hook: 'data-gal', show_title: false, deeplinking: false, social_tools: false, default_width: default_width, default_height: default_height }); } } };