kdf
Version:
116 lines (68 loc) • 2.45 kB
text/coffeescript
KDView = require './../../core/view.coffee'
module.exports = class KDTabPaneView extends KDView
constructor:(options = {},data)->
options.hiddenHandle ?= no # a Boolean
options.name or= "" # a String
options.detachable ?= yes
defaultCssClass = "kdtabpaneview kdhiddentab #{KD.utils.slugify options.name.toLowerCase()} clearfix"
options.cssClass = KD.utils.curry defaultCssClass, options.cssClass
super options, data
= options.name
=
parent : 0
self : 0
'KDTabPaneActive', 'setMainView'
'KDTabPaneLazyViewAdded', 'fireLazyCallback'
show:->
if 'detachable'
?.getElement().appendChild
'kdhiddentab'
'active'
= yes
'KDTabPaneActive'
hide:->
return unless
'KDTabPaneInactive'
'active'
'kdhiddentab'
if 'detachable'
?.getElement().removeChild
= no
setScrollTops: ->
.parent = ?.getElement().scrollTop or 0
.self = .scrollTop
applyScrollTops: ->
KD.utils.defer =>
.scrollTop = .self
?.getElement().scrollTop = .parent
setTitle:(title)->
.setPaneTitle this, title
= title
getHandle: -> .getHandleByPane this
hideTabCloseIcon:-> .hideCloseIcon this
setMainView:(view)->
unless view
{view, viewOptions} =
return if
return unless view or viewOptions
if view instanceof KDView
= view
else if viewOptions
{viewClass, options, data} = viewOptions
= new viewClass options, data
else
return warn "probably you set a weird lazy view!"
"KDTabPaneLazyViewAdded", this,
return
getMainView:->
destroyMainView:->
.destroy()
= null
fireLazyCallback:(pane, view)->
{viewOptions} =
return unless viewOptions
{callback} = viewOptions
return unless callback
callback.call this, pane, view