4chan-x/src/Menu/DownloadLink.coffee
ccd0 eaec80f5a5 Merge from Appchan X: src/Menu
excluded: Labels.coffee
2015-01-31 00:51:44 -08:00

20 lines
523 B
CoffeeScript
Executable File

DownloadLink =
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Menu'] and Conf['Download Link']
a = $.el 'a',
className: 'download-link'
textContent: 'Download file'
# Specifying the filename with the download attribute only works for same-origin links.
$.on a, 'click', ImageCommon.download
Menu.menu.addEntry
el: a
order: 100
open: ({file}) ->
return false unless file
a.href = file.URL
a.download = file.name
true