collapsibles

This commit is contained in:
rolux 2010-07-07 09:18:38 +02:00
parent b58cb9118b
commit 360a3abbf2

View File

@ -1220,6 +1220,7 @@ requires
var self = self || {},
that = new Ox.Element({}, self)
.defaults({
collapsed: false,
collapsible: true,
edge: "left",
elements: [],
@ -1290,6 +1291,13 @@ requires
function toggle() {
Ox.print("toggle");
var size = self.options.collapsed ? 0 : -self.options.size,
animate = {};
animate[self.options.edge] = size;
self.options.parent.animate(animate, 200, function() {
self.options.collapsed = !self.options.collapsed;
Ox.print("callback");
});
}
return that;
@ -4559,27 +4567,10 @@ requires
that.$elements[i] = v.element
.css(edges[2], 0)
.css(edges[3], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css(dimensions[0], v.size + "px");
if (i == 0) {
that.$elements[i].css(edges[0], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css(
edges[1], (getSize(self.options.elements[1]) + (length == 3 ? getSize(self.options.elements[2]) : 0)) + "px"
);
} else if (i == 1) {
!Ox.isUndefined(self.options.elements[0].size) && that.$elements[i].css(
edges[0], getSize(self.options.elements[0]) + "px"
);
(!Ox.isUndefined(self.options.elements[0].size) || !Ox.isUndefined(v.size)) && that.$elements[i].css(
edges[1], (length == 3 ? getSize(self.options.elements[2]) : 0) + "px"
);
} else {
that.$elements[i].css(edges[1], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css(
edges[0], (getSize(self.options.elements[0]) + getSize(self.options.elements[1])) + "px"
);
}
});
setSizes();
$.each(self.options.elements, function(i, v) {
//that.append(element)
that.$elements[i].appendTo(that);
@ -4606,9 +4597,52 @@ requires
}
});
function getSize(element) {
return element.size + !Ox.isUndefined(element.resizable);
function getPositionById(id) {
var position = -1;
$.each(self.options.elements, function(i, element) {
if (element.element.options("id") == id) {
position = 1;
return false;
}
});
return position;
}
function getSize(element) {
return element.size + element.resizable;
}
function setSizes() {
$.each(self.options.elements, function(i, v) {
!Ox.isUndefined(v.size) && that.$elements[i].css(dimensions[0], v.size + "px");
if (i == 0) {
that.$elements[i].css(edges[0], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css(
edges[1], (getSize(self.options.elements[1]) + (length == 3 ? getSize(self.options.elements[2]) : 0)) + "px"
);
} else if (i == 1) {
!Ox.isUndefined(self.options.elements[0].size) && that.$elements[i].css(
edges[0], getSize(self.options.elements[0]) + "px"
);
(!Ox.isUndefined(self.options.elements[0].size) || !Ox.isUndefined(v.size)) && that.$elements[i].css(
edges[1], (length == 3 ? getSize(self.options.elements[2]) : 0) + "px"
);
} else {
that.$elements[i].css(edges[1], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css(
edges[0], (getSize(self.options.elements[0]) + getSize(self.options.elements[1])) + "px"
);
}
});
}
that.resize = function(id, size) {
// one can pass pos instead of id
var pos = Ox.isNumber(id) ? id : getPositionById(id);
Ox.print("pos", pos, self.options.elements, $.map(self.options.elements, function(v, i) { return v.element.options("id"); }))
self.options.elements[pos].size = size;
setSizes();
};
return that;