From cf1d94876ad994344c47ac54764362b431a47588 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 15 Apr 2013 21:45:36 +0200 Subject: [PATCH] $.off these 4chanXInitFinished. --- src/databoard.coffee | 5 ++++- src/features.coffee | 11 +++++++++-- src/qr.coffee | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/databoard.coffee b/src/databoard.coffee index 0e41af492..cceb63c10 100644 --- a/src/databoard.coffee +++ b/src/databoard.coffee @@ -8,7 +8,10 @@ class DataBoard return unless sync # Chrome also fires the onChanged callback on the current tab, # so we only start syncing when we're ready. - $.on d, '4chanXInitFinished', => @sync = sync + init = => + $.off d, '4chanXInitFinished', init + @sync = sync + $.on d, '4chanXInitFinished', init delete: ({boardID, threadID, postID}) -> if postID diff --git a/src/features.coffee b/src/features.coffee index 8288228b2..8333a410e 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -297,6 +297,7 @@ Settings = localStorage.setItem '4chan-settings', JSON.stringify settings open: (openSection) -> + $.off d, '4chanXInitFinished', Settings.open return if Settings.dialog $.event 'CloseMenu' @@ -1778,11 +1779,13 @@ Keybinds = init: -> return if g.VIEW is 'catalog' or !Conf['Keybinds'] - $.on d, '4chanXInitFinished', -> + init = -> + $.off d, '4chanXInitFinished', init $.on d, 'keydown', Keybinds.keydown for node in $$ '[accesskey]' node.removeAttribute 'accesskey' return + $.on d, '4chanXInitFinished', init keydown: (e) -> return unless key = Keybinds.keyCode e @@ -1999,7 +2002,10 @@ Nav = $.on next, 'click', @next $.add span, [prev, $.tn(' '), next] - $.on d, '4chanXInitFinished', -> $.add d.body, span + append = -> + $.off d, '4chanXInitFinished', append + $.add d.body, span + $.on d, '4chanXInitFinished', append prev: -> if g.VIEW is 'thread' @@ -4259,6 +4265,7 @@ ThreadWatcher = $.delete 'AutoWatch' ready: -> + $.off d, '4chanXInitFinished', ThreadWatcher.ready return unless Main.isThisPageLegit() ThreadWatcher.refresh() $.add d.body, ThreadWatcher.dialog diff --git a/src/qr.coffee b/src/qr.coffee index feb3edc9d..010d2d1ed 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -14,6 +14,7 @@ QR = cb: @node initReady: -> + $.off d, '4chanXInitFinished', QR.initReady QR.postingIsEnabled = !!$.id 'postForm' return unless QR.postingIsEnabled