mirror of
https://github.com/pretix/pretix.git
synced 2026-10-02 19:24:42 +00:00
* ESlint: Ignore vendored and pre-vue code * Format pre-vue code with eslint where possible --------- Co-authored-by: Kara Engelhardt <engelhardt@pretix.eu>
83 lines
2.0 KiB
JavaScript
83 lines
2.0 KiB
JavaScript
/*
|
|
* Based on:
|
|
* metismenu - v1.1.3
|
|
* Easy menu jQuery plugin for Twitter Bootstrap 3
|
|
* https://github.com/onokumus/metisMenu
|
|
*
|
|
* Made by Osman Nuri Okumus
|
|
* Under MIT License
|
|
* Modified by Raphael Michel
|
|
*/
|
|
;(function ($, window, document, undefined) {
|
|
let pluginName = 'metisMenu',
|
|
defaults = {
|
|
toggle: true,
|
|
}
|
|
|
|
function Plugin (element, options) {
|
|
this.element = $(element)
|
|
this.settings = $.extend({}, defaults, options)
|
|
this._defaults = defaults
|
|
this._name = pluginName
|
|
this.init()
|
|
}
|
|
|
|
Plugin.prototype = {
|
|
init: function () {
|
|
let $this = this.element,
|
|
$toggle = this.settings.toggle,
|
|
obj = this
|
|
|
|
if (this.isIE() <= 9) {
|
|
$this.find('li.active').has('ul').children('ul').collapse('show')
|
|
$this.find('li').not('.active').has('ul').children('ul').collapse('hide')
|
|
} else {
|
|
$this.find('li.active').has('ul').children('ul').addClass('collapse in')
|
|
$this.find('li').not('.active').has('ul').children('ul').addClass('collapse')
|
|
}
|
|
|
|
$this.find('li').has('ul').children('a.arrow').on('click' + '.' + pluginName, function (e) {
|
|
e.preventDefault()
|
|
$(this).blur()
|
|
|
|
$(this).parent('li').toggleClass('active').children('ul').collapse('toggle')
|
|
|
|
if ($toggle) {
|
|
$(this).parent('li').siblings().removeClass('active').children('ul.in').collapse('hide')
|
|
}
|
|
})
|
|
},
|
|
|
|
isIE: function () { // https://gist.github.com/padolsey/527683
|
|
let undef,
|
|
v = 3,
|
|
div = document.createElement('div'),
|
|
all = div.getElementsByTagName('i')
|
|
|
|
while (
|
|
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
|
|
all[0]
|
|
) {
|
|
return v > 4 ? v : undef
|
|
}
|
|
},
|
|
|
|
remove: function () {
|
|
this.element.off('.' + pluginName)
|
|
this.element.removeData(pluginName)
|
|
}
|
|
|
|
}
|
|
|
|
$.fn[pluginName] = function (options) {
|
|
this.each(function () {
|
|
let el = $(this)
|
|
if (el.data(pluginName)) {
|
|
el.data(pluginName).remove()
|
|
}
|
|
el.data(pluginName, new Plugin(this, options))
|
|
})
|
|
return this
|
|
}
|
|
})(jQuery, window, document)
|