Add download functionality to Gallery, as originally intended.
Conflicts: builds/appchan-x.user.js builds/crx/script.js
This commit is contained in:
parent
bed88c3324
commit
c84a8abd55
@ -59,8 +59,10 @@ Gallery =
|
|||||||
nodes.menu = new UI.Menu 'gallery'
|
nodes.menu = new UI.Menu 'gallery'
|
||||||
|
|
||||||
{cb} = Gallery
|
{cb} = Gallery
|
||||||
$.on nodes.frame, 'click', cb.blank
|
$.on nodes.frame, 'click', cb.blank
|
||||||
$.on nodes.next, 'click', cb.click
|
$.on nodes.next, 'click', cb.click
|
||||||
|
$.on nodes.name, 'click', DownloadLink.download
|
||||||
|
|
||||||
$.on $('.gal-prev', dialog), 'click', cb.prev
|
$.on $('.gal-prev', dialog), 'click', cb.prev
|
||||||
$.on $('.gal-next', dialog), 'click', cb.next
|
$.on $('.gal-next', dialog), 'click', cb.next
|
||||||
$.on $('.gal-start', dialog), 'click', cb.start
|
$.on $('.gal-start', dialog), 'click', cb.start
|
||||||
|
|||||||
@ -7,15 +7,7 @@ DownloadLink =
|
|||||||
textContent: 'Download file'
|
textContent: 'Download file'
|
||||||
|
|
||||||
# Specifying the filename with the download attribute only works for same-origin links.
|
# Specifying the filename with the download attribute only works for same-origin links.
|
||||||
$.on a, 'click', (e) ->
|
$.on a, 'click', @download
|
||||||
return true if @protocol is 'blob:'
|
|
||||||
e.preventDefault()
|
|
||||||
CrossOrigin.file @href, (blob) =>
|
|
||||||
if blob
|
|
||||||
@href = URL.createObjectURL blob
|
|
||||||
@click()
|
|
||||||
else
|
|
||||||
new Notice 'error', "Could not download #{@href}", 30
|
|
||||||
|
|
||||||
Menu.menu.addEntry
|
Menu.menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
@ -25,3 +17,13 @@ DownloadLink =
|
|||||||
a.href = file.URL
|
a.href = file.URL
|
||||||
a.download = file.name
|
a.download = file.name
|
||||||
true
|
true
|
||||||
|
|
||||||
|
download: (e) ->
|
||||||
|
return true if @protocol is 'blob:'
|
||||||
|
e.preventDefault()
|
||||||
|
CrossOrigin.file @href, (blob) =>
|
||||||
|
if blob
|
||||||
|
@href = URL.createObjectURL blob
|
||||||
|
@click()
|
||||||
|
else
|
||||||
|
new Notice 'error', "Could not download #{@href}", 30
|
||||||
Loading…
x
Reference in New Issue
Block a user