From ea74876fb9d980b17db1bd504fb5ef28dd75382e Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 11 Jan 2015 12:43:16 +0200 Subject: client/textanalysis: fix node type change on tab to use cursor correctly (still cannot change type of chained node during editing) --- src/client/textanalysis.ui.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/client/textanalysis.ui.js') diff --git a/src/client/textanalysis.ui.js b/src/client/textanalysis.ui.js index 2d51efb0..7fe2940f 100644 --- a/src/client/textanalysis.ui.js +++ b/src/client/textanalysis.ui.js @@ -55,8 +55,8 @@ var analysisCompleter = completer(element, $('#input-suggestion'), {hideOnTab: f function analyzeSentence(spec) { util.assert(spec.sentence !== undefined && - spec.finalize !== undefined && - spec.cursor !== undefined, "bad input"); + spec.finalize !== undefined, + "bad input"); var sentence = spec.sentence, finalize = spec.finalize, @@ -97,7 +97,7 @@ function textSelect(inp, s, e) { } function changeType(arg) { - var lastnode = textanalysis.lastnode(rz_core.edit_graph), + var lastnode = textanalysis.lastnode(rz_core.edit_graph, element_raw.selectionStart), nodetype, id, name; @@ -110,15 +110,9 @@ function changeType(arg) { } nodetype = (arg === 'up'? textanalysis.selected_type_next() : textanalysis.selected_type_prev()); - if (arg === 'up') { - rz_core.edit_graph.editType(id, null, nodetype); - typeselection.showChosenType(nodetype); - rz_core.edit_graph.findCoordinates(id); - } else { - rz_core.edit_graph.editType(id, null, nodetype); - typeselection.showChosenType(nodetype); - rz_core.edit_graph.findCoordinates(id); - } + rz_core.edit_graph.editType(id, null, nodetype); + typeselection.showChosenType(nodetype); + rz_core.edit_graph.findCoordinates(id); textanalysis.set_type(name, nodetype); } @@ -145,13 +139,12 @@ return { analyzeSentence({ sentence: element.val(), finalize: false, - cursor: element_raw.selectionStart, }); } ret = false; break; case 9: //TAB - if (textanalysis.lastnode(rz_core.edit_graph)) { + if (textanalysis.lastnode(rz_core.edit_graph, element_raw.selectionStart)) { e.preventDefault(); changeType(e.shiftKey ? "up" : "down"); ret = false; @@ -171,7 +164,7 @@ return { analyzeSentence({ sentence: text, finalize: true, - cursor: element_raw.selectionStart}); + }); text = ""; } @@ -194,7 +187,6 @@ return { analyzeSentence({ sentence: text, finalize: false, - cursor: element_raw.selectionStart }); input.push({where: consts.INPUT_WHERE_TEXTANALYSIS, input: text}); }); -- cgit v1.3.1