Working in the resize action.

This commit is contained in:
mdtrooper 2016-03-11 13:14:59 +01:00
parent fd0995af96
commit 2359b955db

View File

@ -351,7 +351,7 @@ MapController.prototype.paint_resize_square = function(item, wait) {
if (typeof(wait) === "undefined") if (typeof(wait) === "undefined")
wait = 1; wait = 1;
var count_files = 1; var count_files = 16;
function wait_load(callback) { function wait_load(callback) {
count_files--; count_files--;
@ -391,21 +391,40 @@ MapController.prototype.paint_resize_square = function(item, wait) {
self.paint_resize_square(item, 0); self.paint_resize_square(item, 0);
} }
else { else {
resize_square var handles = resize_square
.append("g").attr("class", "handles") .append("g").attr("class", "handles");
.selectAll(".handle")
.data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"]) handles.selectAll(".handle")
.enter() .data(["N", "NE", "E", "SE", "S", "SW", "W", "NW"])
.append("g") .enter()
.attr("class", function(d) { return "handler handler_" + d;}) .append("g")
.append("use") .attr("class", function(d) { return "handler handler_" + d;});
.attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
.on("load", function() { handles.selectAll(".handler").each(function(d) {
wait_load(function() { d3.select(this)
self.paint_resize_square( .append("use")
item, 0); .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);
});
});
});
} }
}); });
@ -450,6 +469,7 @@ MapController.prototype.paint_resize_square = function(item, wait) {
.attr("height", (bbox_item.height * transform_viewport.scale[1])); .attr("height", (bbox_item.height * transform_viewport.scale[1]));
// Set the handlers // Set the handlers
var bbox_handler = d3 var bbox_handler = d3
.select(self._target + " .handler").node().getBBox(); .select(self._target + " .handler").node().getBBox();
@ -522,93 +542,27 @@ MapController.prototype.paint_resize_square = function(item, wait) {
//~ }); //~ });
}); });
resize_square.style("opacity", 1); resize_square.style("opacity", 1);
break; break;
} }
} }
MapController.prototype.change_handler_image = function(action, handler, wait) { MapController.prototype.change_handler_image = function(action, handler, wait) {
//~ console.log("action", action);
//~ var self = this; var handlers_d3 = d3.select(self._target + " .handles");
//~ var handler_d3 = d3.select(self._target + " .handler_" + handler);
//~ if (typeof(wait) === "undefined")
//~ wait = 1; switch (action) {
//~ case "mouseover":
//~ var count_files = 1; handler_d3.select(".default").style("opacity", 0);
//~ function wait_load(callback) { handler_d3.select(".over").style("opacity", 1);
//~ count_files--; break;
//~ case "mouseout":
//~ if (count_files == 0) { handler_d3.select(".default").style("opacity", 1);
//~ callback(); handler_d3.select(".over").style("opacity", 0);
//~ } break;
//~ } }
//~
//~
//~ var handlers_d3 = d3.select(self._target + " .handles");
//~ var handler_d3 = d3.select(self._target + " .handler_" + handler);
//~
//~ console.log("target", self._target);
//~
//~
//~
//~ switch (wait) {
//~ case 1:
//~
//~ handler_d3.select("use").remove();
//~
//~ switch (action) {
//~ case "mouseover":
//~ console.log("__mouseover");
//~
//~
//~
//~ handler_d3.append("use")
//~ .attr("xlink:href", "images/maps/resize_handle.over.svg#resize_handle_over")
//~ .attr("class", function(d) { return "handler " + d;})
//~ .on("load", function() {
//~ wait_load(function() {
//~ self.change_handler_image(
//~ action, handler, 0);
//~ });
//~ });
//~
//~ break;
//~ case "mouseout":
//~ console.log("__mouseout");
//~
//~ handler_d3.append("use")
//~ .attr("xlink:href", "images/maps/resize_handle.svg#resize_handle")
//~ .attr("class", function(d) { return "handler " + d;})
//~ .on("load", function() {
//~ wait_load(function() {
//~ self.change_handler_image(
//~ action, handler, 0);
//~ });
//~ });
//~
//~ break;
//~ }
//~ break;
//~ case 0:
//~ handler_d3
//~ .on("mouseover", null)
//~ .on("mouseout", null)
//~ .on("click", null);
//~ handler_d3
//~ .on("mouseover", function(d) {
//~ self.change_handler_image("mouseover", d);
//~ console.log("mouseover");
//~ })
//~ .on("mouseout", function(d) {
//~ self.change_handler_image("mouseout", d);
//~ console.log("mouseout");
//~ })
//~ .on("click", function(d) {
//~ console.log("click");
//~ });
//~ break;
//~ }
} }
MapController.prototype.event_resize = function(action, item, handler) { MapController.prototype.event_resize = function(action, item, handler) {