allow for replacement of all elements of a splitpanel

This commit is contained in:
rolux 2010-12-23 02:34:31 +00:00
parent b3567cb503
commit df2e87b50e

View file

@ -1480,7 +1480,7 @@ requires
} }
function dragStart(e) { function dragStart(e) {
if (!self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
self.startPos = e[self.clientXY]; self.startPos = e[self.clientXY];
self.startSize = self.options.size; self.startSize = self.options.size;
Ox.print('startSize', self.startSize) Ox.print('startSize', self.startSize)
@ -1494,9 +1494,11 @@ requires
} }
function toggle() { function toggle() {
if (self.options.collapsible) {
var i = (self.options.edge == 'left' || self.options.edge == 'top') ? 0 : 1; var i = (self.options.edge == 'left' || self.options.edge == 'top') ? 0 : 1;
self.options.parent.toggle(self.ids[i]); self.options.parent.toggle(self.ids[i]);
self.options.collapsed = !self.options.collapsed; self.options.collapsed = !self.options.collapsed;
}
/* /*
Ox.print('toggle'); Ox.print('toggle');
if (Ox.isUndefined(self.options.position)) { if (Ox.isUndefined(self.options.position)) {
@ -8970,6 +8972,7 @@ requires
that.replace = function(id, element) { that.replace = function(id, element) {
// one can pass pos instead of id // one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id); var pos = Ox.isNumber(id) ? id : getPositionById(id);
Ox.print('replace', pos, element);
Ox.print('element', self.options.elements[pos].element, element) Ox.print('element', self.options.elements[pos].element, element)
self.options.elements[pos].element.replaceWith(element.$element.$element || element.$element); self.options.elements[pos].element.replaceWith(element.$element.$element || element.$element);
self.options.elements[pos].element = element; self.options.elements[pos].element = element;
@ -8988,15 +8991,33 @@ requires
Ox.print(self.options.elements[pos]) Ox.print(self.options.elements[pos])
}; };
that.replaceElements = function(elements) {
elements.forEach(function(element, i) {
if (Ox.isNumber(element.size)) {
that.size(i, element.size);
if (element.collapsible || element.resizable) {
self.$resizebars[i == 0 ? 0 : 1].options({
collapsible: element.collapsible,
resizable: element.resizable,
size: element.size
});
}
}
that.replace(i, element.element);
});
self.options.elements = elements;
}
that.size = function(id, size) { that.size = function(id, size) {
// one can pass pos instead of id // one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id); var pos = Ox.isNumber(id) ? id : getPositionById(id),
element = self.options.elements[pos];
Ox.print('pos', pos, 'size', size); Ox.print('pos', pos, 'size', size);
if (arguments.length == 1) { if (arguments.length == 1) {
Ox.print('size', self.options.elements[pos].element[self.dimensions[0]](), !that.isCollapsed(pos)) Ox.print('size', element.element[self.dimensions[0]](), !that.isCollapsed(pos))
return self.options.elements[pos].element[self.dimensions[0]]() * !that.isCollapsed(pos); return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
} else { } else {
self.options.elements[pos].size = size; element.size = size;
setSizes(); setSizes();
return that; return that;
} }