FappeTyme refactoring.

This commit is contained in:
ccd0 2014-12-20 16:23:49 -08:00
parent db261f1358
commit 3dfa1cfdcc
2 changed files with 12 additions and 14 deletions

View File

@ -2,6 +2,7 @@ FappeTyme =
init: -> init: ->
return if !(Conf['Fappe Tyme'] or Conf['Werk Tyme']) or g.VIEW is 'catalog' or g.BOARD is 'f' return if !(Conf['Fappe Tyme'] or Conf['Werk Tyme']) or g.VIEW is 'catalog' or g.BOARD is 'f'
@nodes = {}
@enabled = @enabled =
fappe: false fappe: false
werk: Conf['werk'] werk: Conf['werk']
@ -11,15 +12,14 @@ FappeTyme =
el = UI.checkbox lc, " #{type} Tyme", false el = UI.checkbox lc, " #{type} Tyme", false
el.title = "#{type} Tyme" el.title = "#{type} Tyme"
FappeTyme[lc] = input = el.firstElementChild @nodes[lc] = el.firstElementChild
$.on input, 'change', FappeTyme.cb.toggle.bind input @set lc, true if Conf[lc]
$.on @nodes[lc], 'change', @toggle.bind(@, lc)
Header.menu.addEntry Header.menu.addEntry
el: el el: el
order: 97 order: 97
FappeTyme.cb.set lc if Conf[lc]
Post.callbacks.push Post.callbacks.push
name: 'Fappe Tyme' name: 'Fappe Tyme'
cb: @node cb: @node
@ -40,12 +40,10 @@ FappeTyme =
className: 'werkTyme-filename' className: 'werkTyme-filename'
$.add @nodes.thumb.parentNode, filename $.add @nodes.thumb.parentNode, filename
cb: set: (type, enabled) ->
set: (type) -> @enabled[type] = @nodes[type].checked = enabled
FappeTyme[type].checked = FappeTyme.enabled[type] $["#{if enabled then 'add' else 'rm'}Class"] doc, "#{type}Tyme"
$["#{if FappeTyme.enabled[type] then 'add' else 'rm'}Class"] doc, "#{type}Tyme"
toggle: -> toggle: (type) ->
FappeTyme.enabled[@name] = !FappeTyme.enabled[@name] @set type, !@enabled[type]
FappeTyme.cb.set @name $.cb.checked.call @nodes[type] if type is 'werk'
$.cb.checked.call FappeTyme[@name] if @name is 'werk'

View File

@ -97,10 +97,10 @@ Keybinds =
Gallery.cb.toggle() Gallery.cb.toggle()
when Conf['fappeTyme'] when Conf['fappeTyme']
return if !Conf['Fappe Tyme'] or g.VIEW is 'catalog' or g.BOARD is 'f' return if !Conf['Fappe Tyme'] or g.VIEW is 'catalog' or g.BOARD is 'f'
FappeTyme.cb.toggle.call {name: 'fappe'} FappeTyme.toggle 'fappe'
when Conf['werkTyme'] when Conf['werkTyme']
return if !Conf['Werk Tyme'] or g.VIEW is 'catalog' or g.BOARD is 'f' return if !Conf['Werk Tyme'] or g.VIEW is 'catalog' or g.BOARD is 'f'
FappeTyme.cb.toggle.call {name: 'werk'} FappeTyme.toggle 'werk'
# Board Navigation # Board Navigation
when Conf['Front page'] when Conf['Front page']
if Conf['JSON Navigation'] and !Conf['Use 4chan X Catalog'] and g.VIEW is 'index' if Conf['JSON Navigation'] and !Conf['Use 4chan X Catalog'] and g.VIEW is 'index'