PageSourceSearch

https://about.upi.com/js/plugins/metisMenu/jquery.metisMenu.js

js upi.com collected 2026-09-24 07:31:53 UTC 13,090 bytes, 341 lines download raw bytes

1/*!
2 * metismenu - v2.7.7
3 * A jQuery menu plugin
4 * https://github.com/onokumus/metismenu#readme
5 *
6 * Made by Osman Nuri Okumus <[email protected]> (https://github.com/onokumus)
7 * Under MIT License
8 */
9(function (global, factory) {
10    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
11        typeof define === 'function' && define.amd ? define(['jquery'], factory) :
12            (global.metisMenu = factory(global.jQuery));
13}(this, (function ($) { 'use strict';
14
15    $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
16
17    function _defineProperty(obj, key, value) {
18        if (key in obj) {
19            Object.defineProperty(obj, key, {
20                value: value,
21                enumerable: true,
22                configurable: true,
23                writable: true
24            });
25        } else {
26            obj[key] = value;
27        }
28
29        return obj;
30    }
31
32    function _objectSpread(target) {
33        for (var i = 1; i < arguments.length; i++) {
34            var source = arguments[i] != null ? arguments[i] : {};
35            var ownKeys = Object.keys(source);
36
37            if (typeof Object.getOwnPropertySymbols === 'function') {
38                ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
39                    return Object.getOwnPropertyDescriptor(source, sym).enumerable;
40                }));
41            }
42
43            ownKeys.forEach(function (key) {
44                _defineProperty(target, key, source[key]);
45            });
46        }
47
48        return target;
49    }
50
51    var Util = function ($$$1) {
52        // eslint-disable-line no-shadow
53        var TRANSITION_END = 'transitionend';
54        var Util = {
55            // eslint-disable-line no-shadow
56            TRANSITION_END: 'mmTransitionEnd',
57            triggerTransitionEnd: function triggerTransitionEnd(element) {
58                $$$1(element).trigger(TRANSITION_END);
59            },
60            supportsTransitionEnd: function supportsTransitionEnd() {
61                return Boolean(TRANSITION_END);
62            }
63        };
64
65        function getSpecialTransitionEndEvent() {
66            return {
67                bindType: TRANSITION_END,
68                delegateType: TRANSITION_END,
69                handle: function handle(event) {
70                    if ($$$1(event.target).is(this)) {
71                        return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
72                    }
73
74                    return undefined;
75                }
76            };
77        }
78
79        function transitionEndEmulator(duration) {
80            var _this = this;
81
82            var called = false;
83            $$$1(this).one(Util.TRANSITION_END, function () {
84                called = true;
85            });
86            setTimeout(function () {
87                if (!called) {
88                    Util.triggerTransitionEnd(_this);
89                }
90            }, duration);
91            return this;
92        }
93
94        function setTransitionEndSupport() {
95            $$$1.fn.mmEmulateTransitionEnd = transitionEndEmulator; // eslint-disable-line no-param-reassign
96            // eslint-disable-next-line no-param-reassign
97
98            $$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
99        }
100
101        setTransitionEndSupport();
102        return Util;
103    }($);
104
105    var MetisMenu = function ($$$1) {
106        // eslint-disable-line no-shadow
107        var NAME = 'metisMenu';
108        var DATA_KEY = 'metisMenu';
109        var EVENT_KEY = "." + DATA_KEY;
110        var DATA_API_KEY = '.data-api';
111        var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
112        var TRANSITION_DURATION = 350;
113        var Default = {
114            toggle: true,
115            preventDefault: true,
116            activeClass: 'active',
117            collapseClass: 'collapse',
118            collapseInClass: 'in',
119            collapsingClass: 'collapsing',
120            triggerElement: 'a',
121            parentTrigger: 'li',
122            subMenu: 'ul'
123        };
124        var Event = {
125            SHOW: "show" + EVENT_KEY,
126            SHOWN: "shown" + EVENT_KEY,
127            HIDE: "hide" + EVENT_KEY,
128            HIDDEN: "hidden" + EVENT_KEY,
129            CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
130        };
131
132        var MetisMenu =
133            /*#__PURE__*/
134            function () {
135                // eslint-disable-line no-shadow
136                function MetisMenu(element, config) {
137                    this.element = element;
138                    this.config = _objectSpread({}, Default, config);
139                    this.transitioning = null;
140                    this.init();
141                }
142
143                var _proto = MetisMenu.prototype;
144
145                _proto.init = function init() {
146                    var self = this;
147                    var conf = this.config;
148                    $$$1(this.element).find(conf.parentTrigger + "." + conf.activeClass).has(conf.subMenu).children(conf.subMenu).attr('aria-expanded', true).addClass(conf.collapseClass + " " + conf.collapseInClass);
149                    $$$1(this.element).find(conf.parentTrigger).not("." + conf.activeClass).has(conf.subMenu).children(conf.subMenu).attr('aria-expanded', false).addClass(conf.collapseClass);
150                    $$$1(this.element).find(conf.parentTrigger).has(conf.subMenu).children(conf.triggerElement).on(Event.CLICK_DATA_API, function (e) {
151                        // eslint-disable-line func-names
152                        var eTar = $$$1(this);
153                        var paRent = eTar.parent(conf.parentTrigger);
154                        var sibLings = paRent.siblings(conf.parentTrigger).children(conf.triggerElement);
155                        var List = paRent.children(conf.subMenu);
156
157                        if (conf.preventDefault) {
158                            e.preventDefault();
159                        }
160
161                        if (eTar.attr('aria-disabled') === 'true') {
162                            return;
163                        }
164
165                        if (paRent.hasClass(conf.activeClass)) {
166                            eTar.attr('aria-expanded', false);
167                            self.hide(List);
168                        } else {
169                            self.show(List);
170                            eTar.attr('aria-expanded', true);
171
172                            if (conf.toggle) {
173                                sibLings.attr('aria-expanded', false);
174                            }
175                        }
176
177                        if (conf.onTransitionStart) {
178                            conf.onTransitionStart(e);
179                        }
180                    });
181                };
182
183                _proto.show = function show(element) {
184                    var _this = this;
185
186                    if (this.transitioning || $$$1(element).hasClass(this.config.collapsingClass)) {
187                        return;
188                    }
189
190                    var elem = $$$1(element);
191                    var startEvent = $$$1.Event(Event.SHOW);
192                    elem.trigger(startEvent);
193
194                    if (startEvent.isDefaultPrevented()) {
195                        return;
196                    }
197
198                    elem.parent(this.config.parentTrigger).addClass(this.config.activeClass);
199
200                    if (this.config.toggle) {
201                        this.hide(elem.parent(this.config.parentTrigger).siblings().children(this.config.subMenu + "." + this.config.collapseInClass).attr('aria-expanded', false));
202                    }
203
204                    elem.removeClass(this.config.collapseClass).addClass(this.config.collapsingClass).height(0);
205                    this.setTransitioning(true);
206
207                    var complete = function complete() {
208                        // check if disposed
209                        if (!_this.config || !_this.element) {
210                            return;
211                        }
212
213                        elem.removeClass(_this.config.collapsingClass).addClass(_this.config.collapseClass + " " + _this.config.collapseInClass).height('').attr('aria-expanded', true);
214
215                        _this.setTransitioning(false);
216
217                        elem.trigger(Event.SHOWN);
218                    };
219
220                    if (!Util.supportsTransitionEnd()) {
221                        complete();
222                        return;
223                    }
224
225                    elem.height(element[0].scrollHeight).one(Util.TRANSITION_END, complete).mmEmulateTransitionEnd(TRANSITION_DURATION);
226                };
227
228                _proto.hide = function hide(element) {
229                    var _this2 = this;
230
231                    if (this.transitioning || !$$$1(element).hasClass(this.config.collapseInClass)) {
232                        return;
233                    }
234
235                    var elem = $$$1(element);
236                    var startEvent = $$$1.Event(Event.HIDE);
237                    elem.trigger(startEvent);
238
239                    if (startEvent.isDefaultPrevented()) {
240                        return;
241                    }
242
243                    elem.parent(this.config.parentTrigger).removeClass(this.config.activeClass); // eslint-disable-next-line no-unused-expressions
244
245                    elem.height(elem.height())[0].offsetHeight;
246                    elem.addClass(this.config.collapsingClass).removeClass(this.config.collapseClass).removeClass(this.config.collapseInClass);
247                    this.setTransitioning(true);
248
249                    var complete = function complete() {
250                        // check if disposed
251                        if (!_this2.config || !_this2.element) {
252                            return;
253                        }
254
255                        if (_this2.transitioning && _this2.config.onTransitionEnd) {
256                            _this2.config.onTransitionEnd();
257                        }
258
259                        _this2.setTransitioning(false);
260
261                        elem.trigger(Event.HIDDEN);
262                        elem.removeClass(_this2.config.collapsingClass).addClass(_this2.config.collapseClass).attr('aria-expanded', false);
263                    };
264
265                    if (!Util.supportsTransitionEnd()) {
266                        complete();
267                        return;
268                    }
269
270                    if (elem.height() === 0 || elem.css('display') === 'none') {
271                        complete();
272                    } else {
273                        elem.height(0).one(Util.TRANSITION_END, complete).mmEmulateTransitionEnd(TRANSITION_DURATION);
274                    }
275                };
276
277                _proto.setTransitioning = function setTransitioning(isTransitioning) {
278                    this.transitioning = isTransitioning;
279                };
280
281                _proto.dispose = function dispose() {
282                    $$$1.removeData(this.element, DATA_KEY);
283                    $$$1(this.element).find(this.config.parentTrigger).has(this.config.subMenu).
283children(this.config.triggerElement).off('click');
284                    this.transitioning = null;
285                    this.config = null;
286                    this.element = null;
287                };
288
289                MetisMenu.jQueryInterface = function jQueryInterface(config) {
290                    // eslint-disable-next-line func-names
291                    return this.each(function () {
292                        var $this = $$$1(this);
293                        var data = $this.data(DATA_KEY);
294
295                        var conf = _objectSpread({}, Default, $this.data(), typeof config === 'object' && config ? config : {});
296
297                        if (!data && /dispose/.test(config)) {
298                            this.dispose();
299                        }
300
301                        if (!data) {
302                            data = new MetisMenu(this, conf);
303                            $this.data(DATA_KEY, data);
304                        }
305
306                        if (typeof config === 'string') {
307                            if (data[config] === undefined) {
308                                throw new Error("No method named \"" + config + "\"");
309                            }
310
311                            data[config]();
312                        }
313                    });
314                };
315
316                return MetisMenu;
317            }();
318        /**
319         * ------------------------------------------------------------------------
320         * jQuery
321         * ------------------------------------------------------------------------
322         */
323
324
325        $$$1.fn[NAME] = MetisMenu.jQueryInterface; // eslint-disable-line no-param-reassign
326
327        $$$1.fn[NAME].Constructor = MetisMenu; // eslint-disable-line no-param-reassign
328
329        $$$1.fn[NAME].noConflict = function () {
330            // eslint-disable-line no-param-reassign
331            $$$1.fn[NAME] = JQUERY_NO_CONFLICT; // eslint-disable-line no-param-reassign
332
333            return MetisMenu.jQueryInterface;
334        };
335
336        return MetisMenu;
337    }($);
338
339    return MetisMenu;
340
341})));

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.