PageSourceSearch

https://www.u2valencia.com/web/plugins/system/t4/themes/base/js/megamenu.js

js u2valencia.com collected 2026-10-02 13:40:34 UTC 8,426 bytes, 251 lines download raw bytes

1jQuery(document).ready(function ($) {
2  window.mobileCheck = function () {
3    let check = false;
4    (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
5    return check;
6  };
7  window.isTouchDevice = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
8
9  // process dropdown hover event
10  var navitem_selector = ".t4-megamenu .nav-item";
11  var hideDropdowns = function ($activeitem) {
12    $activeitem.removeClass("show").find(".dropdown-menu").removeClass("show");
13    endAnimating($activeitem);
14  };
15
16  const winWidth = window.innerWidth;
17
18  function getDropdownWidth($el) {
19    const $parent = $el.closest('.dropdown');
20
21    $parent.addClass('animating');
22
23    const width = $el.outerWidth();
24
25    $parent.removeClass('animating');
26
27    return width;
28  }
29
30  var pos = function ($activeitem) {
31    const $dropdown = $activeitem.children(".dropdown-menu")
32    const $parentDropdown = $activeitem.closest(".dropdown-menu");
33
34    if ($parentDropdown.length) {
35      const parentDropWidth = $parentDropdown.outerWidth();
36      const activeElmOffset = $activeitem.offset();
37      const activeElmWidth = $activeitem.width();
38      const dropdownWidth = getDropdownWidth($dropdown);
39      let marginLeft = 0;
40
41      if (winWidth - activeElmOffset.left - activeElmWidth < parentDropWidth) {
42        marginLeft = 0 - dropdownWidth - activeElmWidth;
43      } else {
44        marginLeft = 0;
45      }
46
47      $dropdown.css("margin-left", marginLeft + "px");
48    } else {
49      var rtl = $("html").attr("dir") == "rtl",
50        dw = $dropdown.outerWidth(),
51        ww = $(window).width(),
52        dl = $dropdown.offset().left,
53        iw = $activeitem.width(),
54        il = $activeitem.offset().left,
55        ml = null,
56        align = $activeitem.data("align");
57      ml =
58        align == "center"
59          ? (iw - dw) / 2
60          : align == "right"
61            ? dw - iw
62            : align == "justify"
63              ? (iw - dw) / 2
64              : 0;
65      if (dw < ww) {
66        if (il + ml < 20) ml = 20 - il;
67        if (il + ml + dw > ww - 20) ml = ww - 20 - il - dw;
68      } else {
69        ml = (ww - dw) / 2 - il;
70      }
71
72      $dropdown.css("margin-left", ml);
73    }
74  };
75
76  var posrtl = function ($activeitem) {
77    const $dropdown = $activeitem.children(".dropdown-menu");
78    const $parentDropdown = $activeitem.closest(".dropdown-menu");
79
80    $dropdown.addClass("show");
81    $activeitem.addClass("show");
82
83    if ($parentDropdown.length) {
84      const parentDropWidth = $parentDropdown.outerWidth();
85      const elmOffset = $activeitem.offset();
86      const dropdownWidth = getDropdownWidth($dropdown);
87      let marginRight = 0;
88
89      if (elmOffset.left < parentDropWidth) {
90        marginRight = 0 - dropdownWidth - $activeitem.width();
91      } else {
92        marginRight = 0;
93      }
94
95      $dropdown.css("margin-right", marginRight + "px");
96    } else {
97      var rtl = $("html").attr("dir") == "rtl",
98        dw = $dropdown.width(),
99        ww = $(window).width(),
100        dl = $dropdown.offset().left,
101        iw = $activeitem.width(),
102        il = $activeitem.offset().left,
103        ml = null,
104        align = $activeitem.data("align");
105
106      ml =
107        align == "center"
108          ? (dw - iw) / 2
109          : align == "right"
110            ? dw - iw
111            : align == "justify"
112              ? ww / 2
113              : 0;
114      if (dw < ww) {
115        if (il + iw + ml > ww - 20) ml = ww - 20 - il - iw;
116        if (il + iw + ml < dw + 20) ml = dw + 20 - il - iw;
117      } else {
118        ml = ww - il - iw + (dw - ww) / 2;
119      }
120      $dropdown.css("margin-right", -ml);
121    }
122  };
123
124  var showDropdown = function ($activeitem) {
125    $activeitem.addClass("show");
126    $activeitem.children(".dropdown-menu").addClass("show");
127
128    if ($("html").attr("dir") == "rtl") {
129      posrtl($activeitem);
130    } else {
131      pos($activeitem);
132    }
133
134    // with animation, start animating after some ms
135    startAnimating($activeitem);
136  };
137
138  var startAnimating = function ($item) {
139    // get duration
140    var $menu = $item.closest(".t4-megamenu");
141
142    if (!$menu.hasClass("animate")) return;
143
144    $item.addClass("animating");
145  };
146
147  var endAnimating = function ($item) {
148    // remove animating class to make sure the dropdown is totally hidden
149    // get duration
150    var $menu = $item.closest(".t4-megamenu");
151    if (!$menu.hasClass("animate")) return;
152
153    $item.removeClass("animating");
154  };
155
156  $(navitem_selector).on('mouseenter', e => {
157    if (window.isTouchDevice) {
158      return;
159    }
160
161    const $elm = $(e.currentTarget);
162    const $currentDropdown = $elm.children('.dropdown-menu');
163
164    if (!$currentDropdown.length) {
165      return;
166    }
167
168    if ($elm.hasClass('animating')) {
169      return;
170    }
171
172    showDropdown($elm);
173  }).on('mouseleave', e => {
174    if (window.isTouchDevice) {
175      return;
176    }
177
178    const $elm = $(e.currentTarget);
179
180    if (!$elm.children('.dropdown-menu').length) {
181      return;
182    }
183
184    hideDropdowns($elm);
185  });
186
187  // if menu open, just open the link
188  let activeNavId = 0;
189
190  $(".nav-item.dropdown > .dropdown-toggle").on('touchstart', function (e) {
191    if (!window.isTouchDevice) {
192      return;
193    }
194
195    const $el = $(e.currentTarget);
196    const $navItem = $el.parent();
197
198    if ($el.parents('.t4-offcanvas').length) {
199      return;
200    }
201
202    const navId = $navItem.attr('data-id');
203
204    if (activeNavId !== navId) {
205      e.stopPropagation();
206      e.preventDefault();
207
208      activeNavId = navId;
209    }
210
211    showDropdown($navItem);
212
213    if (window.outerWidth > 990) {
214      const activeIds = [+$navItem.data('id')];
215
216      $navItem.parents('.nav-item').map((i, el) => {
217        activeIds.push(+el.dataset.id);
218      });
219
220      $('.t4-megamenu .nav-item.dropdown').each((i, el) => {
221        if (activeIds.indexOf(+el.dataset.id) === -1) {
222          hideDropdowns($(el));
223        }
224      });
225    }
226  });
227
228  $(document).on('click', e => {
229    if (window.outerWidth < 990 || !window.isTouchDevice) {
230      return;
231    }
232
233    const $target = $(e.target);
234
235    if ($target.closest('.t4-megamenu').length) {
236      return;
237    }
238
239    activeNavId = 0;
240
241    $('.t4-megamenu .nav-item.dropdown.show').each((i, el) => {
242      hideDropdowns($(el));
243    })
244  })
245
246  // show toggler
247  $(".t4-megamenu").each(function () {
248    $toggle = $('.navbar-toggler[data-target="#' + this.id + '"]');
249    if ($toggle.length == 1) $toggle.removeAttr("style");
250  });
251});

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.