var SALE_STATUS = { ONSALE: 0, ONLYBOXOFFICE: 1, COMINGSOON: 2, SOLDOUT: 3, CUSTOM: 4, COUNTDOWN: 5 }; $(document).ready(function(){ establecerAltura(); lightbox.option({ 'resizeDuration': 200, 'wrapAround': true, 'fitImagesInViewport': true }); if(countdownReloadEventPage != null && countdownReloadEventPage) { userIsReloader(); } if(sale_status != null && sale_status == SALE_STATUS.COUNTDOWN) { if(initSaleDateLong == null || initSaleDateLong <= 0) { //show and enable button enableButtonToBuy(); } else { //init countdown initCountdownToBuy(); } } //Init Google Maps Iframe setTimeout(function(){ mapIframe(); }, 1000); }); $(document).foundation(); //recalcular al rotar $(window).bind("orientationchange", establecerAltura); //recalcular al cambiar tamaƱo de ventana $(window).on("resize", establecerAltura); function establecerAltura() { var h = $(window).height(); var w = $(window).width(); var hf = h; if(w < 640){ hf = h/2.5; }else{ hf = h*0.67; } //banner //If is iframe (widget) if(iframeMode != null && iframeMode) { $("#bannerFicha").css("height",(w/2)+"px"); } else { $("#bannerFicha").css("height",hf+"px"); } //Google Maps if($("#section_mapa")[0]) { var anchoReferencia = $("#referencia-ancho-cuerpo-evento").innerWidth(); var marginLateralResultado = (w-anchoReferencia)/2; var anchoInfomapa = $("#info-maps").innerHeight(); var marginLateralResultado = ((w-anchoReferencia)/2)+40; var anchoResultado = anchoReferencia/3; var alturaMapa = h*0.4; var bottomInfoMapa = (alturaMapa-anchoInfomapa)/2; //movil if(w < 640) { anchoResultado = (anchoReferencia/12)*8; marginLateralResultado = (w/12)*2; alturaMapa = h*0.7; } else { $("#info-maps").css("bottom","-"+bottomInfoMapa+"px"); } //contenedor mapa zonas svg $("#info-maps").css("width",anchoResultado+"px"); $("#info-maps").css("left",marginLateralResultado+"px"); $("#cont-maps").css("height",alturaMapa+"px"); $("#map").css("height",alturaMapa+"px"); } } /* Google Maps */ function mapIframe() { if (denyExternalUrlsMode) return; var hcont = $("#cont-maps").outerHeight(); //sumamos 150 a la altura del contenedor para ocultar el card de Maps desplazando el iframe var codeMaps = ""; $("#map-wrapper").html(codeMaps); } /* Fin Google Maps */ var countDownSeconds = 0; /* * Reload page funcionality */ function userIsReloader() { var obh = localStorage.getItem('loading_event_'+id_event); var objectReload = null; if(obh != null) { objectReload = JSON.parse(obh); } if(objectReload != null) { var timeReload = objectReload.time; var lastReload = objectReload.last_reload; if(timeReload != null && lastReload != null) { //console.info( "This page is reloaded" ); var obh = localStorage.getItem('loading_event_'+id_event); var objectReload = JSON.parse(obh); if(objectReload != null) { /* update local storage*/ var timeNew = timeReload + 1; var d = getDateCorrectedServer(); var newObjectReload = { 'last_reload' : d.getTime(), 'time' : timeNew }; localStorage.setItem("loading_event_"+id_event, JSON.stringify(newObjectReload)); /* calculate penalization */ countDownSeconds = 0; if(timeNew > 2) { countDownSeconds = 2 + (3 * timeNew); //calculate last refresh var nowMoment = new dayjs(); var lastReloadMoment = dayjs(lastReload); var diff = nowMoment.diff(lastReloadMoment, 'seconds'); // Diff in seconds // if user has waited 5 minutes if(diff > (60*5)) { countDownSeconds = 0; initLocalReload(); } } if(countDownSeconds > 0) { /* Show message in window */ $.blockUI( { message: $('#message-reloaded-page-component'), showOverlay: true, overlayCSS: { backgroundColor: '#fff', opacity: 0.8 }, css: { top: ($(window).height() - 125) /2 + 'px', left: ($(window).width() - 125) /2 + 'px', width: '125px', border: 'none', backgroundColor: 'none' }, baseZ: 2000 }); /* interval countdown */ var x = setInterval(function() { // Find the distance between now an the count down date countDownSeconds = countDownSeconds - 1; $('#time-left-reload').html(countDownSeconds); $('#message-reloaded-page').show(); // If the count down is finished, write some text if (countDownSeconds <= 0) { clearInterval(x); //close message $.unblockUI(); } }, 1000); } } } else { initLocalReload(); } } else { initLocalReload(); } } function initLocalReload() { var d = getDateCorrectedServer(); var objectReload = { 'last_reload' : d.getTime(), 'time' : 1 }; localStorage.setItem("loading_event_"+id_event, JSON.stringify(objectReload)); } function enableButtonToBuy() { $(".buyButton").html(polyglot.t("Buy_tickets")); $(".buyButton").removeClass("disabled"); $(".buyButton").prop("disabled", false); $('.buyButton').removeAttr("disabled"); $('.serviceBrief').attr('title', polyglot.t("Buy_tickets")); $(".buyButton").attr("onclick", "").unbind("click"); } function initCountdownToBuy() { var secondToShow = initSaleDateLong / 1000; var secondsLeft = parseInt(secondToShow, 10); /* interval countdown */ var x = setInterval(function() { // Find the distance between now an the count down date secondsLeft = secondsLeft - 1; var seconds = secondsLeft; var days = Math.floor(seconds / (3600*24)); seconds -= days*3600*24; var hrs = Math.floor(seconds / 3600); seconds -= hrs*3600; var mnts = Math.floor(seconds / 60); seconds -= mnts*60; var strLeftBtn = ""; if(days != 0){ strLeftBtn += polyglot.t("days_(days)", { days: days }); } if(hrs != 0){ if(strLeftBtn != ""){ strLeftBtn += ", "; } strLeftBtn += polyglot.t("hrs_(hrs)", { hrs: hrs }); } if(mnts != 0){ if(strLeftBtn != ""){ strLeftBtn += ", "; } strLeftBtn += polyglot.t("m_(mnts)", { mnts: mnts }); } if(strLeftBtn != ""){ strLeftBtn += ", "; } strLeftBtn += polyglot.t("s_(seconds)", { seconds: seconds }); $(".buyButton").html(polyglot.t("Sales_begin_in_(time)", { timeleft: strLeftBtn })); // If the count down is finished, clear interval and enable button if (secondsLeft <= 0) { clearInterval(x); //enable buttons enableButtonToBuy(); } }, 1000); }