From d1b2b184dd7747b21eb5f69439f2a4dd5c271cf7 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 22 Oct 2014 10:08:23 +0300 Subject: fixes #106 broken by define addition (require.js) --- scripts/textanalysis.js | 12 ++++++++++++ scripts/textanalysis.ui.js | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js index 61e15919..413f5eab 100644 --- a/scripts/textanalysis.js +++ b/scripts/textanalysis.js @@ -401,11 +401,23 @@ var textAnalyser2 = function (newtext, finalize) { return ret; } + return { autocompleteCallback:autocompleteCallback, textAnalyser2:textAnalyser2, autoSuggestAddName:autoSuggestAddName, ANALYSIS_NODE_START:ANALYSIS_NODE_START, ANALYSIS_LINK:ANALYSIS_LINK, + lastnode: function() { return lastnode; }, + typeindex: function() { return typeindex; }, + typeindex_next: function() { + typeindex = (typeindex + 1) % 5; + return typeindex; + }, + typeindex_prev: function() { + typeindex = (typeindex + 4) % 5; + return typeindex; + }, + nodetypes: function() { return nodetypes; } // XXX should be readonly, but returning a copy? }; }); diff --git a/scripts/textanalysis.ui.js b/scripts/textanalysis.ui.js index 0a1e3ece..69f2e675 100644 --- a/scripts/textanalysis.ui.js +++ b/scripts/textanalysis.ui.js @@ -38,22 +38,24 @@ function textSelect(inp, s, e) { } function changeType(arg, id) { + var typeindex; + var lastnode = textanalysis.lastnode(); + var nodetype; + if(!id) { id = "new node"; } + typeindex = (arg === 'up'? textanalysis.typeindex_next() : textanalysis.typeindex_prev()); + nodetype = textanalysis.nodetypes()[typeindex]; + if (arg === 'up') { - if (typeindex < 4) typeindex++; - else typeindex = 0; - RZ.graph.editType(id, null, nodetypes[typeindex]); - $('.typeselection').html('
' + "Chosen Type: " + nodetypes[typeindex] + '
'); - RZ.graph.findCoordinates(lastnode,null); + RZ.graph.editType(id, null, nodetype); + $('.typeselection').html('
' + "Chosen Type: " + nodetype + '
'); + RZ.graph.findCoordinates(lastnode, null); } else { - if (typeindex > 0) typeindex--; - else typeindex = 4; - - RZ.graph.editType(id, null, nodetypes[typeindex]); - $('.typeselection').html('
' + "Chosen Type: " + nodetypes[typeindex] + '
'); - RZ.graph.findCoordinates(lastnode,null); + RZ.graph.editType(id, null, nodetype); + $('.typeselection').html('
' + "Chosen Type: " + nodetype + '
'); + RZ.graph.findCoordinates(lastnode, null); } RZ.graph.update(true); } @@ -78,7 +80,7 @@ return { } if (e.keyCode == 9) {//TAB e.preventDefault(); - changeType("down", lastnode); + changeType("down", textanalysis.lastnode()); return false; } -- cgit v1.3.1