| @@ -18,6 +18,7 @@ class app.views.OfflinePage extends app.View · 17 unmodified lines |
| 18 | html = '' | 18 | html = '' |
| 19 | html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all() | 19 | html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all() |
| 20 | @html @tmpl('offlinePage', html) | 20 | @html @tmpl('offlinePage', html) |
| | 21 | @refreshLinks() |
| 21 | return | 22 | return |
| 22 | return | 23 | return |
| 23 | | 24 | |
| @@ -27,6 +28,11 @@ class app.views.OfflinePage extends app.View · 3 unmodified lines |
| 27 | getTitle: -> | 28 | getTitle: -> |
| 28 | 'Offline' | 29 | 'Offline' |
| 29 | | 30 | |
| | 31 | refreshLinks: -> |
| | 32 | for action in ['install', 'update', 'uninstall'] |
| | 33 | @find("a[data-action-all='#{action}']").classList[if @find("a[data-action='#{action}']") then 'add' else 'remove']('_show') |
| | 34 | return |
| | 35 | |
| 30 | docByEl: (el) -> | 36 | docByEl: (el) -> |
| 31 | el = el.parentNode until slug = el.getAttribute('data-slug') | 37 | el = el.parentNode until slug = el.getAttribute('data-slug') |
| 32 | app.docs.findBy('slug', slug) | 38 | app.docs.findBy('slug', slug) |
| @@ -43,14 +49,19 @@ class app.views.OfflinePage extends app.View · 10 unmodified lines |
| 43 | if action = target.getAttribute('data-action') | 49 | if action = target.getAttribute('data-action') |
| 44 | $.stopEvent(event) | 50 | $.stopEvent(event) |
| 45 | doc = @docByEl(target) | 51 | doc = @docByEl(target) |
| | 52 | action = 'install' if action is 'update' |
| 46 | doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc)) | 53 | doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc)) |
| 47 | target.parentNode.innerHTML = "#{target.textContent.replace(/e$/, '')}ing…" | 54 | target.parentNode.innerHTML = "#{target.textContent.replace(/e$/, '')}ing…" |
| | 55 | else if action = target.getAttribute('data-action-all') |
| | 56 | $.stopEvent(event) |
| | 57 | link.click() for link in @findAll("a[data-action='#{action}']") |
| 48 | return | 58 | return |
| 49 | | 59 | |
| 50 | onInstallSuccess: (doc) -> | 60 | onInstallSuccess: (doc) -> |
| 51 | doc.getInstallStatus (status) => | 61 | doc.getInstallStatus (status) => |
| 52 | @docEl(doc).outerHTML = @renderDoc(doc, status) | 62 | @docEl(doc).outerHTML = @renderDoc(doc, status) |
| 53 | $.highlight @docEl(doc), className: '_highlight' | 63 | $.highlight @docEl(doc), className: '_highlight' |
| | 64 | @refreshLinks() |
| 54 | return | 65 | return |
| 55 | | 66 | |
| 56 | onInstallError: (doc) -> | 67 | onInstallError: (doc) -> |