1// JavaScript Document 2(function ($) { 3 Drupal.behaviors.myBehavior2 = { 4 attach: function (context, settings) { 5 // Accesibilidad: Hacer el idioma activo focusable 6 $('.active-language', context).once('lang-focusable').each(function() { 7 var $activeLanguage = $(this); 8 var $wrapper = $activeLanguage.closest('.dropbutton-wrapper'); 9 var $secondaryLinks = $wrapper.find('.dropbutton-action.secondary-action a'); 10 11 $activeLanguage.attr('tabindex', '0'); 12 13 // Inicialmente ocultar enlaces secundarios del tab order 14 $secondaryLinks.attr('tabindex', '-1'); 15 16 // Permitir abrir el dropdown con Enter o Espacio 17 $activeLanguage.on('keydown', function(e) { 18 if (e.key === 'Enter' || e.key === ' ') { 19 e.preventDefault(); 20 var $toggleButton = $wrapper.find('.dropbutton-toggle button'); 21 $toggleButton.trigger('click'); 22 23 // Después de abrir, hacer focusables los enlaces 24 setTimeout(function() { 25 if ($wrapper.hasClass('open')) { 26 $secondaryLinks.attr('tabindex', '0'); 27 } 28 }, 100); 29 } 30 }); 31 32 // Observar cambios en la clase 'open' del wrapper 33 var observer = new MutationObserver(function(mutations) { 34 mutations.forEach(function(mutation) { 35 if (mutation.attributeName === 'class') { 36 if ($wrapper.hasClass('open')) { 37 $secondaryLinks.attr('tabindex', '0'); 38 } else { 39 $secondaryLinks.attr('tabindex', '-1'); 40 } 41 } 42 }); 43 }); 44 45 observer.observe($wrapper[0], { 46 attributes: true, 47 attributeFilter: ['class'] 48 }); 49 }); 50 51 // Author: Leire Oliden 08/2018 52 // Functionality: add + and - to the submenu of the segmento 53 54 $(context).find(".nav-item.menu-item--expanded a.toggle-icon").once().bind('click', function () { 55 if ($(this).find('.fa-plus').hasClass('d-sm-block')) { 56 $(this).next(".menu.collapse").slideUp(); 57 58 $(this).find('.fa-plus').removeClass('d-sm-block'); 59 $(this).find('.fa-plus').addClass('d-none'); 60 61 $(this).find('.fa-minus').removeClass('d-none'); 62 $(this).find('.fa-minus').addClass('d-sm-block'); 63 64 $(this).parent().addClass('clicked'); 65 //$('header').css('position', 'absolute'); 66 //$('.menu-transversal-responsive').css('position', 'absolute'); 67 } 68 else { 69 $(this).next(".menu.collapse").slideDown(); 70 71 $(this).find('.fa-minus').removeClass('d-sm-block'); 72 $(this).find('.fa-minus').addClass('d-none'); 73 74 $(this).find('.fa-plus').removeClass('d-none'); 75 $(this).find('.fa-plus').addClass('d-sm-block'); 76 $(this).parent().removeClass('clicked'); 77 //$('header').css('position', 'fixed'); 78 //$('.menu-transversal-responsive').css('position', 'fixed'); 79 } 80 }); 81 82 // se añade la clase al body en función de los niveles del menú 83 var $lv1Items = $('#navbar-top .navbar-collapse .menu-principal ul.nav li.nav-item.menu-item--expanded.menu-item--active-trail .outer-menu li.menu-item--expanded.menu-item--active-trail'); 84 var $lv1ItemsIngles = $('#block-principalingles > li.nav-item.menu-item--expanded.menu-item--active-trail li.nav-item.menu-item--expanded.menu-item--active-trail li.nav-item.menu-item--active-trail'); 85 var $lv2Items = $('#navbar-top .navbar-collapse .menu-principal ul.nav li.nav-item.menu-item--expanded.menu-item--active-trail .outer-menu li.menu-item--active-trail'); 86 var $lv2ItemsExpanded = $('li.nav-item.menu-item--expanded.menu-item--active-trail > div.menu-level-2'); 87 var $viewIndicadorDeRiesto = $('.view-indicador-de-riesgo'); 88 89 if ($lv1Items.length === 1 || $lv1ItemsIngles.length === 1 || $lv2ItemsExpanded.length > 0) { 90 $('body').addClass('menu-lv-3'); 91 // Ocultar migas 92 if ($viewIndicadorDeRiesto.length > 0) { 93 $('.breadcrumb').hide(); 94 } 95 } else if ($lv2Items.length === 1) { 96 $('body').addClass('menu-lv-2'); 97 } 98 99 // Guillermo - 17/06/2021 100 // Este codigo es para poner bien el texto del dropdown cuando estas en el menu movil 101 // Solo afecta a las cabeceras viejas, no a las nuevas desarrolladas con el modulo weg_header 102 let path = window.location.pathname; 103 let weg_header = $(".weg-header"); 104 if (weg_header == null || weg_header == undefined || weg_header.length == 0) { 105 $(context).find('.dropdown-item').once().each(function () { 106 let item = $(this); 107 if (path.includes(item.attr('href'))) { 108 $('#dropdownMenuButton').html(item.html()); 109 } 110 }); 111 } 112 113 //Hacer que salgan las columnas del footer en funcion del selector en version movil 114 $(context).find('#boton_movil').once().bind('change', function () { 115 var cId = $(this).val(); 116 $('.site-footer__top .footer-col').hide(); 117 $('#' + cId).show(); 118 }); 119 120 if ($(window).width() > 992) { 121 //Guillermo - 16/06/2021 122 //He borrado todo el codigo que se encargaba de poner la clase menu-item--active-trail porque lo hace bien el propio drupal 123 //Este codigo mira si esta el tercer nivel de menu esta desplegado y aplica padding en caso afirmativo 124 if (document.readyState === "complete") { 125 $(context).find('.menu-level-2').once().each(function () { 126 let menu = $(this); 127 if (menu.height() > 0 && menu.is(":visible")) { //Si el menu de tercer nivel esta desplegado aplicar el padding 128 $('#main-wrapper').css('padding-top', '222px'); 129 } 130 }); 131 } 132 } 133 } 134 } 135 136})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.