| @@ -18,6 +18,7 @@ class app.views.OfflinePage extends app.View · 17 unmodified lines |
| 18 | 18 | html = '' |
| 19 | 19 | html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all() |
| 20 | 20 | @html @tmpl('offlinePage', html) |
| 21 | + @refreshLinks() |
| 21 | 22 | return |
| 22 | 23 | return |
| 23 | 24 | |
| @@ -27,6 +28,11 @@ class app.views.OfflinePage extends app.View · 3 unmodified lines |
| 27 | 28 | getTitle: -> |
| 28 | 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 | 36 | docByEl: (el) -> |
| 31 | 37 | el = el.parentNode until slug = el.getAttribute('data-slug') |
| 32 | 38 | app.docs.findBy('slug', slug) |
| @@ -43,14 +49,19 @@ class app.views.OfflinePage extends app.View · 10 unmodified lines |
| 43 | 49 | if action = target.getAttribute('data-action') |
| 44 | 50 | $.stopEvent(event) |
| 45 | 51 | doc = @docByEl(target) |
| 52 | + action = 'install' if action is 'update' |
| 46 | 53 | doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc)) |
| 47 | 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 | 58 | return |
| 49 | 59 | |
| 50 | 60 | onInstallSuccess: (doc) -> |
| 51 | 61 | doc.getInstallStatus (status) => |
| 52 | 62 | @docEl(doc).outerHTML = @renderDoc(doc, status) |
| 53 | 63 | $.highlight @docEl(doc), className: '_highlight' |
| 64 | + @refreshLinks() |
| 54 | 65 | return |
| 55 | 66 | |
| 56 | 67 | onInstallError: (doc) -> |