瀏覽代碼

Download/Delete -> Install/Uninstall

Thibaut 11 年之前
父節點
當前提交
e9fc1d3c68

+ 4 - 4
assets/javascripts/collections/docs.coffee

@@ -35,18 +35,18 @@ class app.collections.Docs extends app.Collection
     doc.clearCache() for doc in @models
     return
 
-  undownload: (callback) ->
+  uninstall: (callback) ->
     i = 0
     next = =>
       if i < @models.length
-        @models[i++].undownload(next, next)
+        @models[i++].uninstall(next, next)
       else
         callback()
     next()
 
-  getDownloadStatuses: (callback) ->
+  getInstallStatuses: (callback) ->
     app.db.versions @models, (statuses) ->
       if statuses
         for key, value of statuses
-          statuses[key] = downloaded: !!value, mtime: value
+          statuses[key] = installed: !!value, mtime: value
       callback(statuses)

+ 12 - 12
assets/javascripts/models/doc.coffee

@@ -89,17 +89,17 @@ class app.models.Doc extends app.Model
     app.store.set @slug, [@mtime, data]
     return
 
-  download: (onSuccess, onError) ->
-    return if @downloading
-    @downloading = true
+  install: (onSuccess, onError) ->
+    return if @installing
+    @installing = true
 
     error = =>
-      @downloading = null
+      @installing = null
       onError()
       return
 
     success = (data) =>
-      @downloading = null
+      @installing = null
       app.db.store @, data, onSuccess, error
       return
 
@@ -109,24 +109,24 @@ class app.models.Doc extends app.Model
       error: error
     return
 
-  undownload: (onSuccess, onError) ->
-    return if @downloading
-    @downloading = true
+  uninstall: (onSuccess, onError) ->
+    return if @installing
+    @installing = true
 
     success = =>
-      @downloading = null
+      @installing = null
       onSuccess()
       return
 
     error = =>
-      @downloading = null
+      @installing = null
       onError()
       return
 
     app.db.unstore @, success, error
     return
 
-  getDownloadStatus: (callback) ->
+  getInstallStatus: (callback) ->
     app.db.version @, (value) ->
-      callback downloaded: !!value, mtime: value
+      callback installed: !!value, mtime: value
     return

+ 7 - 7
assets/javascripts/templates/pages/offline_tmpl.coffee

@@ -30,14 +30,14 @@ app.templates.offlinePage = (docs) -> """
 
 canICloseTheTab = ->
   if app.AppCache.isEnabled()
-    """ Yes! Even offline, you can open a new tab, go to <a href="http://devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you downloaded all the documentations you want to use beforehand).<br>
+    """ Yes! Even offline, you can open a new tab, go to <a href="http://devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand).<br>
         Note that loading any page other than <a href="http://devdocs.io">devdocs.io</a> directly won't work (due to limitations in AppCache). """
   else
     """ No. Because AppCache is unavailable in your browser (or has been disabled), loading <a href="http://devdocs.io">devdocs.io</a> offline won't work.<br>
-        The current tab will continue to work, though (provided you downloaded all the documentations you want to use beforehand). """
+        The current tab will continue to work, though (provided you installed all the documentations you want to use beforehand). """
 
 app.templates.offlineDoc = (doc, status) ->
-  outdated = status.downloaded and status.mtime isnt doc.mtime
+  outdated = status.installed and status.mtime isnt doc.mtime
 
   html = """
     <tr data-slug="#{doc.slug}"#{if outdated then ' class="_highlight"' else ''}>
@@ -45,20 +45,20 @@ app.templates.offlineDoc = (doc, status) ->
       <td class="_docs-size">#{Math.ceil(doc.db_size / 100000) / 10} MB</td>
   """
 
-  html += if !status.downloaded
+  html += if !status.installed
     """
       <td>-</td>
-      <td><a data-dl>Download</a></td>
+      <td><a data-dl>Install</a></td>
     """
   else if outdated
     """
       <td>Outdated</td>
-      <td><a data-dl>Update</a> - <a data-del>Delete</a></td>
+      <td><a data-dl>Update</a> - <a data-del>Uninstall</a></td>
     """
   else
     """
       <td>Up-to-date</td>
-      <td><a data-del>Delete</a></td>
+      <td><a data-del>Uninstall</a></td>
     """
 
   html + '</tr>'

+ 7 - 7
assets/javascripts/views/content/offline_page.coffee

@@ -10,7 +10,7 @@ class app.views.OfflinePage extends app.View
     return
 
   render: ->
-    app.docs.getDownloadStatuses (statuses) =>
+    app.docs.getInstallStatuses (statuses) =>
       return unless @activated
       if statuses is false
         @html @tmpl('offlineError')
@@ -42,24 +42,24 @@ class app.views.OfflinePage extends app.View
     link = event.target
 
     if link.hasAttribute('data-dl')
-      action = 'download'
+      action = 'install'
     else if link.hasAttribute('data-del')
-      action = 'undownload'
+      action = 'uninstall'
 
     if action
       $.stopEvent(event)
       doc = @docByEl(link)
-      doc[action](@onDownloadSuccess.bind(@, doc), @onDownloadError.bind(@, doc))
+      doc[action](@onInstallSuccess.bind(@, doc), @onInstallError.bind(@, doc))
       link.parentNode.innerHTML = "#{link.textContent.replace(/e$/, '')}ing…"
     return
 
-  onDownloadSuccess: (doc) ->
-    doc.getDownloadStatus (status) =>
+  onInstallSuccess: (doc) ->
+    doc.getInstallStatus (status) =>
       @docEl(doc).outerHTML = @renderDoc(doc, status)
       $.highlight @docEl(doc), className: '_highlight'
     return
 
-  onDownloadError: (doc) ->
+  onInstallError: (doc) ->
     el = @docEl(doc)
     el.lastElementChild.textContent = 'Error'
     return

+ 1 - 1
assets/javascripts/views/sidebar/doc_picker.coffee

@@ -50,7 +50,7 @@ class app.views.DocPicker extends app.View
       app.settings.setDocs(docs)
       @saveLink.textContent = if app.appCache then 'Downloading\u2026' else 'Saving\u2026'
       disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1)
-      disabledDocs.undownload -> app.reload()
+      disabledDocs.uninstall -> app.reload()
     return
 
   getSelectedDocs: ->