coffeescript-ui
Version:
Coffeescript User Interface System
138 lines (111 loc) • 3.31 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
###
# Pane with Header and Footer
class CUI.SimplePane extends CUI.Pane
# [Object] options for pane creation
# options [Array, Element, jQuery] header_left access the "left" of the PaneHeader
# options [Array, Element, jQuery] header_center access the "center" of the PaneHeader
# options [Array, Element, jQuery] header_right access the "right" of the PaneHeader
# options [Array, Element, jQuery] footer_left access the "left" of the PaneFooter
# options [Array, Element, jQuery] footer_right access the "right" of the PaneFooter
__init: ->
super()
for k in [
"header_left"
"header_center"
"header_right"
"footer_left"
"footer_right"
]
value = @["_#{k}"]
if not value
continue
if
if not CUI.__ng__
initOpts: ->
super()
title: {}
header_right: {}
header_center: {}
header_left: {}
footer_left: {}
footer_right: {}
content: {}
force_header:
mandatory: true
check: Boolean
default: false
force_footer:
mandatory: true
check: Boolean
default: false
@
readOpts: ->
# Skip readOpts from Pane as it sets defaults in top and bottom
# which is not allowed in our initOpts
CUI.VerticalLayout::readOpts.call(@)
if
CUI.util.assert(not , "new CUI.SimplePane", "opts.header_left conflicts with opts.title", opts: )
if or
not (CUI.util.isUndef() and CUI.util.isUndef() and CUI.util.isUndef()) or
= new CUI.PaneHeader()
=
content:
if or not (CUI.util.isUndef() and CUI.util.isUndef())
= new CUI.PaneFooter()
=
content:
=
content:
@
forceHeader: ->
forceFooter: ->
hasHeader: ->
!!
hasFooter: ->
!!
destroy: ->
?.destroy()
= null
?.destroy()
= null
super()
getPaneAndKey: (key) ->
# this reaches the panels directly
if key in ["center", "top", "bottom"]
[ , key ]
else if key == "content"
[ , "center" ]
else
m = key.match(/^(.*?)_(.*)$/)
CUI.util.assert(m?.length==3, "SimplePane.getPaneAndKey", "key #{key} not matched.", matched: m)
pn = "__pane_#{m?[1]}"
pane = @[pn]
CUI.util.assert(pane, "SimplePane.getPaneAndKey", "pane #{pn} not found.")
[ pane, m[2] ]
empty: (key="center") ->
[ pane, _key ] =
pane.empty(_key)
@
append: (content, key="center") ->
[ pane, _key ] =
pane.append(content, _key)
@
replace: (content, key="center") ->
[ pane, _key ] =
pane.replace(content, _key)
@