PageSourceSearch

https://www.um.es/o/um-lr-genericov2-um-theme/js/main.js?browserId…=js&languageId=es_ES&t=1789981596000

js um.es collected 2026-09-24 08:08:28 UTC 5,589 bytes, 167 lines download raw bytes

1/*1789981596000*/
2/**
3 * Comprueba el tamaño de la pantalla y activa o desactiva el despliegue de los
4 * submenús al hacer click. Su objetivo es permitir en el menú de navegación de
5 * escritorio el despliegue de los submenús mediante hover y que se acceda
6 * directamente al enlace del menú al hacer clic. En el menú móvil se debe dejar
7 * activado para permitir su despliegue al tocar con el dedo.
8 */
9$(() => {
10  const HIDE_ACTION = 'hide';
11  const STICKY_CLASS = 'fixed-top';
12  const CHEVRON_DOWN_ICON_CLASS = 'fa-chevron-down';
13  const CHEVRON_UP_ICON_CLASS = 'fa-chevron-up';
14  const FIXED_HEADER = 'fixed-header';
15  const VISIBLE_SELECTOR = '.show';
16  const TOGGLE_ICONS_SELECTOR = '#navegacion-movil .has-child > i';
17  const SHOW_COLLAPSIBLE_EVENT = 'show.bs.collapse';
18  const CLICK_EVENT = 'click touch';
19
20  let verticalOffset;
21  const $navMovil = $('#navegacion-movil');
22  const $menuMovil = $('#menu-movil');
23  const $miWebMovil = $('#mi-web-movil');
24  const $cuerpo = $('.cuerpo');
25  const navOffset = $navMovil.offset();
26  const stickyThreshold = navOffset.top;
27  const $noLinkNodes = $('.breadcrumb li a[href*="/sin-enlace/"]');
28
29  function _addAutoClosingEvent($node) {
30    $node.on(SHOW_COLLAPSIBLE_EVENT, () => {
31      $node.find(VISIBLE_SELECTOR).collapse(HIDE_ACTION);
32    });
33  }
34
35  function _scrollEventHandler() {
36    if (window.pageYOffset > stickyThreshold) {
37      $navMovil.addClass(STICKY_CLASS);
38      $cuerpo.addClass(FIXED_HEADER);
39    } else {
40      $navMovil.removeClass(STICKY_CLASS);
41      $cuerpo.removeClass(FIXED_HEADER);
42    }
43  }
44
45  function scrollToTop() {
46    const element = $('body');
47    const offset = element.offset();
48    const offsetTop = offset.top;
49    verticalOffset = typeof (verticalOffset) !== 'undefined' ? verticalOffset : 0;
50    $('html, body').animate({ scrollTop: offsetTop }, { duration: 500, easing: 'linear' });
51  }
52
53  function _setMobileMenuHeight($menu) {
54    const rect = $menu[0].getBoundingClientRect();
55    const calculatedHeightValue = window.innerHeight - rect.top;
56    const calculatedHeight = calculatedHeightValue + 'px';
57
58    $menu.css('height', calculatedHeight);
59    $menu.css('max-height', calculatedHeight);
60  }
61
62  /* Controla que se vea o no el botón Volver Arriba */
63  $(document).on('scroll', () => {
64    // noinspection JSValidateTypes
65    if ($(window).scrollTop() > 100) {
66      $('#scrolltop').addClass('show');
67    } else {
68      $('#scrolltop').removeClass('show');
69    }
70  });
71
72  // Hace que el menú se fije a la parte superior al desplazar la pantalla
73  window.onscroll = _scrollEventHandler;
74
75  // Fija el tamaño del menú móvil para conseguir el efecto de scroll y configura el resize
76  _setMobileMenuHeight($menuMovil);
77  if ($miWebMovil.length > 0) {
78    _setMobileMenuHeight($miWebMovil);
79  }
80  $(window).on('resize shown.bs.collapse', () => {
81    _setMobileMenuHeight($menuMovil);
82    if ($miWebMovil.length > 0) {
83      _setMobileMenuHeight($miWebMovil);
84    }
85  });
86
87  /* Evento para subir al inicio al pulsar el botón Ir Arriba */
88  $('#scrolltop').on('click', scrollToTop);
89
90  /* Añade el target="_blank" a la pestaña de vídeos del CMN */
91  $('.cmn #navegacion-lista a[href*="youtube.com/user/campusmarenostrum"]').attr('target', '_blank');
92
93  _addAutoClosingEvent($('.accesos'));
94  _addAutoClosingEvent($('#navegacion-movil__submenu--parent'));
95
96  /* Cambia los iconos de desplegado del toggle de la navegación móvil */
97  $(TOGGLE_ICONS_SELECTOR).on(CLICK_EVENT, function () {
98    const $this = $(this);
99
100    if ($this.hasClass('collapsed')) {
101      $this.removeClass(CHEVRON_DOWN_ICON_CLASS).addClass(CHEVRON_UP_ICON_CLASS);
102    } else {
103      $this.removeClass(CHEVRON_UP_ICON_CLASS).addClass(CHEVRON_DOWN_ICON_CLASS);
104    }
105  });
106
107  $('#navegacion .navbar-default .navbar-nav>li>div>a').on(CLICK_EVENT, function () {
108    window.location.href = this.href;
109  });
110
111  /* Evento para cerrar los menús de móvil al hacer click fuera de él */
112  if ($menuMovil.length > 0 || $miWebMovil.length > 0) {
113    $(document).on('mouseup', (event) => {
114      if ($menuMovil.length > 0) {
115        if (!$menuMovil.is(event.target) && $menuMovil.has(event.target).length === 0) {
116          $menuMovil.collapse(HIDE_ACTION);
117        }
118      }
119      if ($miWebMovil.length > 0) {
120        if (!$miWebMovil.is(event.target) && $miWebMovil.has(event.target).length === 0) {
121          $miWebMovil.collapse(HIDE_ACTION);
122        }
123      }
124    });
125  }
126
127  /* Quita páginas sin enlace de las migas de pan */
128  $noLinkNodes.replaceWith($noLinkNodes.text());
129
130  // Inicializa plugins
131  if (typeof UM !== 'undefined') {
132    if (typeof UM.ImgNormalizer !== 'undefined') {
133      UM.ImgNormalizer.init();
134    }
135
136    if (typeof UM.LayoutUtils !== 'undefined') {
137      UM.LayoutUtils.setFullHeight($('.layout-height, .um-bloque-flotante'));
138    }
139
140    if (typeof UM.Acc !== 'undefined') {
141      // Menús barra superior
142      UM.Acc.initNav(
143        $('#accesos__botones .accesos__boton--menu'),
144        $('#accesos__panel--menu')
145      );
146
147      UM.Acc.initNav(
148        $('#accesos__botones .accesos__boton--buscar'),
149        $('#accesos__panel--buscar')
150      );
151
152      // Menú gris de navegación
153      $('#navegacion-lista .dropdown:not(.no-menu)').each(function () {
154        UM.Acc.initNav(
155          $(this).find('.apartado__boton-submenu'),
156          $(this).find('.dropdown-menu')
157        );
158      });
159    }
160  }
161
162  // Inicializaciones del plugin Agenda SIU
163  if (typeof $.fn.agendaSiu === 'function') {
164    // Inicializa los componentes de Agenda SIU
165    $('.agenda-siu').agendaSiu();
166  }
167});

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.