Fix ToggleBarVisibility keybind

This commit is contained in:
Zixaphir 2013-08-15 20:05:46 -07:00
parent 449aedee63
commit 9d5ef234e9
4 changed files with 20 additions and 32 deletions

View File

@ -1730,17 +1730,14 @@
(hide ? $.addClass : $.rmClass)(Header.bar, 'autohide'); (hide ? $.addClass : $.rmClass)(Header.bar, 'autohide');
return (hide ? $.addClass : $.rmClass)(doc, 'autohide'); return (hide ? $.addClass : $.rmClass)(doc, 'autohide');
}, },
toggleBarVisibility: function(e) { toggleBarVisibility: function() {
var hide, message; var hide, message;
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
hide = this.nodeName === 'INPUT' ? this.checked : !$.hasClass(Header.bar, 'autohide'); hide = this.nodeName === 'INPUT' ? this.checked : !$.hasClass(Header.bar, 'autohide');
Conf['Header auto-hide'] = hide; this.checked = hide;
$.set('Header auto-hide', hide); $.set('Header auto-hide', Conf['Header auto-hide'] = hide);
Header.setBarVisibility(hide); Header.setBarVisibility(hide);
message = hide ? 'The header bar will automatically hide itself.' : 'The header bar will remain visible.'; message = "The header bar will " + (hide ? 'automatically hide itself.' : 'remain visible.');
return new Notification('info', message, 2); return new Notification('info', message, 2);
}, },
setFooterVisibility: function(hide) { setFooterVisibility: function(hide) {
@ -9452,10 +9449,7 @@
} }
break; break;
case Conf['Toggle header']: case Conf['Toggle header']:
if (!$('#menu.left')) { Header.toggleBarVisibility();
Header.menuButton.click();
}
Header.headerToggler.click();
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:
Keybinds.qr(threadRoot); Keybinds.qr(threadRoot);

View File

@ -1746,17 +1746,14 @@
(hide ? $.addClass : $.rmClass)(Header.bar, 'autohide'); (hide ? $.addClass : $.rmClass)(Header.bar, 'autohide');
return (hide ? $.addClass : $.rmClass)(doc, 'autohide'); return (hide ? $.addClass : $.rmClass)(doc, 'autohide');
}, },
toggleBarVisibility: function(e) { toggleBarVisibility: function() {
var hide, message; var hide, message;
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
hide = this.nodeName === 'INPUT' ? this.checked : !$.hasClass(Header.bar, 'autohide'); hide = this.nodeName === 'INPUT' ? this.checked : !$.hasClass(Header.bar, 'autohide');
Conf['Header auto-hide'] = hide; this.checked = hide;
$.set('Header auto-hide', hide); $.set('Header auto-hide', Conf['Header auto-hide'] = hide);
Header.setBarVisibility(hide); Header.setBarVisibility(hide);
message = hide ? 'The header bar will automatically hide itself.' : 'The header bar will remain visible.'; message = "The header bar will " + (hide ? 'automatically hide itself.' : 'remain visible.');
return new Notification('info', message, 2); return new Notification('info', message, 2);
}, },
setFooterVisibility: function(hide) { setFooterVisibility: function(hide) {
@ -9442,10 +9439,7 @@
} }
break; break;
case Conf['Toggle header']: case Conf['Toggle header']:
if (!$('#menu.left')) { Header.toggleBarVisibility();
Header.menuButton.click();
}
Header.headerToggler.click();
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:
Keybinds.qr(threadRoot); Keybinds.qr(threadRoot);

View File

@ -244,19 +244,21 @@ Header =
(if hide then $.addClass else $.rmClass) Header.bar, 'autohide' (if hide then $.addClass else $.rmClass) Header.bar, 'autohide'
(if hide then $.addClass else $.rmClass) doc, 'autohide' (if hide then $.addClass else $.rmClass) doc, 'autohide'
toggleBarVisibility: (e) -> toggleBarVisibility: ->
return if e.type is 'mousedown' and e.button isnt 0 # not LMB
hide = if @nodeName is 'INPUT' hide = if @nodeName is 'INPUT'
@checked @checked
else else
!$.hasClass Header.bar, 'autohide' !$.hasClass Header.bar, 'autohide'
Conf['Header auto-hide'] = hide # set checked status if called from keybind
$.set 'Header auto-hide', hide @checked = hide
$.set 'Header auto-hide', Conf['Header auto-hide'] = hide
Header.setBarVisibility hide Header.setBarVisibility hide
message = if hide message = "The header bar will #{if hide
'The header bar will automatically hide itself.' 'automatically hide itself.'
else else
'The header bar will remain visible.' 'remain visible.'}"
new Notification 'info', message, 2 new Notification 'info', message, 2
setFooterVisibility: (hide) -> setFooterVisibility: (hide) ->

View File

@ -25,9 +25,7 @@ Keybinds =
if Conf['Custom Board Navigation'] if Conf['Custom Board Navigation']
Header.toggleBoardList() Header.toggleBoardList()
when Conf['Toggle header'] when Conf['Toggle header']
unless $('#menu.left') Header.toggleBarVisibility()
Header.menuButton.click()
Header.headerToggler.click()
when Conf['Open empty QR'] when Conf['Open empty QR']
Keybinds.qr threadRoot Keybinds.qr threadRoot
when Conf['Open QR'] when Conf['Open QR']