Commit | Line | Data |
---|---|---|
1760080e AE |
1 | $.Redactor.prototype.WoltLabDropdown = function() { |
2 | "use strict"; | |
3 | ||
4 | return { | |
5 | init: function() { | |
6 | // prevent overflow: hidden on body while hovering dropdowns | |
7 | this.utils.disableBodyScroll = function() {}; | |
8 | this.utils.enableBodyScroll = function() {}; | |
9 | ||
10 | // disable slideUp effect for dropdowns on close | |
f2351ad6 | 11 | this.WoltLabDropdown._hideAll(); |
1760080e AE |
12 | |
13 | // disable slideDown effect for dropdowns on open | |
14 | // enforce dropdownMenu-like DOM | |
f2351ad6 | 15 | this.WoltLabDropdown._show(); |
1760080e AE |
16 | }, |
17 | ||
18 | _hideAll: function() { | |
19 | var hideAll = this.dropdown.hideAll; | |
42af78b3 AE |
20 | this.dropdown.hideAll = (function(e, key) { |
21 | hideAll.call(this, e, key); | |
1760080e AE |
22 | |
23 | $('.redactor-dropdown-' + this.uuid).stop(true, true).hide(); | |
24 | }).bind(this); | |
25 | }, | |
26 | ||
27 | _show: function() { | |
28 | var show = this.dropdown.show; | |
29 | this.dropdown.show = (function(e, key) { | |
30 | var $button = this.button.get(key); | |
31 | var $dropdown = $button.data('dropdown'); | |
32 | ||
33 | if (!elDataBool($dropdown[0], 'woltlab')) { | |
34 | var list = elCreate('ul'); | |
35 | list.className = 'dropdownMenu'; | |
36 | ||
1760080e | 37 | while ($dropdown[0].childElementCount) { |
16764d0d | 38 | list.appendChild($dropdown[0].children[0]); |
1760080e AE |
39 | } |
40 | ||
41 | $dropdown[0].appendChild(list); | |
42 | ||
43 | elData($dropdown[0], 'woltlab', true); | |
44 | } | |
45 | ||
46 | var isActive = $button.hasClass('dropact'); | |
47 | ||
48 | show.call(this, e, key); | |
49 | ||
50 | if (!isActive) { | |
51 | $dropdown.stop(true).show(); | |
52 | } | |
53 | }).bind(this); | |
54 | ||
55 | } | |
56 | }; | |
57 | }; |