diff --git a/4chan_x.user.js b/4chan_x.user.js index a043fcf02..640750d91 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -261,6 +261,7 @@ } this.focus($('.entry', menu)); $.on(d, 'click', this.close); + $.on(d, 'CloseMenu', this.close); $.add(d.body, menu); mRect = menu.getBoundingClientRect(); bRect = button.getBoundingClientRect(); @@ -305,7 +306,8 @@ $.rm(currentMenu); currentMenu = null; lastToggledButton = null; - return $.off(d, 'click', this.close); + $.off(d, 'click', this.close); + return $.off(d, 'CloseMenu', this.close); }; Menu.prototype.keybinds = function(e) { @@ -1060,7 +1062,7 @@ return localStorage.setItem('4chan-settings', JSON.stringify(settings)); }, open: function() { - return Header.menu.close(); + return $.event('CloseMenu'); } }; @@ -1459,7 +1461,7 @@ thread = ThreadHiding.menu.thread; ThreadHiding.hide(thread, makeStub); ThreadHiding.saveHiddenState(thread, makeStub); - return Menu.close(); + return $.event('CloseMenu'); } }, makeButton: function(thread, type) { @@ -1680,7 +1682,7 @@ return; } ReplyHiding.saveHiddenState(post, true, thisPost, makeStub, replies); - return Menu.close(); + return $.event('CloseMenu'); } }, makeButton: function(post, type) { @@ -3809,7 +3811,7 @@ href: 'javascript:;' }); $.on(link, 'click', function() { - Header.menu.close(); + $.event('CloseMenu'); QR.open(); if (g.BOARD.ID === 'f') { if (g.VIEW === 'index') { diff --git a/lib/ui.coffee b/lib/ui.coffee index 7d21e5c31..1697e178d 100644 --- a/lib/ui.coffee +++ b/lib/ui.coffee @@ -53,7 +53,8 @@ UI = (-> @insertEntry entry, menu, data @focus $ '.entry', menu - $.on d, 'click', @close + $.on d, 'click', @close + $.on d, 'CloseMenu', @close $.add d.body, menu # Position @@ -99,7 +100,8 @@ UI = (-> $.rm currentMenu currentMenu = null lastToggledButton = null - $.off d, 'click', @close + $.off d, 'click', @close + $.off d, 'CloseMenu', @close keybinds: (e) -> entry = $ '.focused', currentMenu diff --git a/src/features.coffee b/src/features.coffee index bc3e9fe5a..421ed4eaf 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -128,7 +128,7 @@ Settings = settings.disableAll = true localStorage.setItem '4chan-settings', JSON.stringify settings open: -> - Header.menu.close() + $.event 'CloseMenu' # Here be settings Filter = @@ -500,7 +500,7 @@ ThreadHiding = {thread} = ThreadHiding.menu ThreadHiding.hide thread, makeStub ThreadHiding.saveHiddenState thread, makeStub - Menu.close() + $.event 'CloseMenu' makeButton: (thread, type) -> a = $.el 'a', @@ -661,7 +661,7 @@ ReplyHiding = else return ReplyHiding.saveHiddenState post, true, thisPost, makeStub, replies - Menu.close() + $.event 'CloseMenu' makeButton: (post, type) -> a = $.el 'a', diff --git a/src/qr.coffee b/src/qr.coffee index 0a8a11d24..09f4c6ea6 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -10,7 +10,7 @@ QR = textContent: 'Quick Reply' href: 'javascript:;' $.on link, 'click', -> - Header.menu.close() + $.event 'CloseMenu' QR.open() if g.BOARD.ID is 'f' if g.VIEW is 'index'