coffeescript-ui
Version:
Coffeescript User Interface System
103 lines (86 loc) • 2.27 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('./MultiOutput.html'));
class CUI.MultiOutput extends CUI.DataField
initOpts: ->
super()
control:
mandatory: true
check: CUI.MultiInputControl
showOnlyPreferredKey:
check: Boolean
default: true
markdown:
mandatory: true
default: false
check: Boolean
markdown_opts:
check: "PlainObject"
text_node_func:
check: Function
readOpts: ->
super()
= {}
render: ->
super()
if
key = .getPreferredKey()
CUI.util.assert(key, "Output.displayValue", "MultiInputControl: no preferred key set.", control: )
label =
else
for key, idx in .getKeys()
value = [key.name]
if CUI.util.isEmpty(value)
continue
template =
[key.name] = template
= CUI.Events.listen
type: "multi-input-control-update"
node:
call: =>
return @
__getLabel: (name) ->
return new CUI.Label
multiline: true
text: [name]
text_node_func:
markdown:
markdown_opts:
__buildTemplateForKey: (key) ->
label =
template = new CUI.Template
name: "data-field-multi-output"
map:
center: true
aside: true
template.append(label, "center")
button = new CUI.defaults.class.Button
text: key.tag
tabindex: null
disabled: !.hasUserControl()
role: "multi-output-tag"
tooltip: key.tooltip
appearance: "flat"
onClick: (ev) =>
.showUserControl(ev, button)
template.append(button, "aside")
return template
__hideShowElements: ->
for key, template of
if .isEnabled(key)
template.show()
else
template.hide()
destroy: ->
.destroy()
delete
super()