var innerMenu = false; var claseMenu = ""; var usarWidthWebkit = true; var isPortadaInstitucional = false; (function ($) { var ua = navigator.userAgent.toLowerCase(), match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [], browser = match[1] || "", version = match[2] || "0"; jQuery.browser = {}; if (browser) { jQuery.browser[browser] = true; jQuery.browser.version = version; } // Chrome is Webkit, but Webkit is also Safari. if (jQuery.browser.chrome) { jQuery.browser.webkit = true; } else if (jQuery.browser.webkit) { jQuery.browser.safari = true; } if((/chrome|edg/).test(navigator.userAgent.toLowerCase())) { usarWidthWebkit = false; } })(jQuery); function headerNavSearcher() { $("#nav .buscador").on("click", function (event) { var target = $(event.target); if (!target.hasClass("buscar") && !target.hasClass("botonBuscar") && !target.hasClass("fBuscarEn") && target.parents(".fBuscarEn").length < 1) { $("body").removeClass("general-search"); } }); $("#nav .buscador").find('input[type="text"]').on("keydown", function (event) { //+ Tecla enter if (event.keyCode === 13) { event.preventDefault(); $(this).closest("form").submit(); } }); $("#nav .buscador").find("form").on("submit", function () { var form = $(this); if (!form.find("#buscarPersonas").prop("checked")) { var text = form.find('input[type="text"]').val(); var destiny = form.attr("action"); var concatCharacter = "?"; if (destiny.indexOf("?")) { concatCharacter = "&"; } form.attr("action", destiny + concatCharacter + "q=" + encodeURIComponent(text)); } }); $("#pullSearch~.buscador #buscadorGeneral").click(function (e) { if (window.matchMedia("(max-width: 767.98px)").matches) { e.stopPropagation(); } }); } function headerDeploySearch() { $("#header #submitBuscadorGeneral, #pullSearch").on("click", function (event) { event.preventDefault(); event.stopPropagation(); $("body").addClass("general-search"); //- Gestion de tabindex $("#nav .buscar").focus(); }); //- Gestion de tabindex $("#nav #buscadorGeneral").attr("tabindex", "0"); $("#nav #buscadorGeneral").on("keydown", function (event) { //- Tecla enter if (event.keyCode === 13) { event.preventDefault(); $("body").removeClass("general-search"); } }); $("#nav .botonBuscar").on("keydown", function (event) { //- Tecla tab if (event.keyCode === 9) { event.preventDefault(); $("#nav #buscadorGeneral").focus(); } }); //- Cerramos al redimensionar por si se cambia a la version movil $(window).resize(function () { $("body").removeClass("general-search mobile-menu-deployed"); }); } function headerClickBackMenu() { $("body").removeClass("general-search mobile-menu-deployed"); } function headerPullClick() { $(".backMenu").toggle(); $("body").toggleClass("mobile-menu-deployed"); } function headerPullSearchClick() { $(".backMenu").show(); $("body").addClass("mobile-menu-deployed"); } function headerBodyClick() { $(".backMenu").hide(); $("body").removeClass("general-search mobile-menu-deployed"); } function headerCheckStickyAux(header, logoMovil, logoSticky, navbar) { if (window.pageYOffset > 0) { header.classList.add("sticky"); logoMovil.classList.add("noMovil"); logoSticky.classList.remove("noMovil"); navbar.classList.add("sticky"); } else { navbar.classList.remove("sticky"); header.classList.remove("sticky"); logoMovil.classList.remove("noMovil"); logoSticky.classList.add("noMovil"); } } function headerCheckSticky() { var navbar = document.querySelectorAll("#nav")[0]; var header = document.querySelectorAll("#header")[0]; var logoMovil = document.getElementsByClassName("logomovil")[0]; var logoSticky = document.getElementsByClassName("logomovilsticky")[0]; headerCheckStickyAux(header, logoMovil, logoSticky, navbar); window.onscroll = function () { headerCheckStickyAux(header, logoMovil, logoSticky, navbar); }; } var _clientWidth = 0; function setClientWidth() { _clientWidth = document.documentElement.clientWidth; document.documentElement.style.setProperty("--cw", _clientWidth + "px"); } function _readyResizeVars() { setClientWidth(); window.addEventListener("resize", function () { setClientWidth(); }); } $(function () { if ($("body").hasClass("PortadaInstitucional")) { isPortadaInstitucional = true; if (document.readyState !== "loading") { _readyResizeVars(); } else { //* Si no ha cargado la pagina preparamos el listener document.addEventListener("DOMContentLoaded", function () { _readyResizeVars(); }); } } var pull = $('#pull'); pullSearch = $('#pullSearch'); menu = $('#nav .menu'); openMenu = $('.openMenu'); closeMenu = $('.closeMenu'); buttonMenu2 = $(".menu a.buttonMenu2"); menuMovil2 = $(".menu .menuMovil2"); atrasMenu2 = $(".menu .flechasAtras"); menuHeight = menu.height(); windowWidth = Math.max($(window).innerWidth(), window.innerWidth); var isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } $(pull).on('click', function (e) { e.preventDefault(); e.stopPropagation(); if (isPortadaInstitucional) { headerPullClick(); } else { $(".backMenu").toggle(); $("#content").toggleClass('blur'); $("#footer").toggleClass('blur'); } $('.menu.vistaMovil>ul').show(); menu.slideToggle(400); openMenu.toggle(); closeMenu.toggle(); if ($(openMenu, e).css('display') === 'none') { if ($(".PortadaInstitucional").length > 0) { $('.buttonMenu2').before($('.accesosDirectos').clone()); } if ($(".PortadaMiniSite").length > 0 || $(".MiniSiteA").length > 0 || $(".MiniSiteB") > 0 || $(".MiniSiteC").length > 0) { $('.buttonMenu2').after($('.accesosDirectos').clone()); } } else { $('.menu.vistaMovil .accesosDirectos').detach(); } // Controlamos el menú "Y además" poniendole scroll en caso de que sea más grande que la pantalla actual if ($("body").find(".menuAdemas.compartirMenu:not(.enlHerramientas)").length > 0) { buttonMenu2.show(); if ($('.menuMovil2 .menuAdemas.compartirMenu').length === 0) { $('.menuAdemas.compartirMenu:not(.enlHerramientas)').appendTo($('.menuMovil2')); $('.menuAdemas.compartirMenu:not(.enlHerramientas)').css('display', 'inline-block'); altoMenuAdemas = 0; $("#nav .menuMovil2 .menuAdemas h2").each(function (i) { $($("#nav .menuMovil2 .menuAdemas h2")[i]).prependTo($($("#nav .menuMovil2 .menuAdemas h2")[i]).next()) }) $('.menuMovil2 .menuAdemas.compartirMenu').each(function () { $(this).css("top", altoMenuAdemas); altoMenuAdemas += $(this).height() - 1; }); if (altoMenuAdemas > 0) { $('.menuMovil2').height(altoMenuAdemas + 'px'); if (($('.menuMovil2').height() + $('#nav').height() + $('#header').height()) > $(window).height()) { $('.menuMovil2').css("max-height", $(window).height() - ($('#nav').height() + $('#header').height()) + "px"); $('.menuMovil2').css("overflow", "scroll"); $(".menuMovil2 .flechasAtras").height(altoMenuAdemas + 'px'); } } } } // Compartir en móvil if ($('.menuAdemas.compartirMenu.enlHerramientas').length > 0) { $('.menuAdemas.compartirMenu.enlHerramientas').removeClassExcept('compartirMenu'); } menuMovil2.animate({ "left": "770px" }, 500); // Mostrar desplegado submenu activo en caso de que lo haya if ($(".menu.vistaMovil ul li.activo").length > 0) { $(".menu.vistaMovil ul li").children().children().filter("li").parent().filter('ul:not([class])').hide(); $(".menu.vistaMovil ul li.activo ul").show(); } if ($(".PortadaMiniSite .menu.vistaMovil ul.compartirMenu").length > 0 || $(".MiniSiteA .menu.vistaMovil ul.compartirMenu").length > 0 || $(".MiniSiteB .menu.vistaMovil ul.compartirMenu").length > 0 || $(".MiniSiteC .menu.vistaMovil ul.compartirMenu").length > 0) { $(".PortadaMiniSite .menu.vistaMovil div.accesosDirectos").css("width", "60%"); $(".MiniSiteA .menu.vistaMovil div.accesosDirectos").css("width", "60%"); $(".MiniSiteB .menu.vistaMovil div.accesosDirectos").css("width", "60%"); $(".MiniSiteC .menu.vistaMovil div.accesosDirectos").css("width", "60%"); } // El div del menu siempre debe ocupar espacio if (menu.is(':hidden')) { menu.css('display', 'block'); } }); $(".backMenu").on('click', function () { $('body').click(); if (isPortadaInstitucional) { headerClickBackMenu(); } }); $(buttonMenu2).on('click', function (e) { e.preventDefault(); e.stopPropagation(); menuMovil2.animate({ "left": "0px" }, 500); setTimeout(function () { $('.menu.vistaMovil>ul').hide(); $('.menu.vistaMovil .accesosDirectos').hide(); $('.menu.vistaMovil .buttonMenu2').hide(); }, 500); }); $(atrasMenu2).on('click', function (e) { e.preventDefault(); e.stopPropagation(); menuMovil2.animate({ "left": "770px" }, 500); $('.menu.vistaMovil>ul').show(); $('.menu.vistaMovil .accesosDirectos').show(); $('.menu.vistaMovil .buttonMenu2').show(); }); var searchEl = $('.buscador').clone(); if (isPortadaInstitucional) { $(pullSearch).after(searchEl); headerNavSearcher(); } $(pullSearch).on('click', function (e) { e.preventDefault(); e.stopPropagation(); if (!isPortadaInstitucional) { $(pullSearch).after(searchEl); } $(".buscadorGeneralCabecera form").attr("autocomplete", "off"); $('#nav .buscador').hide(); if (!isPortadaInstitucional) { $(pullSearch).hide(); $(pull).hide(); } $(menu).hide(); if (isPortadaInstitucional) { headerPullSearchClick(); } if (!isPortadaInstitucional) { $(".backMenu").show(); $("#content").addClass('blur'); $("#footer").addClass('blur'); } $('#nav .buscador').show(); $('#nav .buscador').animate({ left: '0px' }, 500); $('#pullSearch~.buscador #buscadorGeneral .fBuscarEn').show(); if (!isPortadaInstitucional) { $('#pullSearch~.buscador #buscadorGeneral .botonBuscar').attr('value', ""); // Para que al hacer click en el buscador no se propague al body y nos lo cierre $('#pullSearch~.buscador #buscadorGeneral').click(function (e) { e.stopPropagation(); }); $('#pullSearch~.buscador #buscadorGeneral').submit(function (e) { if ($("#pullSearch~.buscador #buscarUc3m:checked").length > 0) { var vanity = $("#pullSearch~.buscador #q").attr("vanity") == "true" ? "?q=" : "&q="; $("#pullSearch~.buscador #buscadorGeneral").attr("action", $("#pullSearch~.buscador #buscadorGeneral").attr("action") + vanity + encodeURIComponent($("#pullSearch~.buscador #q").val())); $("#pullSearch~.buscador #q").attr("disabled", "disabled"); } }); } $('#pullSearch~.buscador #buscadorGeneral #q').focus(); }); $("body").click(function (e) { if (windowWidth < 768 && (e.target.classList[0] !== "flechaMovil" && $(e.target).siblings().filter("ul.segundoNivel").length == 0)) { // Esconder busqueda al clickar fuera searchEl.animate({ left: '-770px' }, 500); menuMovil2.animate({ left: '770px' }, 500); setTimeout(function () { searchEl.hide(); if (!isPortadaInstitucional) { pullSearch.css('display', 'inline'); pull.css('display', 'inline'); } }, 400); // Esconder menu al clickar fuera $('.menu.vistaMovil .accesosDirectos').detach(); buttonMenu2.hide(); menu.slideUp(400); closeMenu.hide(); openMenu.show(); if (isPortadaInstitucional) { headerBodyClick(); } else { $(".backMenu").hide(); $("#content").removeClass('blur'); $("#footer").removeClass('blur'); } } if (windowWidth < 768 && (e.target.classList[0] === "flechaMovil" && $(e.target).siblings().filter("ul.segundoNivel").length > 0)) { e.preventDefault(); if ($(e.target.parentNode).hasClass("activo")) { $(e.target.parentNode).removeClass("activo"); } else { $(e.target.parentNode).addClass("activo"); } $(e.target.parentNode).siblings().removeClass("activo"); $(e.target.parentNode).siblings().children().filter('ul[style*="display: block"]').slideToggle(); $(e.target).siblings().filter("ul.segundoNivel").slideToggle(); } }); }); var windowWidth = Math.max($(window).innerWidth(), window.innerWidth); var isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } $(window).resize(function () { var windowResWidth = Math.max($(window).innerWidth(), window.innerWidth); if (isWebkit && usarWidthWebkit) { windowResWidth = document.documentElement.clientWidth; } if (windowWidth === windowResWidth) return; windowWidth = Math.max($(window).innerWidth(), window.innerWidth); isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } setMenuMovil(); $('#pull').hide(); $('#pullSearch').hide(); $('.backMenu').hide(); $("#content").removeClass('blur'); $("#footer").removeClass('blur'); $('.menu .accesosDirectos').hide(); $('#pullSearch~.buscador').hide(); $('.menu>ul').show(); $('.menu .compartirMenu').hide(); $('.openMenu').show(); $('.menu.vistaMovil').hide(); $('.closeMenu').hide(); $('.buttonMenu2').hide(); $('.menu.vistaMovil .accesosDirectos').detach(); $('#navMovil .accesosDirectos').detach() ajustarWidgetsNoticias(); if (windowWidth < 768) { $('#pull').show(); $('#pullSearch').show(); $('.menu .menuAdemas').show(); $('.menu .compartirMenu').show(); $('.menu .segundoNivel').hide(); if (!isPortadaInstitucional) { if (window.pageYOffset > 0) { document.getElementById("nav").style.top = header.offsetHeight + 'px'; } } } if ($('body').hasClass("PortadaMiniSite")) { $(".PortadaMiniSite .innerMenu .marcoMenuInterno .tituloMenu").off("click"); $(".PortadaMiniSite .innerMenu div").removeClass("active"); if (windowWidth < 768) { $(".PortadaMiniSite .innerMenu .marcoMenuInterno ul").hide(); $(".PortadaMiniSite .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } else { $(".PortadaMiniSite .innerMenu .marcoMenuInterno ul").show(); } } else if ($('body').hasClass("MiniSiteC")) { $(".MiniSiteC .innerMenu .marcoMenuInterno .tituloMenu").off("click"); $(".MiniSiteC .innerMenu div").removeClass("active"); if (windowWidth < 768) { $(".MiniSiteC .innerMenu .marcoMenuInterno ul").hide(); $(".MiniSiteC .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } else { $(".MiniSiteC .innerMenu .marcoMenuInterno ul").show(); } } //mostrar el select de ambito de busqueda del buscador global al hacer click //en el campo de texto if (windowWidth > 768) { $('#q').focus(function () { $('div.fBuscarEn').show(); }); } }); //var menuGrande; jQuery(document).ready(function () { //Se oculta el Captcha hasta que se cubran determinados campos if ($("#ocultarRC").length > 0) { //Aplica a FormularioContacto if (!$("#ocultarRC input#correo").val()) { $("#recaptcha_area").hide(); } else { $("#recaptcha_area").show(); } $("#ocultarRC input#correo").blur(function () { if ($(this).val()) { $("#recaptcha_area").show(); } else { $("#recaptcha_area").hide(); } }); } else { //Aplica al resto de formularios if (!$("#nombreApellidos").val()) { $("#recaptcha_area").hide(); } else { $("#recaptcha_area").show(); } $("#nombreApellidos").blur(function () { if ($(this).val()) { $("#recaptcha_area").show(); } else { $("#recaptcha_area").hide(); } }); } $(".buscadorGeneralCabecera form").attr("autocomplete", "off"); //ocultar el select de ambito de busqueda del buscador global $('div.fBuscarEn').hide(); //mostrar el select de ambito de busqueda del buscador global al hacer click //en el campo de texto if (windowWidth > 768) { $('#q').focus(function () { $('div.fBuscarEn').show(); }); } //cualquier click en la pagina ocultaria el selector de ambito del buscador generico $('html').click(function () { $('div.fBuscarEn').fadeOut('medium'); }); if (!isPortadaInstitucional) { //exceptuando un click en el propio formulario $('#buscadorGeneral').click(function (event) { event.stopPropagation(); }); } //El pulsar la tecla 'tab' en el ultimo elemento del formulario de busqueda, se //oculta el selector buscarEn $('#submitBuscadorGeneral').keydown(function (e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { $('div.fBuscarEn').fadeOut('medium'); } }); //menuGrande = $('#nav .menu').clone(); setMenuMovilContent(); if (isPortadaInstitucional) { headerDeploySearch(); } // slides de texto $('.uc3m_clickslide').each(function () { var opener = $(this).find('.botonVerMas'); var closer = $(this).find('.botonVerMenos'); var lista = $(this).find('ul'); var contenedorlista = $(this).find('.contenedorLista'); var nuevalista = $('').css('display', 'none'); $(lista).children('li').each(function (index) { if (index > uc3m_slide_tamano - 1) { nuevalista.append($(this).clone()); $(this).remove(); contenedorlista.css('display', 'none'); opener.css('display', 'list-item'); closer.css('display', 'none'); } }); if(nuevalista.children().length>0){ contenedorlista.append(nuevalista); } opener.on('click', function (e) { e.preventDefault(); contenedorlista.css('display', 'block'); nuevalista.slideToggle(); opener.css('display', 'none'); closer.css('display', 'list-item'); }); closer.on('click', function (e) { e.preventDefault(); contenedorlista.css('display', 'none'); nuevalista.slideUp(); opener.css('display', 'list-item'); closer.css('display', 'none'); }); nuevalista.find('a').click(function (e) { e.stopPropagation() }); }); // Menu portadas minisites $('.uc3m_ms_slide').each(function () { var opener = $(this).find('.botonDesplegar'); var lista = $(this).find('ul'); var nuevalista = $('').css('display', 'none'); // Este elemento se debe llevar al script que va a utilizar en los minisites normales con la nueva modificacion activa $(lista).children('li').each(function (index) { if ($(this).hasClass('elemento_flotante')) { //$(this).detach(); nuevalista.append($(this).clone()); $(this).css('display', 'none'); opener.css('display', 'block'); } }); if(nuevalista.children().length>0){ opener.append(nuevalista); } opener.on('click', function (e) { e.preventDefault(); nuevalista.slideToggle(); }); opener.on('mouseleave', function (e) { e.preventDefault(); nuevalista.slideUp(); }); nuevalista.find('a').click(function (e) { e.stopPropagation() }); }); //gestion de pestanas var anchor = ""; var url = window.location.href; var anchorposition = url.lastIndexOf("#"); if (anchorposition > -1) { anchor = url.substring(anchorposition + 1); } history.scrollRestoration = "manual"; var tamanoViewPort = $(window).width(); var tamanoEscritorio = 768; //Px minimos de resolucion escritorio /** Comprueba si estamos en una ficha de grado **/ function esFichaGrado() { return $(".grado_uc3m_v").length > 0; } /** Obtiene el acordeon del elemento pestaña pasado como parametro elto : Elemento del dom **/ function obtieneAcordeonDePestana(elto) { return elto.closest('.acordeonGrado'); } /** Aplica clases css a un elemento del dom elto : Elemento del dom nuevaClass : Nueva clase css a aplicar al elemento classAEliminar : Clase css del elemento a eliminar **/ function estableceClassCSS(elto, nuevaClass, classAEliminar) { if (undefined != nuevaClass) { $(elto).addClass(nuevaClass) } if (undefined != classAEliminar) { $(elto).removeClass(classAEliminar); } } /** Muestra el contenido de un desplegable elto : Elemento del dom velocidad : Velocidad de despliegue nuevaClass : Nueva clase css a aplicar al elemento (opcional) classAEliminar : Clase css del elemento a eliminar (opcional) pestanaInternaAActivar : Id de pestana interna a activar al finalizar la animacion **/ function mostrarDesplegable(elto, velocidad, nuevaClass, classAEliminar, pestanaInternaAActivar) { if (undefined != pestanaInternaAActivar) { $(pestanaInternaAActivar).find('a')[0].click(); } estableceClassCSS(elto, nuevaClass, classAEliminar); } /** Oculta el contenido de un desplegable elto : Elemento del dom velocidad : Velocidad de despliegue nuevaClass : Nueva clase css a aplicar al elemento (opcional) classAEliminar : Clase css del elemento a eliminar (opcional) **/ function ocultarDesplegable(elto, velocidad, nuevaClass, classAEliminar) { $(elto).slideUp(velocidad, estableceClassCSS(elto, nuevaClass, classAEliminar)); } /** Realiza scroll a un elemento del dom pasado por parametro elto : Elemento del dom al que hacer scroll tiempo : Tiempo en ms del efecto de scroll desplegar : (true/false) Se despliega el acordeon pestanaInternaAActivar : Id de pestana interna a activar al finalizar la animacion **/ function scrollAAncla(elto, tiempo, desplegar, pestanaInternaAActivar) { if (desplegar) { //mostrarDesplegable(elto, 'fast','desplegado','replegado', pestanaInternaAActivar); $('html, body').animate({ scrollTop: ($(elto).offset().top) }, tiempo, function () { $(elto).click(); }); } else { $('html, body').animate({ scrollTop: ($(elto).offset().top) }, tiempo); } } /** Realiza click en el desplegable del acordeon correspondiente al ancla **/ function hacerClickAcordeon(ancla) { var eltoAnclado = $("#" + ancla); if (undefined != eltoAnclado) { $(eltoAnclado).closest(".acordeonGrado").children('.desplegable').click(); } } /** Obtiene el acordeonGrado de una ancla **/ function obtenerAcordeonAnclado(ancla) { var eltoAnclado = $("#" + ancla); if (undefined != eltoAnclado) { return $(eltoAnclado).closest(".acordeonGrado"); } } /** Gestion de acordeon y pestana **/ var eltoAnclado; var eltoEsPestana = false; var eltoEsAcordeon = false; var eltoAcordeonPadre; var eltoAcordeonPadreDiv; var primerDesplegable; var enlacesDeAcordeon; var primerEnlaceDeAcordeon; var esFichaGrado = esFichaGrado(); if (anchor != "") { eltoAnclado = $('#' + anchor); eltoEsPestana = eltoAnclado.hasClass('pestanaInner'); eltoEsAcordeon = eltoAnclado.hasClass('marcoParrafo'); if (undefined != eltoAnclado && (eltoEsAcordeon || eltoEsPestana)) { //Solo se aplica a pestanas o acordeon if (eltoEsPestana) { eltoAcordeonPadre = obtieneAcordeonDePestana(eltoAnclado); if (undefined != eltoAcordeonPadre) { primerDesplegable = eltoAcordeonPadre.find('.desplegable'); if (undefined != primerDesplegable && primerDesplegable.length > 0) { eltoAcordeonPadreDiv = primerDesplegable[0]; } } if (undefined != eltoAcordeonPadre) { enlacesDeAcordeon = eltoAnclado.children('a'); if (undefined != enlacesDeAcordeon && enlacesDeAcordeon.length > 0) { primerEnlaceDeAcordeon = enlacesDeAcordeon[0]; } } } } } var foundAnchor = false; var parent = null; if (anchor != "") { var extTabs = $('#pestanas').children('li'); if (extTabs != undefined && extTabs.size() > 0) { // Se busca el ancla entre las pestanas exteriores $.each(extTabs, function (index, element) { var identifier = $(this).attr('data-anchor'); if (anchor == identifier) { $(this).children('a.noEnlace').addClass('active').next().addClass('is-open').show(); foundAnchor = true; } }); } var parents = $('#pestanas').find('.pestana'); if (extTabs != undefined && extTabs.size() > 0) { // Se busca el ancla entre las subpestanas $.each(parents, function (index, element) { if (!foundAnchor) { var intTabs = $(this).find('.pestanasInner').children('li'); parent = $(this); if (intTabs != undefined && intTabs.size() > 0) { $.each(intTabs, function (index, element) { var identifier = $(this).attr('data-anchor'); if (anchor == identifier) { $(parent).children('a.noEnlace').addClass('active').next().addClass('is-open').show(); // muestra la pestana padre $(this).children('a.noEnlaceInner').addClass('active').next().addClass('is-open').show(); // muestra la subpestana foundAnchor = true; } }); } } }); } } // comprobar si hay que abrir pestanas y subpestanas por URL function checkLinkToSubtabs() { var foundAnchor = false; var parent = null; var anchor = ""; var url = window.location.href; var anchorposition = url.lastIndexOf("#"); if (anchorposition > -1) { anchor = url.substring(anchorposition + 1); } if (anchor != "") { var extTabs = $("#pestanas").children("li"); // Se busca el ancla entre las pestanas exteriores if (extTabs != undefined && extTabs.size() > 0) { $.each(extTabs, function (index, element) { var identifier = $(this).attr("data-anchor"); if (anchor == identifier) { $(this).children("a.noEnlace").addClass("active").next().addClass("is-open").show(); $(this).siblings().each(function() { $(this).children("a.noEnlace").removeClass("active").next().removeClass("is-open").hide(); }); foundAnchor = true; } }); } var parents = $("#pestanas").find(".pestana"); // Se busca el ancla entre las subpestanas if (extTabs != undefined && extTabs.size() > 0) { $.each(parents, function (index, element) { if (!foundAnchor) { var intTabs = $(this).find(".pestanasInner").children("li"); parent = $(this); if (intTabs != undefined && intTabs.size() > 0) { $.each(intTabs, function (index, element) { var identifier = $(this).attr("data-anchor"); if (anchor == identifier) { $(parent).children("a.noEnlace").addClass("active").next().addClass("is-open").show(); // muestra la pestana padre $(parent).siblings().each(function() { $(this).children("a.noEnlace").removeClass("active").next().removeClass("is-open").hide(); }); $(this).children("a.noEnlaceInner").addClass("active").next().addClass("is-open").show(); // muestra la subpestana $(this).siblings().each(function() { $(this).children("a.noEnlaceInner").removeClass("active").next().removeClass("is-open").hide(); }); foundAnchor = true; } }); } } }); } } } // enlaces que NO abran en nueva pestana $('a:not([target="_blank"])').each(function() { // enlaces que apunten a la pagina actual y tengan "#" (ancla) if ($(this).attr("href")?.startsWith(window.location.href.replace(/#.*$/, "#"))) { // al hacer click comprobamos si hay que abrir pestanas y subpestanas $(this).on("click", function() { // delay necesario para dar tiempo a que cambie la URL setTimeout(function() { checkLinkToSubtabs(); }, 100); }); } }); //Se muestra desplegadas la primera pestana si no estamos en una ficha de Grados y no se ha encontrado ancla o estamos en vista escritorio if ((!esFichaGrado && !foundAnchor) || (esFichaGrado && tamanoViewPort >= tamanoEscritorio)) { // En el caso default se muestra como visible la primera pestana (Solo escritorio) $('#pestanas').children('li').first().children('a.noEnlace').addClass('active').next().addClass('is-open').show(); } // Evento de cambio de pestanha $('#pestanas').children('li').on('click', 'a.noEnlace:first', function (event) { event.preventDefault(); event.stopPropagation(); if (!$(this).hasClass('active')) { $('#pestanas .pestana div.contenidoPestana.is-open').removeClass('is-open').hide(); $('.pestanasInner .pestanaInner div.contenidoPestanaInner').not('.is-open').hide(); // mantiene ocultas las pestanhas internas excepto la primera $('.pestanasInner .pestanaInner div.contenidoPestanaInner.closed').hide(); // cierra la primera pestanha si tiene clase closed $(this).next().toggleClass('is-open').toggle(); $('#pestanas').find('.pestana a.noEnlace.active').removeClass('active'); $(this).addClass('active'); // Se fuerza el cambio de id en la url var identifier = $(this).closest("li").attr('data-anchor'); if (anchor != "") { url = url.replace('#' + anchor, '#' + identifier); } else { url = url + '#' + identifier } anchor = identifier; window.location.replace(url) // Proporción videos 16:9 $(".video-container").each(function (i) { var wVideo = $(this).width(); var newHeight = wVideo/1.78; // Proporcion 16:9 $(this).css("padding-bottom", newHeight) }); } }); //gestion de pestanas internas - para cada conjunto de pestanas dentro de cada pestana var pestanas = $('#pestanas').find('.pestana'); $.each(pestanas, function (index, element) { if (!foundAnchor || (foundAnchor && parent == null) || (parent != null && $(this).attr('data-anchor') != $(parent).attr('data-anchor'))) { // En el caso default se muestra como visible la primera pestanha $(this).find('.pestanasInner').children('li').first().not('.closed').children('a.noEnlaceInner').addClass('active').next().addClass('is-open').show(); } // Evento de cambio de pestanha interna $(this).find('.pestanasInner').children('li').on('click', 'a.noEnlaceInner:first', function (event) { event.preventDefault(); event.stopPropagation(); var pestanaContenedora = $(this).closest('.pestana'); if (!$(this).hasClass('active')) { pestanaContenedora.find('.pestanasInner .pestanaInner div.contenidoPestanaInner.is-open').removeClass('is-open').hide(); $(this).next().toggleClass('is-open').toggle(); pestanaContenedora.find('.pestanasInner').find('.pestanaInner a.noEnlaceInner.active').removeClass('active'); $(this).addClass('active'); // Se fuerza el cambio de id en la url var identifier = $(this).closest("li").attr('data-anchor'); if (anchor != "") { url = url.replace('#' + anchor, '#' + identifier); } else { url = url + '#' + identifier } anchor = identifier; window.location.replace(url) // Proporción videos 16:9 $(".video-container").each(function (i) { var wVideo = $(this).width(); var newHeight = wVideo/1.78; // Proporcion 16:9 $(this).css("padding-bottom", newHeight) }); } }); }); // Gestion de parrafos desplegables var desplegables = $(".desplegable"); var mostrar = false; if (desplegables != null) { $.each(desplegables, function (index, element) { // Ocultar-Mostrar con click $(this).click(function () { if ($(this).hasClass("desplegado")) { $(this).removeClass("desplegado"); $(this).addClass("replegado"); mostrar = false; } else if ($(this).hasClass("replegado")) { $(this).removeClass("replegado"); $(this).addClass("desplegado"); mostrar = true; } var elementosDesplegables = $(this).parent().children().not(".desplegable").not(".no-desplegar"); if (elementosDesplegables != null) { $.each(elementosDesplegables, function (ind, elem) { if (mostrar) { $(this).slideDown('fast'); if ($(this).is('a')) { // Los enlaces se deben comportar como bloques $(this).css('display', 'block'); } } else { $(this).slideUp('fast'); } }); } //Si es un acordeon de grado colocado en un grado se fuerza el cambio de id en la url if (esFichaGrado && $(this).find(".marcoParrafo").length > 0) { var identifier = $(this).find(".marcoParrafo")[0].id; if (anchor != "") { url = url.replace('#' + anchor, '#' + identifier); } else { url = url + '#' + identifier } anchor = identifier; window.location.replace(url) } if ($('.PDI').length > 0 || $('.PAS').length > 0) { //window.setTimeout(tamanoFichasPDIPAS,200); } }); // Oculta inicialmente los elementos replegados excepto el del anclado if ($(this).hasClass("replegado")) { var elementosDesplegables = $(this).parent().children().not(".desplegable").not(".no-desplegar"); if (elementosDesplegables != null) { $.each(elementosDesplegables, function (ind, elem) { if ($(this).closest(".acordeonGrado").length == 0 || $(this).closest(".acordeonGrado")[0] != obtenerAcordeonAnclado(anchor)[0] || ($(this).closest(".acordeonGrado")[0] == obtenerAcordeonAnclado(anchor)[0] && $(this).closest('.marcoLiso').find("#" + anchor).length == 0)) { $(this).slideUp('fast'); } else { if ($(this).closest('.marcoLiso').find("#" + anchor).length > 0) { $(this).siblings('.desplegable').removeClass("replegado"); $(this).siblings('.desplegable').addClass("desplegado"); } } }); } } }); } //gestion de pestanas internas - para cada conjunto de pestanas dentro de cada desplegable var contenidoPestanas = $('.row .contenidoPestana'); if (contenidoPestanas != null) { $.each(contenidoPestanas, function (index, element) { //Primera pestanha visible por defecto si no es ficha grado o estamos en tamano Escritorio if (!esFichaGrado || (esFichaGrado && tamanoViewPort > tamanoEscritorio)) { if ($(this).find('.pestanasInner').children('li').find("a.noEnlaceInner.active").length == 0) { $(this).find('.pestanasInner').children('li').first().not('.closed').children('a.noEnlaceInner').addClass('active').next().addClass('is-open').show(); } } // Evento de cambio de pestanha interna $(this).find('.pestanasInner').children('li').on('click', 'a.noEnlaceInner:first', function (event) { event.preventDefault(); event.stopPropagation(); var pestanaContenedora = $(this).closest('.row .contenidoPestana'); if (!$(this).hasClass('active')) { pestanaContenedora.find('.pestanasInner .pestanaInner div.contenidoPestanaInner.is-open').removeClass('is-open').hide(); $(this).next().toggleClass('is-open').toggle(); pestanaContenedora.find('.pestanasInner').find('.pestanaInner a.noEnlaceInner.active').removeClass('active'); $(this).addClass('active'); // Se fuerza el cambio de id en la url var identifier = $(this).closest("li").attr('data-anchor'); if (anchor != "") { url = url.replace('#' + anchor, '#' + identifier); } else { url = url + '#' + identifier } anchor = identifier; window.location.replace(url) // Proporción videos 16:9 $(".video-container").each(function (i) { var wVideo = $(this).width(); var newHeight = wVideo/1.78; // Proporcion 16:9 $(this).css("padding-bottom", newHeight) }); } }); }); } if (esFichaGrado) { //Click en pestana if (eltoEsPestana) { $("#" + anchor).children(".noEnlaceInner").click(); } //Click en pestana anchor si se cambia a resolucion escritorio $(window).resize(function () { var tamanoViewPort = $(window).width(); if (tamanoViewPort > tamanoEscritorio) { var ulPestanasInner = $('ul.pestanasInner'); $.each(ulPestanasInner, function (index, element) { if (esFichaGrado && tamanoViewPort > tamanoEscritorio) { //comprobamos que el ul de pestanas tenga al menos una pestana mostrada, sino mostramos la primera if (!$(this).find("a.noEnlaceInner.active").length > 0) { $(this).find("a.noEnlaceInner")[0].click() } } }); if ($('#' + anchor).hasClass('pestanaInner')) { $("#" + anchor).children(".noEnlaceInner").click(); } } }); setTimeout(function () { if ($("#" + anchor).length > 0) { $('html, body').animate({ scrollTop: ($("#" + anchor).offset().top) }, 'fast'); } }, 1000) } }); jQuery.fn.removeClassExcept = function (val) { return this.each(function (index, el) { var keep = val.split(" "), reAdd = [], $el = $(el); for (var c = 0; c < keep.length; c++) { if ($el.hasClass(keep[c])) reAdd.push(keep[c]); } $el .removeClass() // remove existing classes .addClass(reAdd.join(' ')); // re-add the confirmed ones }); }; function setMenuMovil() { if (!$.browser.msie || ($.browser.msie && $.browser.version >= 9)) { var isSafari = /Safari/.test(navigator.userAgent); var isChrome = /Chrome/.test(navigator.userAgent); var isFirefox = /Mozilla/.test(navigator.userAgent); var condition1 = !isSafari && !isChrome && !isFirefox && windowWidth >= 767; //MSIE var condition2 = isChrome && windowWidth >= 768; // Chrome var condition3 = isSafari && windowWidth >= 768; // Safari var condition4 = isFirefox && windowWidth >= 768; // Mozilla if (condition1 || condition2 || condition3 || condition4) { //se muestran los elementos con class=menuAdemas if (!menu.hasClass("no-navigation")) { // Si no tiene la clase no-navigation menu.show(); // El contenido del menu siempre se muestra cuando se amplia la pantalla y hay elementos de navegacion } else { menu.hide(); // El contenido del menu siempre se esconde cuando se amplia la pantalla y no hay elementos de navegacion } $(".compartirMenu").hide(); menu.find(".accordion_menu").hide(); $(".menuAdemas").show(); $(".menu .menuAdemas").hide(); $("#navMovil").show(); if (menu.hasClass("vistaMovil") && !$('body').hasClass("MiniSiteA") && !$('body').hasClass("MiniSiteB")) { menu.removeClass("vistaMovil"); } if (claseMenu != "") { $("#nav").addClass(claseMenu); claseMenu = ""; } } else { if (!menu.hasClass("vistaMovil")) { //se dejan de visualizar los elementos copiados en la pagina menu.hide(); // El contenido del menu nunca se muestra de inicio cuando se reduce la pantalla $(".menuAdemas").hide(); $(".compartirMenu").show(); menu.find(".accordion_menu").show(); $("#navMovil").hide(); menu.addClass("vistaMovil"); // elimina la clase horizontal o vertical en la vista movil if ($("#nav").hasClass("menuHor")) { claseMenu = "menuHor"; $("#nav").removeClass("menuHor"); } else if ($("#nav").hasClass("menuVert")) { claseMenu = "menuVert"; $("#nav").removeClass("menuVert"); } } } } } // La primera vez que se genera la pagina se intenta copiar el elemento de navegacion movil function setMenuMovilContent() { if ($('body').hasClass("PortadaMiniSite")) { $(".PortadaMiniSite .innerMenu .marcoMenuInterno .tituloMenu").off("click"); $(".PortadaMiniSite .innerMenu div").removeClass("active"); if (windowWidth < 768) { $(".PortadaMiniSite .innerMenu .marcoMenuInterno ul").hide(); $(".PortadaMiniSite .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } else { $(".PortadaMiniSite .innerMenu .marcoMenuInterno ul").show(); } } else if ($('body').hasClass("MiniSiteC")) { $(".MiniSiteC .innerMenu .marcoMenuInterno .tituloMenu").off("click"); $(".MiniSiteC .innerMenu div").removeClass("active"); if (windowWidth < 768) { $(".MiniSiteC .innerMenu .marcoMenuInterno ul").hide(); $(".MiniSiteC .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } else { $(".MiniSiteC .innerMenu .marcoMenuInterno ul").show(); } } if ((!$.browser.msie || ($.browser.msie && $.browser.version >= 9)) && typeof minisite == 'undefined') { // Debemos tener siempre al menos un elemento ul contenido en el menu var menuContent = $('.menu').find('ul'); //se copian todos los elementos con class=menuAdemas al menu, y se elimina dicha //clase del codigo copiado, ademas se borra el estilo var classesNotToBeRemoved = "redesSociales menuAdemas enlHerramientas"; if (innerMenu) { // gestiona el menu interno si existe classesNotToBeRemoved += " uc3m_ms_slide"; } var cloned = $(".menuAdemas").clone().removeClassExcept(classesNotToBeRemoved); cloned.addClass("compartirMenu"); //se eliminan los elementos que no se van a mostrar cloned.find(".noMovil").remove(); cloned.find("#botonCompartirContenido").attr("id", "botonCompartirContenidoMenu"); cloned.find("#botonCompartirContenidoMenu").find("img").remove(); cloned.find("#compartirContenido").attr("id", "compartirContenidoMenu"); //se elimina cualquier display:none que pueda estar en el atributo style cloned.find("* [style*='display: none']").show(); cloned.hide(); if (typeof cloned.html() == 'undefined' && (menu.hasClass("no-navigation") || $('.menu').find("ul li").html() == undefined)) { // No existiran elementos de navegacion menu.detach(); $("#pull").detach(); } if (innerMenu) { // gestiona el menu interno si existe $('.menu').find('ul.accordion_menu').remove(); if (cloned.filter('.uc3m_ms_slide').size() > 0) { var listaDesplegable = $(""); cloned.filter('.uc3m_ms_slide').each(function (index) { $(this).find('.botonDesplegar').remove(); var item_lista = $('
  • '); item_lista.append($(this).find('.tituloMenu')); item_lista.append($(this).find('ul').addClass("panel")); listaDesplegable.append(item_lista); }); cloned.filter('.uc3m_ms_slide').detach().remove(); $('.menu').prepend(listaDesplegable); $('.accordion_menu').accordion({ handle: '.tituloMenu', canToggle: true, canOpenMultiple: false, speed: 400, easing: "linear" }); } $('.menu').append(cloned); menu.find(".accordion_menu").hide(); menu.find(".compartirMenu").hide(); } else { $('.menu').append(cloned); } //se dejan de visualizar los elementos copiados en la pagina $(".menuAdemas").hide(); setMenuMovil(); } } //opciones de ReCaptcha var RecaptchaOptions = { theme: 'clean' }; // Filtro del listado de grados function recorreGrados(seleccionados) { //Mostramos las cajas+titulo al empezar, las ocultaremos cuando no tengamos resultados de esa lista. $('#noHayGrados').hide(); $('.categoriaGrado').show(); $("ul.listRes li").each(function (i, grado) { // Recorremos la lista de grados $(grado).show();//Muestra el grado. Queremos que todos los grados se muestren al principio var valida = true; $.each(seleccionados, function (j, conj) { //Recorremos cada conjunto de los seleccionados para cada grado if (valida) { var validaConj = false; if (conj.length > 0) { $.each(conj, function (k, filtro) { //Cada conjunto es un array, lo recorremos en filtros if ($(grado).attr("class").indexOf(filtro) > -1) { validaConj = true; } }); if (!validaConj) { valida = false; $(grado).hide(); } } } }); }); //Ocultamos las cajas con el titulo si no hay resultados para ellos var existenGradosVisibles = false; $('.categoriaGrado').each(function () { if ($(this).find("li:visible").length == 0) { $(this).hide(); } else { existenGradosVisibles = true; } }); if (!existenGradosVisibles) { $('#noHayGrados').show(); } } function ajustarWidgetsNoticias() { if ($(".fb-page").size() > 0 || $(".twitter-timeline").size() > 0) { $(".noticias_content").removeAttr("style"); $(".noticias_sidebar").removeAttr("style"); var sidebarWidth = $(".noticias_sidebar").width(); var contentWidth = $(".noticias_content").width(); //console.log("sidebarWidth: " + sidebarWidth); //console.log("contentWidth: " + contentWidth); var difference = 280 - sidebarWidth; if (difference < 0 || $(".menuVert").size() > 0) { difference = 0; } //console.log("difference: " + difference); var newContentWidth = contentWidth - difference - 4; // Ajuste de 4px para que encaje en todos los casos if ($(".menuVert").size() > 0) { newContentWidth = contentWidth + sidebarWidth - 4; // Cuando exista menu vertical la barra lateral se colocara debajo } var sideWidth = 290; if (isMobileWidth() || $(".menuVert").size() > 0) { sideWidth = newContentWidth; } //console.log("sideWidth: " + sideWidth); // Ajuste de 10px para dejar un margen lateral $(".noticias_sidebar").width(sideWidth - 10); // ajustes de 10px para dejar margenes $(".fb-page").width(sideWidth - 10); $(".twitter-timeline").width(sideWidth - 10); $(".noticias_content").width(newContentWidth - 10); } } function isMobileWidth() { return $('#mobile-indicator').is(':visible'); } //funcion para simular doble click en enlaces con hover en dispositivos moviles no ios /* By Osvaldas Valutis, www.osvaldas.info Available for use under the MIT License */ (function ($, window, document, undefined) { $.fn.doubleTapToGo = function (params) { if (!('ontouchstart' in window) && !navigator.msMaxTouchPoints && !navigator.userAgent.toLowerCase().match(/windows phone os 7/i)) return false; this.each(function () { var curItem = false; $(this).on('click', function (e) { var item = $(this); if (item[0] != curItem[0]) { e.preventDefault(); curItem = item; } }); $(document).on('click touchstart MSPointerDown', function (e) { var resetItem = true, parents = $(e.target).parents(); for (var i = 0; i < parents.length; i++) if (parents[i] == curItem[0]) resetItem = false; if (resetItem) curItem = false; }); }); return this; }; })(jQuery, window, document); /* Ficha PAS y PDI */ // Se encarga de los desplegables de filtros PDI PAS function desplegablesFiltradosPDIPAS() { $('.filtrosPASPDI #tags div.marcoAzul') .children('ul') .hide(); $(window).resize(function () { $('.filtrosPASPDI #tags div.marcoAzul') .children('ul') .hide(); }); if ($('html').hasClass('touch')) { // Ya esta definido por defecto el click de los acordeones en movil } else { // Si no es movil (tactil) bindeamos los eventos mouseenter mouseleave $('.filtrosPASPDI #tags div.marcoAzul>.desplegable').off(); $('.filtrosPASPDI #tags div.marcoAzul').on( 'mouseenter mouseleave', function (event) { event.preventDefault(); event.stopPropagation(); var desplegableEl = event.currentTarget.children[0]; var desplegarEl = event.currentTarget.children[1]; if ($(desplegableEl).hasClass('desplegado')) { $(desplegarEl).hide(); $(desplegableEl).removeClass('desplegado'); $(desplegableEl).addClass('replegado'); } else { $(desplegarEl).show(); $(desplegableEl).removeClass('replegado'); $(desplegableEl).addClass('desplegado'); } } ); } } // Se encarga del acordeon de ComisionesDocumentacion de la ficha PDI function acordeonComisionesDocumentacion() { $('dl.comDocumentacion>dt.masReplegado') .siblings('dd') .hide(); $('dl.comDocumentacion>dt.masReplegado').click(function (event) { event.preventDefault(); var desplegarEl = event.target.nextElementSibling; var seleccionadoEl = event.target; $(desplegarEl).toggle(); $(seleccionadoEl).toggleClass('menosDesplegado'); //tamanoFichasPDIPAS(); }); } // Se encarga de la modal de la ficha PDI function toggleModal() { $('.abrirModal').click(function (event) { event.preventDefault(); var titulo = '

    ' + event.target.parentElement.parentElement.previousElementSibling.textContent.toUpperCase() + '

    '; var parentEl = event.target.parentElement; var botonCerrar = '×' + titulo + '
    '; var contenidoModal = botonCerrar + $(parentEl).html() + '
    '; $('.comDocModal').show(); $('.comDocModalContent').html(contenidoModal); $('.comDocModalClose').click(function (event) { event.preventDefault(); $('.comDocModal').hide(); }); closeClickOutModal(); }); } // Se encarga de que el tamaño de las cajas de las fichas mantengan la proporcion function tamanoFichasPDIPAS() { $('.PDI div.ficha1').css('min-height', $('.PDI dl.ficha2').outerHeight() + 40 + 'px'); $('.PAS div.ficha1').css('min-height', $('.PAS dl.ficha2').outerHeight() + 40 + 'px'); } $(window).resize(function () { //tamanoFichasPDIPAS(); }); function waitForElement(elementPath, callBack) { window.setTimeout(function () { if ($(elementPath).length) { callBack(elementPath, $(elementPath)); } else { waitForElement(elementPath, callBack); } }, 500) } /* FIN Ficha PAS y PDI */ $(document).ready(function () { $('#tags') .find('input:checkbox') .change(function () { //Recorremos todos los checkboxes para obtener los seleccionados var seleccionados = new Array(); //Array para guardar los filtros totales seleccionados $('#nubeTags span').remove(); $('#tags') .find('div') .each(function (i, conj_n) { var selecConj = new Array(); // Array para guardar los filtros seleccionados de cada conjunto var cont = 1; $(conj_n) .find('input:checkbox') .each(function (j, fil) { var dataRel = ''; if ($(fil).prop('checked')) { dataRel = $(this).attr('data-filter'); selecConj[cont] = dataRel; //Anadimos el data-filter al conjunto var text = $(this) .parent() .text(); $('#nubeTags').append( $('' + text + '') ); //Mostramos el tag con el filtro cont++; } }); seleccionados[i] = selecConj; recorreGrados(seleccionados); }); $.each(seleccionados, function (i, conjunto) { // Recorremos arrays dentro de seleccionados en conjuntos que contienen filtros $.each(conjunto, function (j, filt) { $('#' + filt).on('click', function () { $('#' + filt).remove(); // Eliminar el tag de pantalla $('#tags [data-filter=' + filt + ']').click(); }); }); }); $('#eliminaFiltros').on('click', function () { // Forma de eliminar todos los filtros mejor implementada. Array vacio. $('input[type=checkbox]').prop('checked', false); $('#nubeTags span').remove(); var vacio = []; recorreGrados(vacio); }); }); if ($('#mobile-indicator').size() == 0) { var $mobileIndicator = $("
    "); $('body').append($mobileIndicator); } $(window).resize(function () { // cada vez que se cambie la resolucion de la pantalla if (!isMobileWidth()) { $('.tags-content').show(); if ($('.tags-content').hasClass('vistaMovil')) { $('.tags-content').removeClass('vistaMovil'); } } else { if (!$('.tags-content').hasClass('vistaMovil')) { $('.tags-content').addClass('vistaMovil'); $('.tags-content').hide(); $('#tags') .find('.tags-toggle') .removeClass('active'); //Corrige que muestre bien los iconos de desplegar y plegar } } }); $('#tags') .find('.tags-toggle') .click(function () { //Acordeon para version movil que muestra las categorias de tags por las que se pueden filtrar if (isMobileWidth()) { $(this) .siblings('ul') .slideToggle('fast') .siblings('ul:visible') .slideUp('fast'); $(this).toggleClass('active'); $(this) .siblings() .removeClass('active'); } }); ajustarWidgetsNoticias(); /* Ficha PAS y PDI */ desplegablesFiltradosPDIPAS(); acordeonComisionesDocumentacion(); toggleModal(); /*Cambio para Safari en el overflow de caja derecha*/ $(function () { if ( navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 ) { $('.PDI').addClass('safari'); $('.PAS').addClass('safari'); $('.filtrosPASPDI').addClass('safari'); } }); waitForElement(".PAS dl.ficha2", function () { //tamanoFichasPDIPAS(); }); waitForElement(".PDI dl.ficha2", function () { //tamanoFichasPDIPAS(); }); /* FIN Ficha PAS y PDI */ /* INICIO menu movil sticky */ $('.buttonMenu2').hide(); if (isPortadaInstitucional) { headerCheckSticky(); } else { var navbar = document.getElementById("nav"); var header = document.getElementById("header"); var logoMovil = document.getElementsByClassName("logomovil")[0]; var logoSticky = document.getElementsByClassName("logomovilsticky")[0]; window.onscroll = function () { if (window.pageYOffset >= header.offsetHeight) { header.classList.add("sticky"); logoMovil.classList.add("noMovil"); logoSticky.classList.remove("noMovil"); navbar.classList.add("sticky"); navbar.style.top = header.offsetHeight + 'px'; if ($(".PortadaMiniSite").length > 0) { $(".logoMinisiteMovil").addClass("noMovil"); $(".tituloSite").removeClass("noMovil"); var windowWidth = Math.max($(window).innerWidth(), window.innerWidth); var isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } if (windowWidth < 768) { $(".tituloSite").show(); } } } else { navbar.classList.remove("sticky"); header.classList.remove("sticky"); logoMovil.classList.remove("noMovil"); logoSticky.classList.add("noMovil"); navbar.style.top = 'initial'; if ($(".PortadaMiniSite").length > 0) { $(".logoMinisiteMovil").removeClass("noMovil"); $(".tituloSite").addClass("noMovil"); $(".tituloSite").hide(); } } }; } /* FIN menu movil sticky */ /* INICIO menus minisite internos escritorio */ if (windowWidth < 768) { if ($('body').hasClass("PortadaMiniSite")) { $(".PortadaMiniSite .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } else if ($('body').hasClass("MiniSiteC")) { $(".MiniSiteC .innerMenu .marcoMenuInterno .tituloMenu").on("click", function (e) { $(e.currentTarget.parentNode.parentNode).siblings().removeClass("active"); $(e.currentTarget.parentNode.parentNode).siblings().children().children().filter('ul[style*="display: block"]').slideToggle(); $(e.currentTarget.parentNode.parentNode).toggleClass("active"); $(e.currentTarget.nextSibling).slideToggle(); }); } } /* FIN menus minisite internos escritorio */ var windowWidth = Math.max($(window).innerWidth(), window.innerWidth); var isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } }); // Compartir RRSS $(document).ready(function () { if ($("#compartirContenido, #compartirContenidoMenu").length) { var shareContent = $("#compartirContenido, #compartirContenidoMenu"); var urlCompartir = encodeURI(location.href).replace("%",""); var shareLink = shareContent.find(".compartirURL"); if (window.isSecureContext && navigator.clipboard) { shareLink.on("mousedown", function() { $(this).addClass("mouse-click"); }); shareLink.click(function (event) { event.preventDefault(); event.stopPropagation(); if (window.isSecureContext && navigator.clipboard) { navigator.clipboard.writeText(urlCompartir); } //* Mostrar mensaje if (!$(this).hasClass(".show-copy-message")) { var actualLink = $(this); actualLink.addClass("show-copy-message"); setTimeout(function() { actualLink.removeClass("show-copy-message"); }, 100); } if ($(this).hasClass("mouse-click")) { $(this).blur(); $(this).removeClass("mouse-click"); } }); //* Para cerrar menu movil despues de mostrar el mensaje $("#compartirContenidoMenu").find(".compartirURL").click(function (event) { setTimeout(function() { $('body').click(); }, 1500); }); } else { shareLink.addClass("not-share"); } shareContent.find(".compartirFB").attr("href", "http://www.facebook.com/sharer.php?u=" + urlCompartir) shareContent.find(".compartirTW").attr("href", "https://twitter.com/intent/tweet?url=" + urlCompartir) shareContent.find(".compartirLI").attr("href", "http://www.linkedin.com/shareArticle?url=" + urlCompartir) } }); /* -------------------- Iframes --------------------*/ var stringAdmitedRoots = ""; var admitedUrls = stringAdmitedRoots.split(","); if (window.addEventListener) { window.addEventListener('message', handleDocHeightMsg, false); } else if (window.attachEvent) { // ie8 window.attachEvent('onmessage', handleDocHeightMsg); } // Para IE function checkInteger(num) { var toret; if (Number.isInteger != undefined) { toret = Number.isInteger(num); } else { toret = (typeof num === 'number' && isFinite(num) && Math.floor(num) === num); } return toret; } function handleDocHeightMsg(e) { var permitida = false; var urlOrigin = e.origin; admitedUrls.forEach(function (item, index) { if (urlOrigin.startsWith(item)) { permitida = true; } }); if (permitida) { var data = JSON.parse(e.data); if (data['iframeUrl'] && data['height']) { var iframeUrlRecibida = data['iframeUrl']; var alturaRecibida = data['height']; if (checkInteger(alturaRecibida) && alturaRecibida > 0) { var iframe = $("iframe.responsive-iframe[src='" + iframeUrlRecibida + "']"); if (iframe.length > 0) { var origen = iframe.attr('data-iframe-origin'); if (typeof origen == typeof undefined || origen == false) { iframe.attr('data-iframe-origin', 'external'); // IEs anteriores a IE11 if (window.navigator.userAgent.indexOf("MSIE ") > -1) { alturaRecibida += 50; } } // IE11 if (!!window.MSInputMethodContext && !!document.documentMode) { alturaRecibida += 100; } resizeIframe(iframe, alturaRecibida); } } } } } function resizeIframe(iframe, height) { var myIframe = iframe[0]; var heightFinal = "500px"; var widthFinal = "500px"; var scrollFinal = "yes"; if (typeof (myIframe) != 'undefined' && myIframe != null) { if (height > 0) { heightFinal = height + "px"; widthFinal = "100%"; //scrollFinal = "no"; } else { // lightbox if (iframe.parents('.lightbox-container').length > 0) { widthFinal = "100%"; if ($(window).width() >= 768 && $(window).width() <= 1279) { heightFinal = (Math.ceil($(window).height() * 0.85)) + "px"; } else { heightFinal = (Math.ceil($(window).height() * 0.7)) + "px"; } } else { var height = iframe.attr("data-height"); var width = iframe.attr("data-width"); var mobileHeight = iframe.attr("data-mobile-height"); var mobileWidth = iframe.attr("data-mobile-width"); if ($(window).width() < 768) { if ((typeof mobileHeight !== typeof undefined && mobileHeight !== false) && (typeof mobileWidth !== typeof undefined && mobileWidth !== false)) { heightFinal = mobileHeight; widthFinal = mobileWidth; } } else { if ((typeof height !== typeof undefined && height !== false) && (typeof width !== typeof undefined && width !== false)) { heightFinal = height; widthFinal = width; } } } } myIframe.height = heightFinal; myIframe.width = widthFinal; myIframe.scrolling = scrollFinal; } } function resizeInternalFrame(padre) { var iframe = padre.find(".responsive-iframe"); if (!iframe.has("data-iframe-origin") || iframe.attr("data-iframe-origin") != "external") { var height = 0; try { height = iframe[0].contentWindow.document.body.offsetHeight; } catch (err) { height = 0; } resizeIframe(iframe, height); } } function cargarIframe(desplegable) { var padre = desplegable.parent(); if (padre.has(".loading-iframe")) { desplegable.on('click', function (e) { var loading = padre.find(".loading-iframe"); var loadingToReplace = padre.find(".loading-iframe-replace"); var iframeUrl = loadingToReplace.attr("data-iframe-url"); if (typeof iframeUrl !== typeof undefined && iframeUrl !== false) { var iframeHTML = '' + '
    ' + '' + '
    '; loadingToReplace.replaceWith(iframeHTML); var iframe = padre.find("iframe.responsive-iframe"); iframe.on("load", function () { loading.remove(); // si el iframe es externo se gestionaran sus dimensiones cuando la pagina mande su altura resizeInternalFrame(iframe.parent()); iframe.parent().css("width", "99%"); setTimeout(function () { iframe.parent().css("width", "100%"); }, 100); }); } }); } } $(window).resize(function () { $(".desplegable.desplegado, .comDocModalContent").each(function (i) { var padre = $(this).parent(); if (padre.has(".responsive-iframe")) { resizeInternalFrame(padre); } }); }); $(document).ready(function () { $(".desplegable.replegado").each(function (i) { var desplegable = $(this); cargarIframe(desplegable) }); }); /* -------------------- Lightbox para Docencia -------------------- */ $(document).ready(function () { $('.lightbox-only-desktop').on('click', function (event) { event.preventDefault(); var windowWidth = Math.max($(window).innerWidth(), window.innerWidth); var isWebkit = /WebKit/.test(navigator.userAgent); if (isWebkit && usarWidthWebkit) { windowWidth = document.documentElement.clientWidth; } // con la ventana a 1020px, especificamente estos iframes pasan a modo escritorio if (windowWidth < 1020) { event.stopPropagation(); var iframeUrl = $(this).parent().attr("data-iframe-url"); window.open(iframeUrl, '_blank'); } }); }); /* -------------------- Proporción videos 16:9 -------------------- */ $(document).ready(function () { $(".video-container").each(function (i) { var wVideo = $(this).width(); var newHeight = wVideo/1.78; // Proporcion 16:9 $(this).css("padding-bottom", newHeight) }); }); $(window).on("resize orientationchange", function () { $(".video-container").each(function (i) { var wVideo = $(this).width(); var newHeight = wVideo/1.78; // Proporcion 16:9 $(this).css("padding-bottom", newHeight) }); });