History

Fully implement offline docs table

Thibaut committed 11 years ago

Commit f2111241 parent eb58c015 files · +54 −45Browse files

Showing the changes to assets/javascripts/views (1 of 5 files). Show all

Unified · Split

assets/javascripts/views/content/offline_page.coffee+8−6
@@ -39,25 +39,27 @@ class app.views.OfflinePage extends app.View · 38 unmodified lines
3939 return
4040
4141 onClick: (event) =>
42− if event.target.hasAttribute('data-dl')
42+ link = event.target
43+
44+ if link.hasAttribute('data-dl')
4345 action = 'download'
44− else if event.target.hasAttribute('data-del')
46+ else if link.hasAttribute('data-del')
4547 action = 'undownload'
4648
4749 if action
4850 $.stopEvent(event)
49− doc = @docByEl(event.target)
51+ doc = @docByEl(link)
5052 doc[action](@onDownloadSuccess.bind(@, doc), @onDownloadError.bind(@, doc))
51− @docEl(doc).classList.add("#{action}ing")
53+ link.parentNode.innerHTML = "#{link.textContent.replace(/e$/, '')}ing…"
5254 return
5355
5456 onDownloadSuccess: (doc) ->
5557 doc.getDownloadStatus (status) =>
5658 @docEl(doc).outerHTML = @renderDoc(doc, status)
59+ $.highlight @docEl(doc), className: '_highlight'
5760 return
5861
5962 onDownloadError: (doc) ->
6063 el = @docEl(doc)
61− el.className = ''
62− el.classList.add('error')
64+ el.lastElementChild.textContent = 'Error'
6365 return