1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| container_dblclick($event) {
var d = document.getElementById("dragging-container");
if (this.tmpSelDblClick == 0) {
this.X1 = $event.layerX;// - d.offsetLeft;
this.Y1 = $event.layerY;// - d.offsetTop;
var c = document.getElementById("dragging-container");
console.log("X1 : " + this.X1.toString() + " - Y1 : " + this.Y1.toString());
document.getElementById("selectmsg").innerHTML =
"Please double click on the opposite corner of the area to select";
//this.X1 + " " + this.Y1;
this.tmpSelDblClick = 1;
} else if (this.tmpSelDblClick == 1) {
this.tmpSelDblClick = 2;
this.X2 = $event.layerX;// - d.offsetLeft;
this.Y2 = $event.layerY;// - d.offsetTop;
console.log("X2 : " + this.X2.toString() + " - Y2 : " + this.Y2.toString());
document.getElementById("selectmsg").innerHTML =
"Please move the area to move the elements under it. Double click outside to end."
//this.X1 + " " + this.Y1 + " / " + this.X2 + " " + this.Y2;
var s = document.getElementById("selectframe");
var dc = document.getElementById("page-bg-image");
//this.X1 = (this.X1 * 1) - (dc.offsetParent.offsetLeft);
//this.X2 = (this.X2 * 1) - (dc.offsetParent.offsetLeft);
//this.Y1 = (this.Y1 * 1) - (dc.offsetParent.offsetTop * 1);
//this.Y2 = (this.Y2 * 1) - (dc.offsetParent.offsetTop * 1);
s.style.zIndex = "4";
s.style.position = "absolute";
s.style.top = this.Y1 + "px";
s.style.left = this.X1 + "px";
s.style.width = (this.X2 - this.X1) + "px";
s.style.height = (this.Y2 - this.Y1) + "px";
s.style.border = "solid";
this.SelectElementsFromCoord();
} else if (this.tmpSelDblClick == 2) {
this.lstElements = [];
var s = document.getElementById("selectframe");
s.style.top = "0";
s.style.left = "0";
s.style.width = "1px";
s.style.height = "1px";
this.X1 = 0;
this.Y1 = 0;
this.X2 = 0;
this.Y2 = 0;
document.getElementById("selectmsg").innerHTML = "<BR />";
this.tmpSelDblClick = 0;
}
}
SelectElementsFromCoord(this) {
var _this = this;
var c = document.getElementById("dragging-container");
this.el.ycod = 0 ;
var i = 0;
this.configICList[0].icList.forEach(function (elem) {
var h = document.getElementById(elem.icid);
var x = h.offsetLeft;
var y = h.offsetTop;
//x = (x * 1) + (dc.offsetLeft * 1);
console.log("i : " + i + " - x : " + x + " ; y : " + y);
console.log("relative to the dragging container :");
console.log("X1 : " + _this.X1 + " ; Y1 : " + _this.Y1);
console.log("X2 : " + _this.X2 + " ; Y2 : " + _this.Y2);
console.log("relative to the page :");
console.log("X1 : " + ((_this.X1 * 1) + (c.offsetLeft * 1)) + " ; Y1 : " + ((_this.Y1 * 1) + (c.offsetTop * 1)));
console.log("X2 : " + ((_this.X2 * 1) + (c.offsetLeft * 1)) + " ; Y2 : " + ((_this.Y2 * 1) + (c.offsetTop * 1)));
_this.el.id = elem.icid;
_this.el.xcod = document.getElementById(elem.icid).style.left;
_this.el.ycod = document.getElementById(elem.icid).style.top;
if ((_this.X1 < x) && (x < _this.X2) && (_this.Y1 < y) && (y < _this.Y2)) {
console.log(elem.icid + " : " + elem.shortText);
console.log("++++++++++++++++++++++++++++++++++++++++++");
var el = { id: _this.el.id, xcod: _this.el.xcod + "", ycod: _this.el.ycod + "" };
_this.lstElements.push(el);
}
else {
console.log("-----------------------------------------");
}
i++;
});
console.log(this.lstElements.length + " elements selected : ");
this.lstElements.forEach(function (element) {
console.log(element.id + " ; " + element.xcod + ", " + element.ycod)
});
} |
Partager