From d27eb43719b1d861a0aaa01a121511bc2e389b0d Mon Sep 17 00:00:00 2001
From: Patrick Simianer
Date: Fri, 6 Nov 2015 11:19:48 +0100
Subject: adding elements by ctrl-click
---
derivation-editor.js | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/derivation-editor.js b/derivation-editor.js
index 7b5eb3d..08b97fc 100644
--- a/derivation-editor.js
+++ b/derivation-editor.js
@@ -180,7 +180,7 @@ var DE_up = function () {
if (this.pair.type != "text")
this.pair.animate({"fill-opacity": 0}, 250);
- snap_to_grid(true);
+ DE_snap_to_grid(true);
}
/******************************************************************************
@@ -223,7 +223,7 @@ var DE_collide = function (obj)
obj["grid_tmp_"] = tmp_pos;
}
-var snap_to_grid = function (anim=false)
+var DE_snap_to_grid = function (anim=false)
{
// just x coord, y is fixed in drag
var d = DE_ui_xbegin;
@@ -297,7 +297,7 @@ var snap_to_grid = function (anim=false)
DE_cur_drag = null;
}
-var DE_debug_snap_to_grid = function () {
+var DE_debug_DE_snap_to_grid = function () {
var s = "";
for (var i=0; i=new_grid) {
+ sh["grid_"] += 1;
+ sh.pair["grid_"] += 1;
+ }
+ }
+ DE_snap_to_grid(true);
}
}
});
@@ -386,7 +401,7 @@ var DE_make_obj = function (x, text, type)
} else if (e.keyCode == 8) {
// backspace
DE_cur_ed_shape.animate({width:DE_cur_ed_shape.getBBox().width-DE_ui_font_width},125);
- setTimeout(function(){snap_to_grid(true);},125);
+ setTimeout(function(){DE_snap_to_grid(true);},125);
} else if (e.keyCode == 13) {
// return
e.preventDefault();
@@ -394,13 +409,13 @@ var DE_make_obj = function (x, text, type)
DE_cur_ed_shape.toFront();
DE_cur_ed.toBack();
DE_cur_ed_shape.animate({width:DE_cur_ed.getBBox().width+(DE_ui_margin-DE_ui_padding)},125);
- setTimeout(function(){snap_to_grid(true);},125);
+ setTimeout(function(){DE_snap_to_grid(true);},125);
DE_edit_mode = false;
} else {
// input
DE_cur_ed_shape.animate({width:(this.value.length*DE_ui_font_width)+2*DE_ui_font_width+2*DE_ui_padding},25);
setTimeout(function(){
- snap_to_grid(true);
+ DE_snap_to_grid(true);
DE_paper.setSize(DE_paper.width+DE_ui_font_width, DE_paper.height);
},25);
}
@@ -410,7 +425,7 @@ var DE_make_obj = function (x, text, type)
DE_cur_ed_shape.toFront();
DE_cur_ed.toBack();
DE_cur_ed_shape.animate({width:DE_cur_ed.getBBox().width+(DE_ui_margin-DE_ui_padding)},125);
- setTimeout(function(){snap_to_grid(true);},125);
+ setTimeout(function(){DE_snap_to_grid(true);},125);
DE_edit_mode = false;
}, true);
});
@@ -475,6 +490,8 @@ var DE_make_obj = function (x, text, type)
DE_id++;
if (type == "target")
DE_next_grid++;
+
+ return sh;
}
var DE_add_object = function()
@@ -497,7 +514,7 @@ var DE_add_object = function()
DE_paper.setSize(DE_paper.width+DE_target_shapes[DE_target_shapes.length-1].getBBox().width+DE_ui_margin, DE_paper.height);
DE_cur_drag = null;
- snap_to_grid(true);
+ DE_snap_to_grid(true);
}
var DE_make_objs = function (a, type)
@@ -556,7 +573,7 @@ var rm_obj = function(obj)
if (!DE_next_grid) // empty
DE_next_grid = 0;
DE_cur_drag = null;
- snap_to_grid(true);
+ DE_snap_to_grid(true);
return;
}
@@ -680,6 +697,7 @@ var DE_init = function ()
var paper_width = DE_ui_xbegin+(Math.max(DE_data_source.length,DE_data_target.length)*(DE_ui_margin+DE_ui_padding+avg_box_len)),
paper_height = DE_ui_ybegin+2*DE_ui_box_height+DE_ui_line_margin;
DE_paper.setSize(paper_width, paper_height);
+
// source objs
DE_make_objs(DE_data_source, "source");
// target objs
--
cgit v1.2.3