diff options
| author | Alon Levy <alon@pobox.com> | 2015-02-11 17:57:04 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-02-11 17:57:06 +0200 |
| commit | aa1e484e804c226e900c44eb7b397820495310ab (patch) | |
| tree | c1dd0637d5deb23cefa2f612869263eb6f565686 /src/client/textanalysis.ui.js | |
| parent | e6f64e9d55fef3fc351d935f78c7a478066576cb (diff) | |
client/textanalysis.ui: set typeselection position at node, fixes #261
Note that the selection doesn't move with the node, so it is possible to
create a discrepancy, this can happen either when:
1. dragging or zooming the graph
2. causing the bubble animation to playout
The selection text will not be next to the node in both cases until Tab
is pressed again.
Fixing this right now seems too much work, will revisit if this is
really bothersome. Would require either timers or another connection, or
different implementation as a foreign object under the svg node (and so
tied by the layout, no need to change).
Diffstat (limited to 'src/client/textanalysis.ui.js')
| -rw-r--r-- | src/client/textanalysis.ui.js | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/client/textanalysis.ui.js b/src/client/textanalysis.ui.js index 90c771b8..6a8ce4a6 100644 --- a/src/client/textanalysis.ui.js +++ b/src/client/textanalysis.ui.js @@ -25,14 +25,25 @@ var typeselection = function TypeSelectionDialog() { e_desc = e.find('#chosentypedesc'), typeselection = {}; - typeselection.analysisNodeStart = function() { - typeselection.show(); + typeselection.analysisNodeStart = function(node_id) { + typeselection.show(node_id); } - typeselection.show = function() { + function set_position(node_id) + { + var x, + y, + node_location; + + node_location = get_svg__body_position(node_id); + x = node_location.x; + y = node_location.y + 10; e.css({ - top: window.innerHeight / 2 - 115, - left: window.innerWidth / 2 - 325 - }); + left: x, + top: y, + }); + } + typeselection.show = function(node_id) { + set_position(node_id); e_label.hide(); e_desc.hide(); e_intro.show(); @@ -41,9 +52,10 @@ var typeselection = function TypeSelectionDialog() { typeselection.hide = function() { e.hide(); } - typeselection.showChosenType = function(nodetype) { + typeselection.showChosenType = function(node_id, nodetype) { var desc = description[nodetype]; + set_position(node_id); e_intro.hide(); e_label.show(); e_name.html(nodetype); @@ -67,23 +79,27 @@ function analyzeSentence(spec) var sentence = spec.sentence, finalize = spec.finalize, - ret = textanalysis.textAnalyser(spec); + ret = textanalysis.textAnalyser(spec), + lastnode; + + ret.applyToGraph({ + main_graph: rz_core.main_graph, + edit_graph: rz_core.edit_graph, + backend_commit: rz_config.backend_enabled, + }); switch (ret.state) { case textanalysis.ANALYSIS_NODE_START: - typeselection.analysisNodeStart(); + lastnode = textanalysis.lastnode(rz_core.edit_graph, element_raw.selectionStart); + if (lastnode !== null) { + typeselection.analysisNodeStart(lastnode.id); + } break; case textanalysis.ANALYSIS_LINK: typeselection.hide(); break; } - ret.applyToGraph({ - main_graph: rz_core.main_graph, - edit_graph: rz_core.edit_graph, - backend_commit: rz_config.backend_enabled, - }); - if (finalize || sentence.length == 0) { typeselection.hide(); } @@ -118,7 +134,7 @@ function changeType(arg) { nodetype = (arg === 'up'? textanalysis.selected_type_next() : textanalysis.selected_type_prev()); rz_core.edit_graph.editType(id, nodetype); - typeselection.showChosenType(nodetype); + typeselection.showChosenType(id, nodetype); textanalysis.set_type(name, nodetype); } |
