kdf
Version:
80 lines (54 loc) • 1.86 kB
text/coffeescript
KDScrollView = require './../scrollview/scrollview.coffee'
module.exports = class KDSplitViewPanel extends KDScrollView
constructor:(options = {}, data)->
options.fixed ?= no
options.view or= null
super options, data
{type} =
= type.toLowerCase() is "vertical"
{ , , } =
splitPanel: (options = {}) ->
if .first instanceof KDSplitView
return warn "this panel is already splitted"
view = .first
index = .panels.indexOf this
= []
if view
view.detach()
view.unsetParent()
options.views = [view]
options.colored = yes
# options.type = ['vertical','horizontal'][KD.utils.getRandomNumber(2)-1]
{splitClass} = .getOptions()
split = new (splitClass or KDSplitView) options
.setView split, index
return split
_getSize:-> if then else
_setSize:(size)->
if size
size = 0 if size < 0
if then size else size
.sizes[ ] = = size
.emit "PanelDidResize", panel : this
"PanelDidResize", newSize : size
size
else
no
_wouldResize:(size)->
minimum = .minimums[ ] ? 0
maximum = .maximums[ ] ? 999999
if maximum >= size >= minimum
then yes
else
if size < minimum
._panelReachedMinimum
else if size > maximum
._panelReachedMaximum
no
_setOffset:(offset)->
offset = Math.max offset, 0
if then offset else offset
_getOffset:->
if
then parseInt .style.left, 10
else parseInt .style.top, 10