droparea.js
Summary
No overview generated for 'droparea.js'
Zapatec.Utils.DropArea = function(config) {
if (arguments.length > 1) {
config = {container : config};
config.dropName = arguments[1];
config.eventListeners = {
onDrop : arguments[2],
onDragInit : arguments[3],
onDragOver : arguments[4],
onDragOut : arguments[5],
onDragEnd : arguments[6]
}
}
Zapatec.Utils.DropArea.SUPERconstructor.call(this, config);
};
Zapatec.Utils.DropArea.id = "Zapatec.DropArea";
Zapatec.inherit(Zapatec.Utils.DropArea, Zapatec.Widget);
Zapatec.implement(Zapatec.Utils.DropArea, "Zapatec.CommandEvent");
Zapatec.Utils.DropArea.prototype.init = function(config) {
Zapatec.Utils.DropArea.SUPERclass.init.call(this, config);
this.dropArea = this.getConfiguration().container;
this.elementOver = false;
this.addListeners();
};
Zapatec.Utils.DropArea.prototype.configure = function(config) {
this.defineConfigOption("container", null);
this.defineConfigOption("dropName", null);
this.defineConfigOption("theme", null);
Zapatec.Utils.DropArea.SUPERclass.configure.call(this, config);
config = this.getConfiguration();
config.container = Zapatec.Widget.getElementById(config.container);
};
Zapatec.Utils.DropArea.prototype.reconfigure = function(config) {
Zapatec.Utils.DropArea.SUPERclass.reconfigure.call(this, config);
};
Zapatec.Utils.DropArea.prototype.dragInit = function(ev, movable) {
this.mousePos = movingPoint = movable.getMovingPoint();
var dropArea = Zapatec.Utils.getElementOffset(this.dropArea);
var elems = Zapatec.Array(movable.getMovableElements());
if (elems.length == 1) {
elems = elems[0];
}
if ((movingPoint.x > dropArea.x) && (movingPoint.x < dropArea.x + dropArea.width) &&
(movingPoint.y > dropArea.y) && (movingPoint.y < dropArea.y + dropArea.height)) {
this.elementOver = elems;
}
if (this.fireEvent("onDragInit", elems, this) == "parent-re-execute") {
return "re-execute";
}
if (this.elementOver) {
if (this.fireEvent("onDragOver", elems, this) == "parent-re-execute") {
return "re-execute";
}
}
};
Zapatec.Utils.DropArea.prototype.dragMove = function(ev, movable) {
this.mousePos = movingPoint = movable.getMovingPoint();
var dropArea = Zapatec.Utils.getElementOffset(this.dropArea);
var elems = Zapatec.Array(movable.getMovableElements());
if (elems.length == 1) {
elems = elems[0];
}
if ((movingPoint.x > dropArea.x) && (movingPoint.x < dropArea.x + dropArea.width) &&
(movingPoint.y > dropArea.y) && (movingPoint.y < dropArea.y + dropArea.height)) {
if (!this.elementOver) {
if (this.fireEvent("onDragOver", elems, this) == "parent-re-execute") {
return "re-execute";
}
}
this.elementOver = elems;
} else {
if (this.elementOver) {
if (this.fireEvent("onDragOut", elems, this) == "parent-re-execute") {
return "re-execute";
}
}
this.elementOver = null;
}
};
Zapatec.Utils.DropArea.prototype.dragEnd = function(ev, movable) {
var elems = Zapatec.Array(movable.getMovableElements());
if (elems.length == 1) {
elems = elems[0];
}
if (this.elementOver) {
if (this.fireEvent("onDrop", elems, this) == "parent-re-execute") {
return "re-execute";
}
}
if (this.fireEvent("onDragEnd", elems, this) == "parent-re-execute") {
return "re-execute";
}
this.movingPoint = null;
this.elementOver = null;
};
Zapatec.Utils.DropArea.prototype.removeListeners = function() {
Zapatec.GlobalEvents.removeEventListener("onDragInit", this.tmp.onDragInit);
Zapatec.GlobalEvents.removeEventListener("onDragMove", this.tmp.onDragMove);
Zapatec.GlobalEvents.removeEventListener("onDragEnd", this.tmp.onDragEnd);
}
Zapatec.Utils.DropArea.prototype.addListeners = function() {
var self = this;
if (!this.tmp) {
this.tmp = {};
}
this.tmp.onDragInit = function(ev, movable) {
this.returnValue(self.dragInit(ev, movable));
};
this.tmp.onDragMove = function(ev, movable) {
this.returnValue(self.dragMove(ev, movable));
};
this.tmp.onDragEnd = function(ev, movable) {
this.returnValue(self.dragEnd(ev, movable));
};
Zapatec.GlobalEvents.addEventListener("onDragInit", this.tmp.onDragInit);
Zapatec.GlobalEvents.addEventListener("onDragMove", this.tmp.onDragMove);
Zapatec.GlobalEvents.addEventListener("onDragEnd", this.tmp.onDragEnd);
}
Zapatec.Utils.DropArea.prototype.destroy = function() {
this.dropArea = null;
this.removeListeners();
};
Documentation generated by
JSDoc on Thu Aug 16 12:18:39 2007