Optimize Menu.makeButton().

This commit is contained in:
Mayhem 2013-12-20 04:14:53 +01:00
parent 6574e4aa95
commit be8371d4c6
3 changed files with 14 additions and 14 deletions

View File

@ -168,7 +168,7 @@ PostHiding =
className: 'stub' className: 'stub'
$.add post.nodes.stub, a $.add post.nodes.stub, a
if Conf['Menu'] if Conf['Menu']
$.add post.nodes.stub, [$.tn(' '), Menu.makeButton()] $.add post.nodes.stub, Menu.makeButton()
$.prepend post.nodes.root, post.nodes.stub $.prepend post.nodes.root, post.nodes.stub
show: (post, showRecursively=Conf['Recursive Hiding']) -> show: (post, showRecursively=Conf['Recursive Hiding']) ->

View File

@ -124,7 +124,7 @@ ThreadHiding =
thread.stub = $.el 'div', thread.stub = $.el 'div',
className: 'stub' className: 'stub'
if Conf['Menu'] if Conf['Menu']
$.add thread.stub, [a, $.tn(' '), Menu.makeButton()] $.add thread.stub, [a, Menu.makeButton()]
else else
$.add thread.stub, a $.add thread.stub, a
$.prepend root, thread.stub $.prepend root, thread.stub

View File

@ -9,22 +9,22 @@ Menu =
node: -> node: ->
if @isClone if @isClone
button = $ '.menu-button', @nodes.info $.on $('.menu-button', @nodes.info), 'click', Menu.toggle
$.on button, 'click', Menu.toggle
return return
button = Menu.makeButton() $.add @nodes.info, Menu.makeButton()
$.add @nodes.info, [$.tn('\u00A0'), button]
makeButton: do -> makeButton: do ->
a = null frag = null
-> ->
a or= $.el 'a', unless frag
className: 'menu-button' a = $.el 'a',
innerHTML: '[<i></i>]' className: 'menu-button'
href: 'javascript:;' innerHTML: '[<i></i>]'
button = a.cloneNode true href: 'javascript:;'
$.on button, 'click', Menu.toggle frag = $.nodes [$.tn(' '), a]
button clone = frag.cloneNode true
$.on clone.lastElementChild, 'click', Menu.toggle
clone
toggle: (e) -> toggle: (e) ->
try try