summaryrefslogtreecommitdiff
path: root/src/client/textanalysis.ui.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-04-01 13:06:12 +0300
committerAlon Levy <alon@pobox.com>2015-04-02 00:33:37 +0300
commitf70b33b914ee22c07c22941273f5bda73474fa68 (patch)
tree5cf91a3e15094e5cb70eca5b637155e35809832e /src/client/textanalysis.ui.js
parent60c43869630ac94b1725d95f32efff9b2afd7617 (diff)
client/typeselection: switch from absolute positioning to child of node
means that the text moves with the node now, plus allows for setting the node position asynchronously with setting the typeselection.
Diffstat (limited to 'src/client/textanalysis.ui.js')
-rw-r--r--src/client/textanalysis.ui.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/client/textanalysis.ui.js b/src/client/textanalysis.ui.js
index d5345c43..bf1b50fb 100644
--- a/src/client/textanalysis.ui.js
+++ b/src/client/textanalysis.ui.js
@@ -21,31 +21,32 @@ function get_svg__body_position(node_id)
}
var typeselection = function TypeSelectionDialog() {
- var e = $('.type_selection'),
+ var fo = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject'),
+ e = $('.type_selection'),
e_intro = e.find('#type_selection__intro'),
e_label = e.find('#type_selection__chosen_type_label'),
e_name = e.find('#type_selection__chosen_type_name'),
e_desc = e.find('#type_selection__chosen_type_desc'),
typeselection = {};
+ fo.appendChild(e[0]);
typeselection.analysisNodeStart = function(node_id) {
typeselection.show(node_id);
}
- function set_position(node_id)
- {
- var x,
- y,
- node_location;
+ function attach_to(node_id) {
+ var node = document.getElementById(node_id);
- node_location = get_svg__body_position(node_id);
- x = node_location.x - 20; // subtract average node size
- y = node_location.y + 25;
- e.css({ left: x,
- top: y,
- });
+ if (node === undefined) {
+ console.log('cannot show type selection since node does not exist: ' + node_id);
+ return;
+ }
+ node.appendChild(fo);
}
typeselection.show = function(node_id) {
- set_position(node_id);
+ if (document.getElementById(node_id) === null) {
+ return;
+ }
+ attach_to(node_id);
e_label.hide();
e_desc.hide();
e_intro.show();
@@ -57,7 +58,10 @@ var typeselection = function TypeSelectionDialog() {
typeselection.showChosenType = function(node_id, nodetype) {
var desc = description[nodetype];
- set_position(node_id);
+ if (document.getElementById(node_id) === null) {
+ return;
+ }
+ attach_to(node_id);
e_intro.hide();
e_label.show();
e_name.html(nodetype);