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) {
if (!self.options.collapsed) {
if (self.options.resizable && !self.options.collapsed) {
self.startPos = e[self.clientXY];
self.startSize = self.options.size;
Ox.print('startSize', self.startSize)
@ -1494,9 +1494,11 @@ requires
}
function toggle() {
var i = (self.options.edge == 'left' || self.options.edge == 'top') ? 0 : 1;
self.options.parent.toggle(self.ids[i]);
self.options.collapsed = !self.options.collapsed;
if (self.options.collapsible) {
var i = (self.options.edge == 'left' || self.options.edge == 'top') ? 0 : 1;
self.options.parent.toggle(self.ids[i]);
self.options.collapsed = !self.options.collapsed;
}
/*
Ox.print('toggle');
if (Ox.isUndefined(self.options.position)) {
@ -8894,19 +8896,19 @@ requires
Ox.print('v.size', v.size)
self.resizebarElements[index] = i < 2 ? [0, 1] : [1, 2];
self.$resizebars[index] = new Ox.Resizebar({
collapsible: v.collapsible,
edge: self.edges[index],
elements: [
that.$elements[self.resizebarElements[index][0]],
that.$elements[self.resizebarElements[index][1]]
],
id: v.element.options('id'),
orientation: self.options.orientation == 'horizontal' ? 'vertical' : 'horizontal',
parent: that, // fixme: that.$content
resizable: v.resizable,
resize: v.resize,
size: v.size
});
collapsible: v.collapsible,
edge: self.edges[index],
elements: [
that.$elements[self.resizebarElements[index][0]],
that.$elements[self.resizebarElements[index][1]]
],
id: v.element.options('id'),
orientation: self.options.orientation == 'horizontal' ? 'vertical' : 'horizontal',
parent: that, // fixme: that.$content
resizable: v.resizable,
resize: v.resize,
size: v.size
});
self.$resizebars[index][i == 0 ? 'insertAfter' : 'insertBefore'](that.$elements[i]);
}
});
@ -8970,6 +8972,7 @@ requires
that.replace = function(id, element) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id);
Ox.print('replace', pos, 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 = element;
@ -8988,15 +8991,33 @@ requires
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) {
// 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);
if (arguments.length == 1) {
Ox.print('size', self.options.elements[pos].element[self.dimensions[0]](), !that.isCollapsed(pos))
return self.options.elements[pos].element[self.dimensions[0]]() * !that.isCollapsed(pos);
Ox.print('size', element.element[self.dimensions[0]](), !that.isCollapsed(pos))
return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
} else {
self.options.elements[pos].size = size;
element.size = size;
setSizes();
return that;
}