Showing the changes to assets/javascripts/views (1 of 5 files). Show all
Unified · Split
| @@ -39,25 +39,27 @@ class app.views.OfflinePage extends app.View · 38 unmodified lines | |||
| 39 | return | 39 | return |
| 40 | 40 | ||
| 41 | onClick: (event) => | 41 | onClick: (event) => |
| 42 | if event.target.hasAttribute('data-dl') | 42 | link = event.target |
| 43 | |||
| 44 | if link.hasAttribute('data-dl') | ||
| 43 | action = 'download' | 45 | action = 'download' |
| 44 | else if event.target.hasAttribute('data-del') | 46 | else if link.hasAttribute('data-del') |
| 45 | action = 'undownload' | 47 | action = 'undownload' |
| 46 | 48 | ||
| 47 | if action | 49 | if action |
| 48 | $.stopEvent(event) | 50 | $.stopEvent(event) |
| 49 | doc = @docByEl(event.target) | 51 | doc = @docByEl(link) |
| 50 | doc[action](@onDownloadSuccess.bind(@, doc), @onDownloadError.bind(@, doc)) | 52 | doc[action](@onDownloadSuccess.bind(@, doc), @onDownloadError.bind(@, doc)) |
| 51 | @docEl(doc).classList.add("#{action}ing") | 53 | link.parentNode.innerHTML = "#{link.textContent.replace(/e$/, '')}ing…" |
| 52 | return | 54 | return |
| 53 | 55 | ||
| 54 | onDownloadSuccess: (doc) -> | 56 | onDownloadSuccess: (doc) -> |
| 55 | doc.getDownloadStatus (status) => | 57 | doc.getDownloadStatus (status) => |
| 56 | @docEl(doc).outerHTML = @renderDoc(doc, status) | 58 | @docEl(doc).outerHTML = @renderDoc(doc, status) |
| 59 | $.highlight @docEl(doc), className: '_highlight' | ||
| 57 | return | 60 | return |
| 58 | 61 | ||
| 59 | onDownloadError: (doc) -> | 62 | onDownloadError: (doc) -> |
| 60 | el = @docEl(doc) | 63 | el = @docEl(doc) |
| 61 | el.className = '' | 64 | el.lastElementChild.textContent = 'Error' |
| 62 | el.classList.add('error') | ||
| 63 | return | 65 | return |