From 9682fbd149f8d062ba4ce082720b7a913d7d8856 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 14 Mar 2013 21:29:56 +0100 Subject: [PATCH] Fix board list toggle keybind not working where there are no toggle button. --- 4chan_x.user.js | 16 +++++++++------- src/features.coffee | 14 ++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 81d151886..e2a7f4e0c 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1123,11 +1123,13 @@ return $.add(list, nodes); }, toggleBoardList: function() { - var bar, showBoardList; - showBoardList = $.hasClass(this, 'show-board-list-button'); + var bar, custom, full, showBoardList; bar = Header.bar; - $('#custom-board-list', bar).hidden = showBoardList; - return $('#full-board-list', bar).hidden = !showBoardList; + custom = $('#custom-board-list', bar); + full = $('#full-board-list', bar); + showBoardList = !full.hidden; + custom.hidden = !showBoardList; + return full.hidden = showBoardList; }, setCatalogLinks: function(useCatalog) { var a, as, str, _i, _len; @@ -2887,7 +2889,7 @@ }); }, 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))) { return; } @@ -2901,8 +2903,8 @@ thread = Get.postFromNode($('.op', threadRoot)).thread; switch (key) { 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))) { - Header.toggleBoardList.call(el); + if (Conf['Custom Board Navigation']) { + Header.toggleBoardList(); } break; case Conf['Open empty QR']: diff --git a/src/features.coffee b/src/features.coffee index 6caf661e8..acc730515 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -95,10 +95,12 @@ Header = $.add list, nodes toggleBoardList: -> - showBoardList = $.hasClass @, 'show-board-list-button' - {bar} = Header - $('#custom-board-list', bar).hidden = showBoardList - $('#full-board-list', bar).hidden = !showBoardList + {bar} = Header + custom = $ '#custom-board-list', bar + full = $ '#full-board-list', bar + showBoardList = !full.hidden + custom.hidden = !showBoardList + full.hidden = showBoardList setCatalogLinks: (useCatalog) -> as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar @@ -1624,8 +1626,8 @@ Keybinds = switch key # QR & Options 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 - Header.toggleBoardList.call el + if Conf['Custom Board Navigation'] + Header.toggleBoardList() when Conf['Open empty QR'] Keybinds.qr threadRoot when Conf['Open QR']