diff options
| author | Alon Levy <alon@pobox.com> | 2015-01-11 12:43:16 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-01-11 12:43:16 +0200 |
| commit | ea74876fb9d980b17db1bd504fb5ef28dd75382e (patch) | |
| tree | 26c3a3ed2bd2f889d42cba7b7b9c43051ca24bcc /src/client/textanalysis.ui.js | |
| parent | d5a68f9f00eef3d65811c3b6233ffc3126a7615c (diff) | |
client/textanalysis: fix node type change on tab to use cursor correctly (still cannot change type of chained node during editing)
Diffstat (limited to 'src/client/textanalysis.ui.js')
| -rw-r--r-- | src/client/textanalysis.ui.js | 24 |
1 files changed, 8 insertions, 16 deletions
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}); }); |
