diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 2cc714c6f..6b9adab75 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -61,7 +61,7 @@ Gallery = {cb} = Gallery $.on nodes.frame, 'click', cb.blank $.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-next', dialog), 'click', cb.next diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 3ee657eea..1d7d3a671 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -83,3 +83,13 @@ ImageCommon = # XXX Estimate whether clicks are on the video controls and should be ignored. onControls: (e) -> 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 diff --git a/src/Menu/DownloadLink.coffee b/src/Menu/DownloadLink.coffee index 61ff0f5fd..2bc929c2a 100755 --- a/src/Menu/DownloadLink.coffee +++ b/src/Menu/DownloadLink.coffee @@ -7,7 +7,7 @@ DownloadLink = textContent: 'Download file' # 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 el: a @@ -16,14 +16,4 @@ DownloadLink = return false unless file a.href = file.URL a.download = file.name - 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 \ No newline at end of file + true \ No newline at end of file