From abf3da24827c465c5769bd06e015f4a1a06fe696 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 25 Dec 2013 18:04:30 -0700 Subject: [PATCH] Fix zixaphir/appchan-x#507 --- builds/4chan-X.user.js | 16 +++++++--------- builds/crx/script.js | 16 +++++++--------- src/General/Header.coffee | 24 ++++++++++++++++-------- 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 84803348d..972736f1e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1900,17 +1900,15 @@ return Header.previousOffset = offsetY; }, setBarPosition: function(bottom) { + var args; + Header.barPositionToggler.checked = bottom; $.event('CloseMenu'); - if (bottom) { - $.addClass(doc, 'bottom-header'); - $.rmClass(doc, 'top-header'); - return Header.bar.parentNode.className = 'bottom'; - } else { - $.addClass(doc, 'top-header'); - $.rmClass(doc, 'bottom-header'); - return Header.bar.parentNode.className = 'top'; - } + args = bottom ? ['bottom-header', 'top-header', 'bottom', 'after'] : ['top-header', 'bottom-header', 'top', 'add']; + $.addClass(doc, args[0]); + $.rmClass(doc, args[1]); + Header.bar.parentNode.className = args[2]; + return $[args[3]](Header.bar, Header.notify); }, toggleBarPosition: function() { $.cb.checked.call(this); diff --git a/builds/crx/script.js b/builds/crx/script.js index e41efb467..c2a1a120b 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1924,17 +1924,15 @@ return Header.previousOffset = offsetY; }, setBarPosition: function(bottom) { + var args; + Header.barPositionToggler.checked = bottom; $.event('CloseMenu'); - if (bottom) { - $.addClass(doc, 'bottom-header'); - $.rmClass(doc, 'top-header'); - return Header.bar.parentNode.className = 'bottom'; - } else { - $.addClass(doc, 'top-header'); - $.rmClass(doc, 'bottom-header'); - return Header.bar.parentNode.className = 'top'; - } + args = bottom ? ['bottom-header', 'top-header', 'bottom', 'after'] : ['top-header', 'bottom-header', 'top', 'add']; + $.addClass(doc, args[0]); + $.rmClass(doc, args[1]); + Header.bar.parentNode.className = args[2]; + return $[args[3]](Header.bar, Header.notify); }, toggleBarPosition: function() { $.cb.checked.call(this); diff --git a/src/General/Header.coffee b/src/General/Header.coffee index bba089aa5..5d221cae3 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -301,14 +301,22 @@ Header = setBarPosition: (bottom) -> Header.barPositionToggler.checked = bottom $.event 'CloseMenu' - if bottom - $.addClass doc, 'bottom-header' - $.rmClass doc, 'top-header' - Header.bar.parentNode.className = 'bottom' - else - $.addClass doc, 'top-header' - $.rmClass doc, 'bottom-header' - Header.bar.parentNode.className = 'top' + args = if bottom then [ + 'bottom-header' + 'top-header' + 'bottom' + 'after' + ] else [ + 'top-header' + 'bottom-header' + 'top' + 'add' + ] + + $.addClass doc, args[0] + $.rmClass doc, args[1] + Header.bar.parentNode.className = args[2] + $[args[3]] Header.bar, Header.notify toggleBarPosition: -> $.cb.checked.call @