Move download function in ImageCommon
Conflicts: builds/appchan-x.user.js builds/crx/script.js src/Images/ImageCommon.coffee
This commit is contained in:
parent
c84a8abd55
commit
29fd66898e
@ -61,7 +61,7 @@ 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 nodes.name, 'click', ImageCommon.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
|
||||||
|
|||||||
@ -83,3 +83,13 @@ ImageCommon =
|
|||||||
# XXX Estimate whether clicks are on the video controls and should be ignored.
|
# XXX Estimate whether clicks are on the video controls and should be ignored.
|
||||||
onControls: (e) ->
|
onControls: (e) ->
|
||||||
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35
|
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
@ -7,7 +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', @download
|
$.on a, 'click', ImageCommon.download
|
||||||
|
|
||||||
Menu.menu.addEntry
|
Menu.menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
@ -16,14 +16,4 @@ DownloadLink =
|
|||||||
return false unless file
|
return false unless file
|
||||||
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