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>
#
_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
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(