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