fire select list event after timeout

This commit is contained in:
rolux 2010-07-17 10:46:27 +02:00
parent 331011b90e
commit 0e109f6db7
2 changed files with 107 additions and 54 deletions

View File

@ -55,6 +55,9 @@ Bars
white-space: nowrap; white-space: nowrap;
} }
.OxResizebar {
z-index: 2;
}
.OxResizebar.OxHorizontal { .OxResizebar.OxHorizontal {
width: 100%; width: 100%;
height: 5px; height: 5px;

View File

@ -827,8 +827,8 @@ requires
$element = that.$element; $element = that.$element;
} }
*/ */
// why does this not work? // why does this not work? (that?)
// ret = that.$element[v].apply(this, arguments); // ret = that.$element[fn].apply(this, arguments);
if (length == 0) { if (length == 0) {
ret = that.$element[fn](); ret = that.$element[fn]();
} else if (length == 1) { } else if (length == 1) {
@ -1272,12 +1272,11 @@ requires
self.startSize = self.options.size; self.startSize = self.options.size;
Ox.print("startSize", self.startSize) Ox.print("startSize", self.startSize)
$window.mousemove(drag); $window.mousemove(drag);
$window.mouseup(dragStop); $window.one("mouseup", dragStop);
} }
function dragStop() { function dragStop() {
$window.unbind("mousemove"); $window.unbind("mousemove");
$window.unbind("mouseup");
} }
function toggle() { function toggle() {
@ -2790,11 +2789,7 @@ requires
self.$items[pos].addClass("OxSelected"); self.$items[pos].addClass("OxSelected");
} }
Ox.print("addToSelection") Ox.print("addToSelection")
that.triggerEvent("select", { triggerSelectEvent();
ids: $.map(self.selected, function(v, i) {
return self.ids[v];
})
});
} }
} }
@ -2838,11 +2833,7 @@ requires
if (!Ox.isUndefined(self.$items[pos])) { if (!Ox.isUndefined(self.$items[pos])) {
self.$items[pos].removeClass("OxSelected"); self.$items[pos].removeClass("OxSelected");
} }
that.triggerEvent("select", { triggerSelectEvent();
ids: $.map(self.selected, function(v, i) {
return self.ids[v];
})
});
} }
} }
@ -3129,6 +3120,24 @@ requires
} }
} }
function triggerSelectEvent() {
var ids = $.map(self.selected, function(v, i) {
return self.ids[v];
});
setTimeout(function() {
var ids_ = $.map(self.selected, function(v, i) {
return self.ids[v];
});
if (ids.length == ids_.length && (ids.length == 0 || ids[0] == ids_[0])) {
that.triggerEvent("select", {
ids: ids
});
} else {
Ox.print("select event not triggered after timeout")
}
}, 100);
}
function unloadPage(page) { function unloadPage(page) {
if (page < 0 || page >= self.pages) { if (page < 0 || page >= self.pages) {
return; return;
@ -4606,13 +4615,25 @@ requires
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
Ox.SplitPanel Ox.SplitPanel
options: options:
elements: [{ array of one, two or three elements
collapsible: false, collapsible or not (only for outer elements)
collapsed: false, collapsed or not (only for collapsible elements)
element: {}, OxElement (if any element is resizable or
collapsible, all OxElements must have an id)
resizable: false, resizable or not (only for outer elements)
resize: [], array of sizes (only for resizable elements,
first value is min, last value is max,
other values are "snappy" points in between)
size: 0 size in px (one element must have no size)
}],
orientation: "" "horizontal" or "vertical" orientation: "" "horizontal" or "vertical"
elements: [{ methods:
element, Ox Element isCollapsed(id) element is collapsed or not
size: 0, size in px resize(id, size) resize element to size px
resizable: false resizable or not toggle(id) collapse or expand element
}] events:
resize
toggle
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
*/ */
@ -4625,51 +4646,52 @@ requires
orientation: "horizontal" orientation: "horizontal"
}) })
.options(options || {}) .options(options || {})
.addClass("OxSplitPanel"), .addClass("OxSplitPanel");
length = self.options.elements.length,
dimensions = oxui.getDimensions(self.options.orientation), $.extend(self, {
edges = oxui.getEdges(self.options.orientation); dimensions: oxui.getDimensions(self.options.orientation),
edges: oxui.getEdges(self.options.orientation),
length: self.options.elements.length
});
that.$elements = []; that.$elements = [];
$.each(self.options.elements, function(i, v) { $.each(self.options.elements, function(i, v) {
if (Ox.isUndefined(v.collapsible)) { self.options.elements[i] = $.extend({
v.collapsible = false; collapsible: false,
} collapsed: false,
if (Ox.isUndefined(v.resizable)) { resizable: false,
v.resizable = false; resize: [],
} size: "auto"
}, v);
that.$elements[i] = v.element that.$elements[i] = v.element
.css(edges[2], 0) .css(self.edges[2], 0)
.css(edges[3], 0); .css(self.edges[3], 0);
}); });
setSizes(); setSizes();
$.each(self.options.elements, function(i, v) { $.each(self.options.elements, function(i, v) {
//that.append(element) //that.append(element)
Ox.print("V: ", v)
that.$elements[i].appendTo(that); // fixme: that.$content that.$elements[i].appendTo(that); // fixme: that.$content
if (v.collapsible || v.resizable) { if (v.collapsible || v.resizable) {
Ox.print("v.size", v.size) Ox.print("v.size", v.size)
$resizebar = new Ox.Resizebar({ var $resizebar = new Ox.Resizebar({
collapsible: v.collapsible, collapsible: v.collapsible,
edge: self.options.orientation == "horizontal" ? edge: self.edges[i == 0 ? 0 : 1],
(i == 0 ? "left" : "right") : (i == 0 ? "top" : "bottom"),
elements: i < 2 ? elements: i < 2 ?
[that.$elements[0], that.$elements[1]] : [that.$elements[0], that.$elements[1]] :
[that.$elements[1], that.$elements[2]], [that.$elements[1], that.$elements[2]],
id: v.element.options("id"),
orientation: self.options.orientation == "horizontal" ? "vertical" : "horizontal", orientation: self.options.orientation == "horizontal" ? "vertical" : "horizontal",
parent: that, // fixme: that.$content parent: that, // fixme: that.$content
resizable: v.resizable, resizable: v.resizable,
resize: v.resize, resize: v.resize,
size: v.size size: v.size
}) })
.css(edges[i == 0 ? 0 : 1], v.size); .css(self.edges[i == 0 ? 0 : 1], v.size);
if (i == 0) { $resizebar[i == 0 ? "insertAfter" : "insertBefore"](that.$elements[i]);
$resizebar.appendTo(that);
} else {
$resizebar.prependTo(that); // fixme: that.$content
}
} }
}); });
@ -4677,7 +4699,7 @@ requires
var position = -1; var position = -1;
$.each(self.options.elements, function(i, element) { $.each(self.options.elements, function(i, element) {
if (element.element.options("id") == id) { if (element.element.options("id") == id) {
position = 1; position = i;
return false; return false;
} }
}); });
@ -4690,28 +4712,32 @@ requires
function setSizes() { function setSizes() {
$.each(self.options.elements, function(i, v) { $.each(self.options.elements, function(i, v) {
!Ox.isUndefined(v.size) && that.$elements[i].css(dimensions[0], v.size + "px"); v.size != "auto" && that.$elements[i].css(self.dimensions[0], v.size + "px");
if (i == 0) { if (i == 0) {
that.$elements[i].css(edges[0], 0); that.$elements[i].css(self.edges[0], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css( v.size != "auto" && that.$elements[i].css(
edges[1], (getSize(self.options.elements[1]) + (length == 3 ? getSize(self.options.elements[2]) : 0)) + "px" self.edges[1], (getSize(self.options.elements[1]) + (length == 3 ? getSize(self.options.elements[2]) : 0)) + "px"
); );
} else if (i == 1) { } else if (i == 1) {
!Ox.isUndefined(self.options.elements[0].size) && that.$elements[i].css( self.options.elements[0].size != "auto" && that.$elements[i].css(
edges[0], getSize(self.options.elements[0]) + "px" self.edges[0], getSize(self.options.elements[0]) + "px"
); );
(!Ox.isUndefined(self.options.elements[0].size) || !Ox.isUndefined(v.size)) && that.$elements[i].css( (self.options.elements[0].size != "auto" || v.size != "auto") && that.$elements[i].css(
edges[1], (length == 3 ? getSize(self.options.elements[2]) : 0) + "px" self.edges[1], (self.length == 3 ? getSize(self.options.elements[2]) : 0) + "px"
); );
} else { } else {
that.$elements[i].css(edges[1], 0); that.$elements[i].css(self.edges[1], 0);
!Ox.isUndefined(v.size) && that.$elements[i].css( v.size != "auto" && that.$elements[i].css(
edges[0], (getSize(self.options.elements[0]) + getSize(self.options.elements[1])) + "px" self.edges[0], (getSize(self.options.elements[0]) + getSize(self.options.elements[1])) + "px"
); );
} }
}); });
} }
that.isCollapsed = function(id) {
return self.options.elements[getPositionById(id)].collapsed;
};
that.resize = function(id, size) { that.resize = 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);
@ -4721,6 +4747,30 @@ requires
return that; return that;
}; };
that.toggle = function(id) {
Ox.print("toggle", id);
/*
// something like this is needed to load in collapsed state
if (Ox.isUndefined(self.options.position)) {
self.options.position = parseInt(self.options.parent.css(self.options.edge)) +
(self.options.collapsed ? self.options.size : 0);
}
var size = self.options.position -
(self.options.collapsed ? 0 : self.options.size),
animate = {};
Ox.print("s.o.e", self.options.edge);
*/
var pos = getPositionById(id),
size = self.options.elements[pos].collapsed ? 0 : self.options.elements[pos].size,
animate = {};
animate[self.edges[pos == 0 ? 0 : 1]] = size;
self.options.parent.animate(animate, 200, function() {
var i = (self.options.edge == "left" || self.options.edge == "top") ? 1 : 0;
Ox.Event.trigger("resize_" + id, self.options.elements[i][self.dimensions[1]]());
self.options.elements[pos].collapsed = !self.options.elements[pos].collapsed;
});
};
return that; return that;
}; };