History

Add links to install/update/uninstall all docs

Thibaut committed 11 years ago

Commit 95f81051 parent aee7ab13 files · +37 −1Browse files

Unified · Split

3 files
  1. assets/javascripts/templates/pages/offline_tmpl.coffee +8 −1
  2. assets/javascripts/views/content/offline_page.coffee +11 −0
  3. assets/stylesheets/components/_content.scss +18 −0
assets/javascripts/templates/pages/offline_tmpl.coffee+8−1
@@ -1,5 +1,12 @@
1app.templates.offlinePage = (docs) -> """1app.templates.offlinePage = (docs) -> """
2 <h1 class="_lined-heading">Offline Documentation</h1>2 <h1 class="_lined-heading">Offline Documentation</h1>
3
4 <div class="_docs-tools">
5 <div class="_docs-links">
6 <a class="_docs-link" data-action-all="install">Install all</a><a class="_docs-link" data-action-all="update">Update all</a><a class="_docs-link" data-action-all="uninstall">Uninstall all</a>
7 </div>
8 </div>
9
3 <table class="_docs">10 <table class="_docs">
4 <tr>11 <tr>
5 <th>Documentation</th>12 <th>Documentation</th>
@@ -53,7 +60,7 @@ app.templates.offlineDoc = (doc, status) -> · 47 unmodified lines
53 else if outdated60 else if outdated
54 """61 """
55 <td>Outdated</td>62 <td>Outdated</td>
56 <td><a data-action="install">Update</a> - <a data-action="uninstall">Uninstall</a></td>63 <td><a data-action="update">Update</a> - <a data-action="uninstall">Uninstall</a></td>
57 """64 """
58 else65 else
59 """66 """
assets/javascripts/views/content/offline_page.coffee+11−0
@@ -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 return22 return
22 return23 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 return58 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 return65 return
55 66
56 onInstallError: (doc) ->67 onInstallError: (doc) ->
assets/stylesheets/components/_content.scss+18−0
@@ -269,6 +269,24 @@ · 268 unmodified lines
269 269
270._docs-size { text-align: right; }270._docs-size { text-align: right; }
271 271
272._docs-tools { overflow: hidden; }
273
274._docs-links {
275 float: right;
276 padding: .375rem .125rem;
277 @extend %box;
278}
279
280._docs-link {
281 display: none;
282 vertical-align: top;
283 padding: 0 .75rem;
284 cursor: pointer;
285
286 &._show { display: inline-block; }
287 &._show ~ &._show { border-left: 1px solid $boxBorder; }
288}
289
272//290//
273// News291// News
274//292//

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t