diff --git a/src/General/DataBoard.coffee b/src/General/DataBoard.coffee index aa6ef84f8..1c59940ac 100644 --- a/src/General/DataBoard.coffee +++ b/src/General/DataBoard.coffee @@ -3,7 +3,7 @@ DataBoards = ['hiddenThreads', 'hiddenPosts', 'lastReadPosts', 'yourPosts', 'wat class DataBoard constructor: (@key, sync, dontClean) -> @data = Conf[key] - $.sync key, @onSync.bind @ + $.sync key, @onSync @clean() unless dontClean return unless sync # Chrome also fires the onChanged callback on the current tab, @@ -84,6 +84,6 @@ class DataBoard @deleteIfEmpty {boardID} @save() - onSync: (data) -> + onSync: (data) => @data = data or boards: {} @sync?() diff --git a/src/General/Notification.coffee b/src/General/Notification.coffee index dc3043071..a3f1d8d1c 100644 --- a/src/General/Notification.coffee +++ b/src/General/Notification.coffee @@ -1,8 +1,5 @@ class Notification constructor: (type, content, @timeout) -> - @add = add.bind @ - @close = close.bind @ - @el = $.el 'div', innerHTML: '×
' @el.style.opacity = 0 @@ -17,7 +14,7 @@ class Notification setType: (type) -> @el.className = "notification #{type}" - add = -> + add: => if d.hidden $.on d, 'visibilitychange', @add return @@ -27,5 +24,5 @@ class Notification @el.style.opacity = 1 setTimeout @close, @timeout * $.SECOND if @timeout - close = -> + close: => $.rm @el diff --git a/src/General/UI.coffee b/src/General/UI.coffee index 7fb0abe2d..c2ad0d09d 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -17,8 +17,7 @@ UI = do -> constructor: (@type) -> # Doc here: https://github.com/MayhemYDG/4chan-x/wiki/Menu-API - $.on d, 'AddMenuEntry', @addEntry.bind @ - @close = close.bind @ + $.on d, 'AddMenuEntry', @addEntry @entries = [] makeMenu: -> @@ -27,7 +26,7 @@ UI = do -> id: 'menu' tabIndex: 0 $.on menu, 'click', (e) -> e.stopPropagation() - $.on menu, 'keydown', @keybinds.bind @ + $.on menu, 'keydown', @keybinds menu toggle: (e, button, data) -> @@ -98,7 +97,7 @@ UI = do -> $.add entry.el, submenu return - close = -> + close: => $.rm currentMenu currentMenu = null lastToggledButton = null @@ -110,7 +109,7 @@ UI = do -> +(first.style.order or first.style.webkitOrder) - +(second.style.order or second.style.webkitOrder) entries[entries.indexOf(entry) + direction] - keybinds: (e) -> + keybinds: (e) => entry = $ '.focused', currentMenu while subEntry = $ '.focused', entry entry = subEntry @@ -167,7 +166,7 @@ UI = do -> $.addClass submenu, 'right' $.rmClass submenu, 'left' - addEntry: (e) -> + addEntry: (e) => entry = e.detail return if entry.type isnt @type @parseEntry entry diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 88a226a9e..6da3f8cf0 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -446,7 +446,7 @@ QR = $.on elm, 'blur', QR.focusout $.on elm, 'focus', QR.focusin <% } %> - $.on el, 'click', @select.bind @ + $.on el, 'click', @select $.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm() $.on @nodes.label, 'click', (e) => e.stopPropagation() $.on @nodes.spoiler, 'change', (e) => @@ -516,7 +516,7 @@ QR = @nodes.el.draggable = !lock unlock: -> @lock false - select: -> + select: => if QR.selected QR.selected.nodes.el.id = null QR.selected.forceSave()