Change how download button works to allow for right-clicking to work
authorSteven Chan <steven3416@gmail.com>
Wed, 10 Sep 2014 20:46:56 +0000 (13:46 -0700)
committerSteven Chan <steven3416@gmail.com>
Wed, 10 Sep 2014 20:46:56 +0000 (13:46 -0700)
On user clicking a download button, we convert the download URL to a content URL,
and then convert the button to a link with a new message. This will
allow the link to be used directly, ie, right-clicking to open in a new
tab.

The interaction is not perfect, for example, the content link will be
useful for only 60 seconds. A more elaborate interaction will need to be
devised.

Signed-off-by: Steven Chan <steven3416@gmail.com>
src/od_action.coffee

index 31b5ffc..3c399be 100644 (file)
@@ -449,6 +449,8 @@ define [
                        #
                _download_format: ->
                        @on 'click', 'td.formats a', (ev) ->
+                               $a = $(@)
+                               return unless $a.hasClass 'opac-button'
                                ev.preventDefault()
 
                                # We will return to the current page to handle errors
@@ -460,11 +462,11 @@ define [
                                od.api dl
                                .then(
                                        (x) ->
-                                               window.open(
-                                                       x.links.contentlink.href # url
-                                                       '_blank' #'Overdrive Read format' # title
-                                                       'resizable, scrollbars, status, menubar, toolbar, personalbar' # features
-                                               )
+                                               $a
+                                               .prop 'href', x.links.contentlink.href
+                                               .text 'Content is ready. Right-click to download in a new tab or window'
+                                               .removeClass 'opac-button'
+                                               return
                                        -> console.log 'failed to get download link'
                                )
                                .then(