coffeescript-ui
Version:
Coffeescript User Interface System
69 lines (56 loc) • 1.66 kB
text/coffeescript
###
* coffeescript-ui - Coffeescript User Interface System (CUI)
* Copyright (c) 2013 - 2016 Programmfabrik GmbH
* MIT Licence
* https://github.com/programmfabrik/coffeescript-ui, http://www.coffeescript-ui.org
###
CUI.Template.loadTemplateText(require('./FileUploadButton.html'));
class CUI.FileUploadButton extends CUI.Button
constructor: (opts) ->
super(opts)
if
.initDropZone(dropZone: )
initOpts: ->
super()
fileUpload:
mandatory: true
check: CUI.FileUpload
multiple:
default: true
check: (v) =>
v == true or v == false or v instanceof Function
directory:
check: Boolean
# whether to allow file drop on the button
drop:
check: Boolean
accept:
check: String
getTemplateName: ->
= true
= true
return "file-upload-button-ng"
readOpts: ->
= .onClick
.onClick =
super()
return
run: (ev, btn) ->
__onClick: (ev, btn) =>
?.call(@, ev, btn)
if ev.isDefaultPrevented() or ev.isImmediatePropagationStopped()
return
if instanceof Function
multiple = .call(@, ev, btn) == true
else
multiple =
.initFilePicker
directory: ((ev.altKey() or ev.shiftKey()) and ) or
multiple: multiple
accept:
return
CUI.ready =>
CUI.dom.append(document.body, CUI.dom.htmlToNodes("""<!-- CUI.FileUploadButton --><form style="display:none;"><input type="file" id="cui-file-upload-button"></input></form><!-- /CUI.FileUploadButton -->"""))