coffeescript-ui
Version:
Coffeescript User Interface System
187 lines (147 loc) • 3.4 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('./Tab.html'));
class CUI.Tab extends CUI.DOMElement
constructor: (opts) ->
super(opts)
if not CUI.util.isEmpty()
cls = "ez-tab-#{CUI.util.toClass(@_name)}"
else
cls = null
= new CUI.Template
name: "tab-body"
class: cls
if
= true
if CUI.util.isFunction()
if not
else if
= 0
initButton: (tabs) ->
CUI.util.assert(tabs instanceof CUI.Tabs, "Tab.initButton", "Parameter #1 need to be instance of Tabs.", tabs: tabs)
= new CUI.Button
role: "tab-header"
radio: "tabs--"+tabs.getUniqueId()
class: "cui-tab-header-button"
disabled:
qa: if then + "-button"
id:
size: "normal"
group: "tabs"
text:
attr:
tab:
active: false
onActivate: (btn, flags, event) =>
++
if and not
if == 1
?(@)
?(@, flags, event)
CUI.Events.trigger
type: "tab_activate"
node:
onDeactivate: (btn, flags, event) =>
?(@, flags, event)
CUI.Events.trigger
type: "tab_deactivate"
node:
@
initOpts: ->
super()
padded:
check: Boolean
name:
check: String
button_id:
check: String
text:
mandatory: true
check: String
disabled:
mandatory: true
default: false
check: Boolean
content:
mandatory: true
check: (v) ->
CUI.util.isContent(v) or CUI.util.isString(v)
onFirstActivate:
check: Function
onActivate:
check: Function
onDeactivate:
check: Function
content_placeholder:
check: (v) ->
CUI.util.isContent(v)
load_on_show:
check: Boolean
loadContent: ->
CUI.Panel::loadContent.call(@)
setContent: (content) ->
CUI.Panel::setContent.call(@, content, false)
appendContent: (content) ->
CUI.Panel::appendContent.call(@, content, false)
getText: ->
hide: ->
# console.error "hiding tab...", ,
CUI.dom.addClass(, "cui-tab-hidden")
@
show: ->
# console.error "showing tab...", ,
# move to first position
CUI.dom.removeClass(, "cui-tab-hidden")
CUI.Events.trigger
type: "viewport-resize"
node:
info:
tab: true
CUI.Events.trigger
type: "content-resize"
node:
@
destroy: ->
CUI.Events.trigger
type: "tab_destroy"
node:
.destroy()
super()
disable: ->
.disable()
@
enable: ->
.enable()
@
activate: ->
.activate()
@
deactivate: ->
.deactivate()
@
isActive: ->
.isActive()
getButton: ->
getBody: ->
CUI.ready =>
CUI.Events.registerEvent
type: "tab_destroy"
CUI.Events.registerEvent
type: "tab_deactivate"
CUI.Events.registerEvent
type: "tab_activate"