Fix board list toggle keybind not working where there are no toggle button.

This commit is contained in:
Nicolas Stepien 2013-03-14 21:29:56 +01:00
parent 1692b5de3b
commit 9682fbd149
2 changed files with 17 additions and 13 deletions

View File

@ -1123,11 +1123,13 @@
return $.add(list, nodes); return $.add(list, nodes);
}, },
toggleBoardList: function() { toggleBoardList: function() {
var bar, showBoardList; var bar, custom, full, showBoardList;
showBoardList = $.hasClass(this, 'show-board-list-button');
bar = Header.bar; bar = Header.bar;
$('#custom-board-list', bar).hidden = showBoardList; custom = $('#custom-board-list', bar);
return $('#full-board-list', bar).hidden = !showBoardList; full = $('#full-board-list', bar);
showBoardList = !full.hidden;
custom.hidden = !showBoardList;
return full.hidden = showBoardList;
}, },
setCatalogLinks: function(useCatalog) { setCatalogLinks: function(useCatalog) {
var a, as, str, _i, _len; var a, as, str, _i, _len;
@ -2887,7 +2889,7 @@
}); });
}, },
keydown: function(e) { keydown: function(e) {
var el, form, key, notification, notifications, target, thread, threadRoot, _i, _len, _ref; var form, key, notification, notifications, target, thread, threadRoot, _i, _len, _ref;
if (!(key = Keybinds.keyCode(e))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -2901,8 +2903,8 @@
thread = Get.postFromNode($('.op', threadRoot)).thread; thread = Get.postFromNode($('.op', threadRoot)).thread;
switch (key) { switch (key) {
case Conf['Toggle board list']: case Conf['Toggle board list']:
if (Conf['Custom Board Navigation'] && (el = $('span:not([hidden]) > .show-board-list-button, span:not([hidden]) > .hide-board-list-button', Header.bar))) { if (Conf['Custom Board Navigation']) {
Header.toggleBoardList.call(el); Header.toggleBoardList();
} }
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:

View File

@ -95,10 +95,12 @@ Header =
$.add list, nodes $.add list, nodes
toggleBoardList: -> toggleBoardList: ->
showBoardList = $.hasClass @, 'show-board-list-button' {bar} = Header
{bar} = Header custom = $ '#custom-board-list', bar
$('#custom-board-list', bar).hidden = showBoardList full = $ '#full-board-list', bar
$('#full-board-list', bar).hidden = !showBoardList showBoardList = !full.hidden
custom.hidden = !showBoardList
full.hidden = showBoardList
setCatalogLinks: (useCatalog) -> setCatalogLinks: (useCatalog) ->
as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar
@ -1624,8 +1626,8 @@ Keybinds =
switch key switch key
# QR & Options # QR & Options
when Conf['Toggle board list'] when Conf['Toggle board list']
if Conf['Custom Board Navigation'] and el = $ 'span:not([hidden]) > .show-board-list-button, span:not([hidden]) > .hide-board-list-button', Header.bar if Conf['Custom Board Navigation']
Header.toggleBoardList.call el Header.toggleBoardList()
when Conf['Open empty QR'] when Conf['Open empty QR']
Keybinds.qr threadRoot Keybinds.qr threadRoot
when Conf['Open QR'] when Conf['Open QR']