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 @@
11 app.templates.offlinePage = (docs) -> """
22 <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+
310 <table class="_docs">
411 <tr>
512 <th>Documentation</th>
@@ -53,7 +60,7 @@ app.templates.offlineDoc = (doc, status) -> · 47 unmodified lines
5360 else if outdated
5461 """
5562 <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>
5764 """
5865 else
5966 """
assets/javascripts/views/content/offline_page.coffee+11−0
@@ -18,6 +18,7 @@ class app.views.OfflinePage extends app.View · 17 unmodified lines
1818 html = ''
1919 html += @renderDoc(doc, statuses[doc.slug]) for doc in app.docs.all()
2020 @html @tmpl('offlinePage', html)
21+ @refreshLinks()
2122 return
2223 return
2324
@@ -27,6 +28,11 @@ class app.views.OfflinePage extends app.View · 3 unmodified lines
2728 getTitle: ->
2829 'Offline'
2930
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+
3036 docByEl: (el) ->
3137 el = el.parentNode until slug = el.getAttribute('data-slug')
3238 app.docs.findBy('slug', slug)
@@ -43,14 +49,19 @@ class app.views.OfflinePage extends app.View · 10 unmodified lines
4349 if action = target.getAttribute('data-action')
4450 $.stopEvent(event)
4551 doc = @docByEl(target)
52+ action = 'install' if action is 'update'
4653 doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc))
4754 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}']")
4858 return
4959
5060 onInstallSuccess: (doc) ->
5161 doc.getInstallStatus (status) =>
5262 @docEl(doc).outerHTML = @renderDoc(doc, status)
5363 $.highlight @docEl(doc), className: '_highlight'
64+ @refreshLinks()
5465 return
5566
5667 onInstallError: (doc) ->
assets/stylesheets/components/_content.scss+18−0
@@ -269,6 +269,24 @@ · 268 unmodified lines
269269
270270 ._docs-size { text-align: right; }
271271
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+
272290 //
273291 // News
274292 //

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