Add the CloseMenu event/API.

This commit is contained in:
Nicolas Stepien 2013-02-13 18:24:59 +01:00
parent 4f28b6d2e5
commit 2d677acad4
4 changed files with 15 additions and 11 deletions

View File

@ -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') {

View File

@ -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

View File

@ -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',

View File

@ -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'