Some work in the resize

This commit is contained in:
mdtrooper 2016-03-14 14:26:19 +01:00
parent 1fc3b7497b
commit cb248b6a92
1 changed files with 101 additions and 100 deletions

View File

@ -350,91 +350,7 @@ MapController.prototype.remove_resize_square = function(item, wait) {
d3.select(self._target + " svg #resize_square").remove();
}
MapController.prototype.paint_resize_square = function(item, wait) {
var self = this;
if (typeof(wait) === "undefined")
wait = 1;
var count_files = 16;
function wait_load(callback) {
count_files--;
if (count_files == 0) {
callback();
}
}
switch (wait) {
case 1:
var resize_square = d3
.select(self._target + " svg")
.append("g").attr("id", "resize_square")
.style("opacity", 0);
d3.xml("images/maps/square_selection.svg", "application/xml", function(xml) {
var nodes = xml
.evaluate("//*[@id='square_selection']/*", xml, null, XPathResult.ANY_TYPE, null);
var result = nodes.iterateNext();
resize_square
.append("g").attr("class", "square_selection")
.append(function() {return result});
if (is_buggy_firefox) {
resize_square
.append("g").attr("class", "handles")
.selectAll(".handle")
.data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"])
.enter()
.append("g")
.attr("class", function(d) { return "handler handler_" + d;})
.append("use")
.attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
.attr("class", function(d) { return "handler " + d;});
self.paint_resize_square(item, 0);
}
else {
var handles = resize_square
.append("g").attr("class", "handles");
handles.selectAll(".handle")
.data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"])
.enter()
.append("g")
.attr("class", function(d) { return "handler handler_" + d;});
handles.selectAll(".handler").each(function(d) {
d3.select(this)
.append("use")
.style("opacity", 1)
.attr("class", "default")
.attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
.on("load", function() {
wait_load(function() {
self.paint_resize_square(
item, 0);
});
});
d3.select(this)
.append("use")
.style("opacity", 0)
.attr("class", "over")
.attr("xlink:href", "images/maps/resize_handle.over.svg#resize_handle_over")
.on("load", function() {
wait_load(function() {
self.paint_resize_square(
item, 0);
});
});
});
}
});
break;
case 0:
MapController.prototype.positioning_resize_square = function(item) {
var resize_square = d3.select(self._target + " #resize_square");
var item_d3 = d3.select(self._target + " #node_" + item['graph_id']);
@ -529,7 +445,97 @@ MapController.prototype.paint_resize_square = function(item, wait) {
d3.select(self._target + " .handler_" + d)
.attr("transform", transform.toString());
});
}
MapController.prototype.paint_resize_square = function(item, wait) {
var self = this;
if (typeof(wait) === "undefined")
wait = 1;
var count_files = 16;
function wait_load(callback) {
count_files--;
if (count_files == 0) {
callback();
}
}
switch (wait) {
case 1:
var resize_square = d3
.select(self._target + " svg")
.append("g").attr("id", "resize_square")
.style("opacity", 0);
d3.xml("images/maps/square_selection.svg", "application/xml", function(xml) {
var nodes = xml
.evaluate("//*[@id='square_selection']/*", xml, null, XPathResult.ANY_TYPE, null);
var result = nodes.iterateNext();
resize_square
.append("g").attr("class", "square_selection")
.append(function() {return result});
if (is_buggy_firefox) {
resize_square
.append("g").attr("class", "handles")
.selectAll(".handle")
.data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"])
.enter()
.append("g")
.attr("class", function(d) { return "handler handler_" + d;})
.append("use")
.attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
.attr("class", function(d) { return "handler " + d;});
self.paint_resize_square(item, 0);
}
else {
var handles = resize_square
.append("g").attr("class", "handles");
handles.selectAll(".handle")
.data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"])
.enter()
.append("g")
.attr("class", function(d) { return "handler handler_" + d;});
handles.selectAll(".handler").each(function(d) {
d3.select(this)
.append("use")
.style("opacity", 1)
.attr("class", "default")
.attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
.on("load", function() {
wait_load(function() {
self.paint_resize_square(
item, 0);
});
});
d3.select(this)
.append("use")
.style("opacity", 0)
.attr("class", "over")
.attr("xlink:href", "images/maps/resize_handle.over.svg#resize_handle_over")
.on("load", function() {
wait_load(function() {
self.paint_resize_square(
item, 0);
});
});
});
}
});
break;
case 0:
self.positioning_resize_square(item);
d3.selectAll(" .handler").each(function(d) {
var drag = d3.behavior.drag()
.origin(function(d) { return d; })
.on("dragstart", function(d) {
@ -553,6 +559,7 @@ MapController.prototype.paint_resize_square = function(item, wait) {
});
});
var resize_square = d3.select(self._target + " #resize_square");
resize_square.style("opacity", 1);
break;
@ -596,8 +603,6 @@ MapController.prototype.event_resize = function(action, item, handler) {
var delta_x = d3.event.dx;
var delta_y = d3.event.dy;
var transform = d3.transform(handler_d3.attr("transform"));
switch (handler) {
case "N":
case "S":
@ -609,13 +614,9 @@ MapController.prototype.event_resize = function(action, item, handler) {
break;
}
transform.translate[0] += delta_x;
transform.translate[1] += delta_y;
self.resize_node(item, handler, delta_x, delta_y);
handler_d3.attr("transform", transform.toString());
self.positioning_resize_square(item);
//~ self.move_arrow(d3.select(this).attr("data-graph_id"));
break;
case "dragend":