(function($){ $.fn.UItoTop = function(options) { var defaults = { text: 'To Top', min: 200, inDelay:600, outDelay:400, containerID: 'toTop', containerHoverID: 'toTopHover', scrollSpeed: 1200, easingType: 'linear' }, settings = $.extend(defaults, options), containerIDhash = '#' + settings.containerID, containerHoverIDHash = '#'+settings.containerHoverID; $('body').append(''+settings.text+''); $(containerIDhash).hide().on('click.UItoTop',function(){ $('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType); $('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType); return false; }) .prepend('') .hover(function() { $(containerHoverIDHash, this).stop().animate({ 'opacity': 1 }, 600, 'linear'); }, function() { $(containerHoverIDHash, this).stop().animate({ 'opacity': 0 }, 700, 'linear'); }); $(window).scroll(function() { var sd = $(window).scrollTop(); if(typeof document.body.style.maxHeight === "undefined") { $(containerIDhash).css({ 'position': 'absolute', 'top': sd + $(window).height() - 50 }); } if ( sd > settings.min ) $(containerIDhash).fadeIn(settings.inDelay); else $(containerIDhash).fadeOut(settings.Outdelay); }); }; })(jQuery); function colocar_subir_inicio() { var scrollTop = $(window).scrollTop(); if (scrollTop <= 300) { $(".buttonUp").addClass('top'); } else { $(".buttonUp").removeClass('top'); } } var scrollTimeout; $(window).scroll(function () { if (scrollTimeout) { clearTimeout(scrollTimeout); } setTimeout(colocar_subir_inicio, 500); }); $(window).ready(function(){ //prueba span hover const target = document.querySelector(".lineaInferiorHoverMenu"); const links = document.querySelectorAll(".linkDesplegable"); const contenido = document.querySelector(".contenido"); const colors = ["#02679f"]; for (let i = 0; i < links.length; i++) { links[i].addEventListener("mouseenter", mouseenterFunc); } contenido.addEventListener("mouseenter", onFocusFunc); window.addEventListener("resize", resizeFunc); function onFocusFunc(){ for (let i = 0; i < links.length; i++) { links[i].style.opacity = "1"; } target.style.display = "none"; } function mouseenterFunc() { target.style.display = "inline"; if (!this.parentNode.classList.contains("active")) { for (let i = 0; i < links.length; i++) { if (links[i].parentNode.classList.contains("active")) { links[i].parentNode.classList.remove("active"); } links[i].style.opacity = "0.25"; } this.parentNode.classList.add("active"); this.style.opacity = "1"; var width; if(this.parentNode.getElementsByTagName('ul').length == 0){ width = this.getBoundingClientRect().width; }else{ width = this.parentNode.getElementsByTagName('ul')[0].getBoundingClientRect().width; } const height = this.getBoundingClientRect().height; const left = this.getBoundingClientRect().left + window.pageXOffset; const top = this.getBoundingClientRect().top + window.pageYOffset; const color = colors[Math.floor(Math.random() * colors.length)]; target.style.width = width+'px'; target.style.height = height+'px'; target.style.left = left+'px'; target.style.top = top+'px'; target.style.borderColor = color; target.style.transform = "none"; } } function resizeFunc() { const active = document.querySelector(".menuNav .megamenu li.active"); if (active) { const left = active.getBoundingClientRect().left + window.pageXOffset; const top = active.getBoundingClientRect().top + window.pageYOffset; target.style.left = left+'px'; target.style.top = top+'px'; } } var rv = -1; // Return value assumes failure if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } if (typeof mgnl != 'undefined' && mgnl!=null && mgnl.PageEditor!=null){ mgnl.PageEditor.onReady( function() { var localeSelector = $("select.mgnlEditorLocaleSelector"); if(localeSelector!=null){ $(localeSelector).find("option").each(function( index ) { var optValue = $(this).text(); if(optValue!=null && optValue!='' && optValue.toLowerCase().indexOf("va") >= 0){ optValue = optValue.replace("Va", "Valencià"); $(this).text(optValue); } }); } }); } // Renderizado videos if($(".object_elem")){ if(navigator.userAgent.indexOf("MSIE") != -1){ $('.object_elem.ie11-browser').remove(); }else{ $('.object_elem.ie-old').remove(); } $(".object_elem").each(function( index ) { if($(this).parents('.contenido_left.home').length<=0){ var parent = $(this).parent().get(0); $(this).height($(parent).height()*0.7); $(this).width($(parent).width()*0.7); } }); } // Activamos estilos con javascript activado. $('body').addClass('jsactivo'); // Control de elemento acordeón. if ($('ul.acordeon')) { acordeon.inicializar(); } //inicializar acordeon if($(".accordion").length>0) $(".accordion").accordion({ collapsible: true, active: false, autoHeight: false, heightStyle: "content" }); //end inicializacion acordeon //init Carousel if($('.md-carousel').length>0){ if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { if (typeof this !== 'function') { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function() {}, fBound = function() { return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } $('.md-carousel').slick({ infinite: false, adaptiveHeight: true, autoplay: true, arrows: false, pauseOnHover : false, dots: true, slidesToShow: 1, slidesToScroll: 1, autoplaySpeed: 6000, accesibility: true, responsive: [ { breakpoint: 1024, settings: { } }, { breakpoint: 768, settings: { arrows: true, dots: false } } ] }); } //fin init carousel /* init del calendario */ initCalendar(); /* Menu horizontal home */ /* $(".megamenu").accessibleMegaMenu({*/ $(".fun-menuNav").accessibleMegaMenu({ /* prefix for generated unique id attributes, which are required to indicate aria-owns, aria-controls and aria-labelledby */ uuidPrefix: "accessible-megamenu", /* css class used to define the megamenu styling */ menuClass: "nav-menu", /* css class for a top-level navigation item in the megamenu */ topNavItemClass: "nav-item", /* css class for a megamenu panel */ panelClass: "sub-nav", /* css class for a group of items within a megamenu panel */ panelGroupClass: "sub-nav-group", /* css class for the hover state */ hoverClass: "hover", /* css class for the focus state */ focusClass: "focus", /* css class for the open state */ openClass: "open" }); $(window).resize(function(){ if(window.innerWidth<"768"){ // igualar altura en carrusel del figure con respecto al contenedor var slideIMG = $(".carousel-cont_img").height(); var slideContent = $(".carousel-link").height(); if (slideIMG>slideContent){ $(".slick-track").css("height", slideIMG); } else { $(".slick-track").css("height", slideContent); } // fin igualar altura en carrusel del figure con respecto al contenedor $(".mod_navcontent_aside .fc-acordeon").accordion({ collapsible: true, active: false, autoHeight: false, navigation: true, heightStyle: "content", clearStyle: true }); for(var i=0;i<$(".mdc-item-content").length;i++){ $($(".mdc-item-content")[i]).appendTo($(".cont-info")[i]); } $(".mdc-item-content").css("visibility","inherit"); } else { $(".slick-track").css("height", "auto"); } if (window.innerWidth <= "1024" && window.innerWidth >= "768") { $(".md-carousel-content").css("padding-right","17.5px"); $(".md-carousel-content").css("padding-left","17.5px"); } if (window.innerWidth > "1024") { $(".md-carousel-content").css("padding-right","15px"); $(".md-carousel-content").css("padding-left","15px"); } if(window.innerWidth>"768"){ if($(".mod_navcontent_aside .fc-acordeon").hasClass("ui-accordion")){ $(".mod_navcontent_aside .fc-acordeon").accordion("destroy"); } for(var i=0;i<$(".mdc-item-content").length;i++){ $($(".mdc-image")[i]).appendTo($(".cont-info")[i]); } } }); $(window).load(function () { if(window.innerWidth<"768"){ // igualar altura en carrusel del figure con respecto al contenedor var slideContent = $(".md-carousel-content").height(); // Get the current slide $(".slick-track").css("height", slideContent); // fin igualar altura en carrusel del figure con respecto al contenedor // fin igualar altura en carrusel del figure con respecto al contenedor $(".mod_navcontent_aside .fc-acordeon").accordion({ collapsible: true, active: false, autoHeight: false, navigation: true, heightStyle: "content", clearStyle: true }); for(var i=0;i<$(".mdc-item-content").length;i++){ $($(".mdc-item-content")[i]).appendTo($(".cont-info")[i]); } $(".mdc-item-content").css("visibility","inherit"); } if (window.innerWidth <= "1024" && window.innerWidth >= "768") { $(".md-carousel-content").css("padding-right","17.5px"); $(".md-carousel-content").css("padding-left","17.5px"); } if (window.innerWidth > "1024") { $(".md-carousel-content").css("padding-right","15px"); $(".md-carousel-content").css("padding-left","15px"); } }); $(".slick-prev,.slick-next").click(function() { var currentSlide = $('.md-carousel').slick('slickCurrentSlide'); $(".md-carousel-content").each(function(idx, el) { var altSlideContent = $(".carousel-link")[idx].offsetHeight; if (currentSlide === idx) { $(".slick-track").css("height", altSlideContent); } }); }); }); function colocar_subir_inicio() { var scrollTop = $(document).scrollTop(); if (scrollTop <= 300) { $(".buttonUp").addClass('top'); } else { $(".buttonUp").removeClass('top'); } } function initCalendar () { if($(".mod_calendar").length>0){ var fun = function(){ if($(".date-picker-table caption").length<1) $(".date-picker-table").prepend("Calendario"); } //var idCalendar = "calendarEvents"; if (window.location.pathname.indexOf('index')!='-1') { if (window.innerWidth <= "1024") { //idCalendar = "calendarEvents_mov"; datePickerController.createDatePicker({ formElements:{"calendarEvents_mov":"%d/%m/%Y"}, showWeeks:false, dayNamesMin: [ "D", "L", "M", "X", "J", "V", "S" ], staticPos:true, /*mostrar el calendario estaticamente*/ fillGrid:true, callbackFunctions:{ "dateset":[datePickerEventos], "datereturned":[datePickerSelectDate] } }); }else{ datePickerController.createDatePicker({ formElements:{"calendarEvents":"%d/%m/%Y"}, showWeeks:false, dayNamesMin: [ "D", "L", "M", "X", "J", "V", "S" ], staticPos:true, /*mostrar el calendario estaticamente*/ fillGrid:true, callbackFunctions:{ "dateset":[datePickerEventos], "datereturned":[datePickerSelectDate] } }); } }else{ if (window.innerWidth <= "768") { datePickerController.createDatePicker({ formElements:{"calendarEvents_mov":"%d/%m/%Y"}, showWeeks:false, dayNamesMin: [ "D", "L", "M", "X", "J", "V", "S" ], staticPos:true, /*mostrar el calendario estaticamente*/ fillGrid:true, callbackFunctions:{ "dateset":[datePickerEventos], "datereturned":[datePickerSelectDate] } }); }else{ datePickerController.createDatePicker({ formElements:{"calendarEvents":"%d/%m/%Y"}, showWeeks:false, dayNamesMin: [ "D", "L", "M", "X", "J", "V", "S" ], staticPos:true, /*mostrar el calendario estaticamente*/ fillGrid:true, callbackFunctions:{ "dateset":[datePickerEventos], "datereturned":[datePickerSelectDate] } }); } } } $(".prev-but, .next-but").on("click", function (e) { var array_yyyymm = obtenerMesAnioDPCalendar($(this), e); datePickerEventos(null,array_yyyymm[1], array_yyyymm[0]); }); $(".date-picker-thead").on("click", function (e) { e.preventDefault(); }); } function initCalendarTablet () { if($(".mod_calendar").length>0){ var fun = function(){ if($(".date-picker-table caption").length<1) $(".date-picker-table").prepend("Calendario"); } datePickerController.createDatePicker({ formElements:{"calendarEvents":"%d/%m/%Y"}, showWeeks:false, dayNamesMin: [ "D", "L", "M", "X", "J", "V", "S" ], staticPos:true, /*mostrar el calendario estaticamente*/ fillGrid:true, callbackFunctions:{ "dateset":[datePickerEventos], "datereturned":[datePickerSelectDate] } }); } $(".prev-but, .next-but").on("click", function (e) { var array_yyyymm = obtenerMesAnioDPCalendar($(this), e); datePickerEventos(null,array_yyyymm[1], array_yyyymm[0]); }); $(".date-picker-thead").on("click", function (e) { e.preventDefault(); }); } //Función que recoge el día que hemos seleccionado function datePickerSelectDate (date, id, dd, mm, yyyy) { var idDatePicked = ".cd-" + date.yyyy + date.mm + date.dd; var urlRedirect = ""; if($(idDatePicked).attr("data-url")){ urlRedirect = $(idDatePicked).attr("data-url"); }else if($(idDatePicked).hasClass("date-picker-selected-date")){ /*urlRedirect = "/buscador-gsa/buscadorEventos.htm?busqueda=true&diaDesdeP=" + date.dd + "&mesDesdeP=" + date.mm + "&anioDesdeP=" + date.yyyy; }else{ urlRedirect = "/buscador-gsa/buscadorEventos.htm";*/ } //console.log(urlRedirect); window.location.href = urlRedirect; } function datePickerSelected (dateSelected, mes, anio) { if(dateSelected!=null && dateSelected.date!=null){ return ; }else{ datePickerEventos (mes, anio); } } //Función que pinta los días que tienen eventos function datePickerEventos (dateSelected, mes, anio) { if(dateSelected!=null && dateSelected.date!=null){ //var e = document.window.event; //if(e.stopPropagation) { //e.stopPropagation(); //e.preventDefault(); //}; return ; } var mesIni = ""; var anioIni = ""; var mesFin = ""; var anioFin = ""; var dateIni = new Date(); if(mes==null || anio ==null){ mes = dateIni.getMonth(); anio = dateIni.getFullYear(); }else{ mes = mes - 1; } dateIni.setFullYear(anio); dateIni.setMonth(mes,1); dateIni.setDate(1); var dateFin = new Date(dateIni); dateFin.setDate(1); dateFin.setMonth(dateIni.getMonth() + 1,1); mesIni = mes + 1; anioIni = anio; mesFin = dateFin.getMonth() + 1; anioFin = dateFin.getFullYear(); //console.log("FechaIniBusqueda: " + mesIni + "/" + anioIni + " FechaFinBusqueda: " + mesFin + "/" + anioFin); var jsonobj = ""; var url = "/face_Home/app/peticionesCalculos.html?calculo=calendar&fechaIni=" + mesIni + "/" + anioIni + "&fechaFin=" + mesFin + "/" + anioFin; if($("#pathCalendarEvents")!=null && $("#pathCalendarEvents").val()!=null && $("#pathCalendarEvents").val()!=""){ url = url + "&path=" + $("#pathCalendarEvents").val(); } $.ajax({ url: url, type: "GET", success: function(html){ if(html.indexOf("##INI_STR##")!=-1 && html.indexOf("##FIN_STR##")!=-1){ var iniStr = html.indexOf("##INI_STR##") + 11; var finStr = html.indexOf("##FIN_STR##"); html = html.substring(iniStr,finStr); jsonobj= $.parseJSON(html); if(jsonobj!=""){ for (var i in jsonobj){ var strDateIni = jsonobj[i].dateIni; var dateIni = new Date(strDateIni); var strDateFin = jsonobj[i].dateFin; if(strDateFin!=null && strDateFin !=''){ var dateFin = new Date(strDateFin); while (dateIni.getTime()<=dateFin.getTime()){ var strDateIniAux = dateIni.getFullYear().toString()+(((dateIni.getMonth()+1) < 10 ? '0' : '') + (dateIni.getMonth()+1)).toString()+ ((dateIni.getDate()<10?'0':'')+dateIni.getDate()).toString(); if($(".cd-"+strDateIniAux).hasClass("date-picker-selected-date")){ //$(".cd-"+strDateIniAux).removeAttr("data-url"); var urlActual = jsonobj[i].link; urlActual = urlActual.substring(0,urlActual.lastIndexOf("/")); $(".cd-"+strDateIniAux).attr("data-url",urlActual); }else{ $(".cd-"+strDateIniAux).addClass("date-picker-selected-date"); $(".cd-"+strDateIniAux).attr("data-url",jsonobj[i].link); } var dateIniAux = new Date(dateIni); dateIniAux.setDate(dateIniAux.getDate() + 1); dateIni = dateIniAux; } } else{ var strDateIniAux = strDateIni.replace("/","").replace("/",""); if($(".cd-"+strDateIniAux).hasClass("date-picker-selected-date")){ //$(".cd-"+strDateIniAux).removeAttr("data-url"); var urlActual = jsonobj[i].link; urlActual = urlActual.substring(0,urlActual.lastIndexOf("/")) + ".html"; $(".cd-"+strDateIniAux).attr("data-url",urlActual); }else{ $(".cd-"+strDateIniAux).addClass("date-picker-selected-date"); $(".cd-"+strDateIniAux).attr("data-url",jsonobj[i].link); } } } } } else{ jsonobj = ""; } }, error: function(){ jsonobj = ""; }, async: true, // La petición es asíncrona cache: false // No queremos usar la caché del navegador }); } function obtenerMesAnioDPCalendar (node, e) { //retrocedemos hatsa el inicio de la tabla var tablaCE = $(node).parents(".date-picker-table"); //buscamos un dia dentro del mes en curso para poder recuperar su clase y obtener el mes y el año var diaCE = ""; var arrayDiaCE = $(tablaCE).find("tbody tr td"); for (var i = 0; i < arrayDiaCE.length; i++) { var diaCEEnCurso = $(arrayDiaCE[i]).attr("class"); //debemos seleccionar un dia del mes en curso, nunca de los dias que salen del mes anterior if(diaCEEnCurso.indexOf("not-selectable") < 0){ var diaLocalizado = false; //localizamos la clase que tiene el formato "yyyymmm-201502", por ejemplo var diaCEEnCurso = diaCEEnCurso.split(" "); for (var j = 0; j < diaCEEnCurso.length; j++) { if(diaCEEnCurso[j].indexOf("yyyymm-") > -1){ // obtenemos el string del año y el mes var array_stryyyymm = diaCEEnCurso[j].split("yyyymm-"); var anioCE = array_stryyyymm[1].substring(0,4); var mesCE = array_stryyyymm[1].substring(4,7); //Recuperamos el mes y el año diaLocalizado = true; var array_yyyymm = [anioCE, mesCE]; return array_yyyymm; } }; // Si ya hemos localizado el dia salimos de los dos for if(diaLocalizado){ break; } } }; } function accAccesibilidad() { if (window.location.pathname.indexOf('/en/')!='-1') { window.location = "/face_Home/en/accesibilidad.html"; } else if (window.location.pathname.indexOf('/ca/')!='-1') { window.location = "/face_Home/ca/accesibilidad.html"; } else if (window.location.pathname.indexOf('/eu/')!='-1') { window.location = "/face_Home/eu/accesibilidad.html"; } else if (window.location.pathname.indexOf('/gl/')!='-1') { window.location = "/face_Home/gl/accesibilidad.html"; } else{ window.location = "/face_Home/accesibilidad.html"; } } function accContacto() { if (window.location.pathname.indexOf('/en/')!='-1') { window.location = "/face_Home/en/contacta.html"; } else if (window.location.pathname.indexOf('/ca/')!='-1') { window.location = "/face_Home/ca/contacta.html"; } else if (window.location.pathname.indexOf('/eu/')!='-1') { window.location = "/face_Home/eu/contacta.html"; } else if (window.location.pathname.indexOf('/gl/')!='-1') { window.location = "/face_Home/gl/contacta.html"; } else{ window.location = "/face_Home/contacta.html"; } } function accMapaWeb() { if (window.location.pathname.indexOf('/en/')!='-1') { window.location = "/face_Home/en/mapa-web.html"; } else if (window.location.pathname.indexOf('/ca/')!='-1') { window.location = "/face_Home/ca/mapa-web.html"; } else if (window.location.pathname.indexOf('/eu/')!='-1') { window.location = "/face_Home/eu/mapa-web.html"; } else if (window.location.pathname.indexOf('/gl/')!='-1') { window.location = "/face_Home/gl/mapa-web.html"; } else{ window.location = "/face_Home/mapa-web.html"; } } function accInicio() { if (window.location.pathname.indexOf('/en/')!='-1') { window.location = "/face_Home/en/index.html"; } else if (window.location.pathname.indexOf('/ca/')!='-1') { window.location = "/face_Home/ca/index.html"; } else if (window.location.pathname.indexOf('/eu/')!='-1') { window.location = "/face_Home/eu/index.html"; } else if (window.location.pathname.indexOf('/gl/')!='-1') { window.location = "/face_Home/gl/index.html"; } else{ window.location = "/face_Home/index.html"; } } /*function accBuscar(){ document.getElementById('inputBusq').focus(); }*/ function accBuscar(){ document.getElementById('inputBusq').value=""; }