coffeescript-ui
Version:
Coffeescript User Interface System
122 lines (100 loc) • 2.69 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('./Block.html'));
class CUI.Block extends CUI.DOMElement
constructor: (opts) ->
super(opts)
= new CUI.Template
name:
map:
header: true
content: true
if
else
arr = []
if or
= new CUI.Label
class: "cui-block-title"
text:
icon:
multiline: true
arr.push()
if
arr.push new CUI.Label
class: "cui-block-description"
text:
multiline: true
if arr.length > 0
if
if
initOpts: ->
super()
text:
check: String
description:
check: String
header:
check: (v) ->
!!(CUI.util.isContent(v) or CUI.util.isString(v) or v?.DOM)
icon:
check: CUI.Icon
content:
check: (v) ->
!!(CUI.util.isContent(v) or CUI.util.isString(v) or v?.DOM)
level:
mandatory: true
default: 1
check: [1, 2, 3]
appearance:
default: "normal"
mandatory: true
check: ["normal","wide"]
padded:
check: Boolean
default: true
maximize:
check: Boolean
maximize_horizontal:
check: Boolean
default: false
maximize_vertical:
check: Boolean
default: false
readOpts: ->
super()
CUI.util.assert(not (( or ) and ), "new CUI.Block", "opts.text and opts.header are mutually exclusive.", opts: )
CUI.Layout::maximizeReadOpts.call(@)
@
maximizeAddClasses: ->
CUI.Layout::maximizeAddClasses.call(@)
getTemplateName: ->
"block"
setText: (txt) ->
CUI.util.assert(, "Block.setText", "Block must not be called with opts.header and with opts.text or opts.icon.", opts: )
.setText(txt)
setIcon: (icon) ->
CUI.util.assert(, "Block.setText", "Block must not be called with opts.header and with opts.text or opts.icon.", opts: )
.setIcon(icon)
setHeader: (header) ->
.replace(header, "header")
setContent: (content) ->
.replace(content, "content")
getContent: ->
.map.content
getHeader: ->
.map.header
appendContent: (content) ->
.append(content, "content")