PageSourceSearch

https://www.um.es/o/um-lr-74-principal-theme/js/utils/um-utils.js?…=js&languageId=es_ES&t=1790587750000

js um.es collected 2026-10-01 08:31:04 UTC 3,968 bytes, 144 lines download raw bytes

1/*1790587750000*/
2var UM = window.UM || {};
3(function () {
4  const SCREEN_SM_MAX = 991;
5  const MODE_NORMAL = 'normal';
6  const MODE_DESKTOP = 'desktop';
7  const MODE_MOBILE = 'mobile';
8
9  function _isSmSize() {
10    return (Liferay.Util.getWindowWidth() <= SCREEN_SM_MAX);
11  }
12
13  function _addHeights($elements) {
14    const elementHeights = [];
15
16    // Obtiene la altura de cada elemento y la almacena
17    $elements.each(function () {
18      let prevCSS;
19      let $parentItem;
20      let outerHeight;
21      const $this = $(this);
22
23      // Si el elemento esta oculto, lo muestra temporalmente para calcular su altura
24      if ($this.is(':hidden')) {
25        // Caso para elementos ocultos del Carrusel
26        $parentItem = $this.parents('.carousel-item');
27        if ($parentItem) {
28          prevCSS = $parentItem.attr('style');
29          $parentItem.css({
30            position: 'absolute',
31            visibility: 'hidden',
32            display: 'block'
33          });
34          outerHeight = $this.outerHeight();
35          $parentItem.attr('style', prevCSS || '');
36        }
37      } else {
38        outerHeight = $this.outerHeight();
39      }
40      elementHeights.push(outerHeight);
41    });
42
43    // Calcula la altura mayor y la asigna a todos los elementos
44    const newHeight = Math.max.apply(null, elementHeights);
45    $elements.css('height', newHeight + 'px');
46  }
47
48  function _removeHeights($elements) {
49    $elements.css('height', '');
50  }
51
52  function _heightCaptionsCheck($elements, mode) {
53    const isMobile = $(window).width() < 768;
54    const normalize = mode === MODE_NORMAL
55      || (mode === MODE_DESKTOP && !isMobile)
56      || (mode === MODE_MOBILE && isMobile);
57
58    _removeHeights($elements);
59    if (normalize) {
60      _addHeights($elements);
61    }
62  }
63
64  function _dataURLtoBlob(dataurl) {
65    const arr = dataurl.split(',');
66    const mime = arr[0].match(/:(.*?);/)[1];
67    const bstr = atob(arr[1]); let n = bstr.length;
68    const u8arr = new Uint8Array(n);
69
70    while (n--) {
71      u8arr[n] = bstr.charCodeAt(n);
72    }
73    return new Blob([u8arr], { type: mime });
74  }
75
76  function _normalizeHeight(elements, mode) {
77    const $elements = $(elements);
78    if ($elements) {
79      _heightCaptionsCheck($elements, mode || MODE_NORMAL);
80      $(window).on('resize', () => {
81        _heightCaptionsCheck($elements, mode || MODE_NORMAL);
82      });
83    }
84  }
85
86  function _getURLParameter(param) {
87    let parameter;
88    let i;
89    const pageURL = window.location.search.substring(1);
90    const URLVariables = pageURL.split('&');
91
92    for (i = 0; i < URLVariables.length; i += 1) {
93      parameter = URLVariables[i].split('=');
94
95      if (parameter[0] === param) {
96        return parameter[1];
97      }
98    }
99
100    return undefined;
101  }
102
103  UM.Utils = {
104    dataURLtoBlob: _dataURLtoBlob,
105    getUrlParameter: _getURLParameter,
106    isSmSize: _isSmSize,
107    normalizeHeight: _normalizeHeight
108  };
109}());
110
111(function(window) {
112  'use strict';
113
114  // Namespace global
115  window.UMUtils = window.UMUtils || {};
116
117  // Sub-namespace para utilidades de interfaz de usuario
118  UMUtils.UI = UMUtils.UI || {};
119
120  /**
121   * Alterna el icono de un botón de menú con animación fade.
122   * @param {HTMLImageElement} icon - Elemento <img> del icono.
123   * @param {Object} paths - Rutas de los iconos.
124   * @param {string} paths.closed - Ruta del icono cerrado.
125   * @param {string} paths.open - Ruta del icono abierto.
126   */
127  UMUtils.UI.toggleMenuIcon = function(icon, paths) {
128      icon.classList.add("fade-out");
129
130      setTimeout(() => {
131          // Compara solo el nombre del archivo para mayor flexibilidad
132          const closedIconName = paths.closed.split('/').pop();
133          icon.src = icon.src.includes(closedIconName) ? paths.open : paths.closed;
134
135          icon.classList.remove("fade-out");
136          icon.classList.add("fade-in");
137
138          setTimeout(() => {
139              icon.classList.remove("fade-in");
140          }, 300);
141      }, 300);
142  };
143})(window);
144

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.