document Ox.SplitPanel properties

This commit is contained in:
j 2011-09-05 14:42:37 +02:00
parent c3b59a62fe
commit 318e2e95b2

View file

@ -155,11 +155,22 @@ Ox.SplitPanel = function(options, self) {
});
}
/*@
isCollapsed <f> panel collapsed state
(id) -> <b> id or position of panel, returns collapsed state
id <i> id or position of element
@*/
that.isCollapsed = function(id) {
var pos = Ox.isNumber(id) ? id : getPositionById(id);
return self.options.elements[pos].collapsed;
};
/*@
repleaseElement <f> replace panel element
(id, element) -> <f> replace element
id <i> id or position of element
element <o> new element
@*/
that.replaceElement = function(id, element) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id);
@ -180,6 +191,11 @@ Ox.SplitPanel = function(options, self) {
return that;
};
/*@
repleaseElements <f> replace panel elements
(elements) -> <f> replace elements
elements <a> array of new elements
@*/
that.replaceElements = function(elements) {
elements.forEach(function(element, i) {
if (Ox.isNumber(element.size)) {
@ -206,6 +222,13 @@ Ox.SplitPanel = function(options, self) {
return that;
};
/*@
size <f> get or set size
(id) -> <i> get size
(id, size) -> <f> set size
id <i> id or position of panel
size <i> size to set
@*/
that.size = function(id, size) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id),
@ -218,12 +241,23 @@ Ox.SplitPanel = function(options, self) {
return that;
}
};
/*@
getSize <f> get size of panel
(id) -> <i> id or position of panel, returns size
id <i> id or position of panel
@*/
that.getSize = function(id) {
var pos = Ox.isNumber(id) ? id : getPositionById(id),
element = self.options.elements[pos];
return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
};
/*@
toggle <f> toggle collapsed state of a panel
(id) -> <o> toggle panel
id <i> id or position of panel
@*/
that.toggle = function(id) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id),
@ -246,6 +280,12 @@ Ox.SplitPanel = function(options, self) {
});
};
/*@
updateSize <f> update size of element
(pos, size) -> <o> update size of element
pos <i> position of element
size <n> new size
@*/
that.updateSize = function(pos, size) {
// this is called from resizebar
pos = pos == 0 ? 0 : self.options.elements.length - 1; // fixme: silly that 0 or 1 is passed, and not pos