Put DeleteLink nodes in DeleteLink.nodes.

This commit is contained in:
ccd0 2015-08-08 00:32:47 -07:00
parent 9970fa6c29
commit 54ef3a74ef

View File

@ -13,7 +13,9 @@ DeleteLink =
fileEl = $.el 'a', fileEl = $.el 'a',
className: 'delete-file' className: 'delete-file'
href: 'javascript:;' href: 'javascript:;'
@links = [postEl, fileEl] @nodes =
menu: div.firstChild
links: [postEl, fileEl]
postEntry = postEntry =
el: postEl el: postEl
@ -35,9 +37,8 @@ DeleteLink =
open: (post) -> open: (post) ->
return false if post.isDead return false if post.isDead
DeleteLink.post = post DeleteLink.post = post
node = div.firstChild DeleteLink.nodes.menu.textContent = DeleteLink.menuText()
node.textContent = DeleteLink.menuText() DeleteLink.cooldown.start post
DeleteLink.cooldown.start post, node
true true
subEntries: [postEntry, fileEntry] subEntries: [postEntry, fileEntry]
@ -68,7 +69,7 @@ DeleteLink =
DeleteLink.delete post, fileOnly DeleteLink.delete post, fileOnly
delete: (post, fileOnly) -> delete: (post, fileOnly) ->
link = DeleteLink.links[+fileOnly] link = DeleteLink.nodes.links[+fileOnly]
delete DeleteLink.auto[+fileOnly][post.fullID] delete DeleteLink.auto[+fileOnly][post.fullID]
$.off link, 'click', DeleteLink.toggle if post.fullID is DeleteLink.post.fullID $.off link, 'click', DeleteLink.toggle if post.fullID is DeleteLink.post.fullID
@ -108,20 +109,20 @@ DeleteLink =
cooldown: cooldown:
seconds: {} seconds: {}
start: (post, node) -> start: (post) ->
# Already counting. # Already counting.
return if DeleteLink.cooldown.seconds[post.fullID]? return if DeleteLink.cooldown.seconds[post.fullID]?
seconds = QR.cooldown.secondsDeletion post seconds = QR.cooldown.secondsDeletion post
if seconds > 0 if seconds > 0
DeleteLink.cooldown.seconds[post.fullID] = seconds DeleteLink.cooldown.seconds[post.fullID] = seconds
DeleteLink.cooldown.count post, node DeleteLink.cooldown.count post
count: (post, node) -> count: (post) ->
node.textContent = DeleteLink.menuText() if post.fullID is DeleteLink.post.fullID DeleteLink.nodes.menu.textContent = DeleteLink.menuText() if post.fullID is DeleteLink.post.fullID
if DeleteLink.cooldown.seconds[post.fullID] > 0 if DeleteLink.cooldown.seconds[post.fullID] > 0
DeleteLink.cooldown.seconds[post.fullID]-- DeleteLink.cooldown.seconds[post.fullID]--
setTimeout DeleteLink.cooldown.count, 1000, post, node setTimeout DeleteLink.cooldown.count, 1000, post
else else
delete DeleteLink.cooldown.seconds[post.fullID] delete DeleteLink.cooldown.seconds[post.fullID]
for fileOnly in [false, true] when DeleteLink.auto[+fileOnly][post.fullID] for fileOnly in [false, true] when DeleteLink.auto[+fileOnly][post.fullID]