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 | 39 | return |
| 40 | 40 | |
| 41 | 41 | onClick: (event) => |
| 42 | − if event.target.hasAttribute('data-dl') | |
| 42 | + link = event.target | |
| 43 | + | |
| 44 | + if link.hasAttribute('data-dl') | |
| 43 | 45 | action = 'download' |
| 44 | − else if event.target.hasAttribute('data-del') | |
| 46 | + else if link.hasAttribute('data-del') | |
| 45 | 47 | action = 'undownload' |
| 46 | 48 | |
| 47 | 49 | if action |
| 48 | 50 | $.stopEvent(event) |
| 49 | − doc = @docByEl(event.target) | |
| 51 | + doc = @docByEl(link) | |
| 50 | 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 | 54 | return |
| 53 | 55 | |
| 54 | 56 | onDownloadSuccess: (doc) -> |
| 55 | 57 | doc.getDownloadStatus (status) => |
| 56 | 58 | @docEl(doc).outerHTML = @renderDoc(doc, status) |
| 59 | + $.highlight @docEl(doc), className: '_highlight' | |
| 57 | 60 | return |
| 58 | 61 | |
| 59 | 62 | onDownloadError: (doc) -> |
| 60 | 63 | el = @docEl(doc) |
| 61 | − el.className = '' | |
| 62 | − el.classList.add('error') | |
| 64 | + el.lastElementChild.textContent = 'Error' | |
| 63 | 65 | return |