summaryrefslogtreecommitdiff
path: root/src/client/main.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-01-06 16:12:09 +0200
committerAlon Levy <alon@pobox.com>2015-01-06 16:12:09 +0200
commit9e8618229939fb9097427f059ae57d95a610911a (patch)
tree37ed096f20c13b0cda779fd9f9106190e6fac5f0 /src/client/main.js
parent05b448607ddf1b87e0a90a43b11fd54ac4a0c0d4 (diff)
client: extract search to client/view/search.js
Diffstat (limited to 'src/client/main.js')
-rw-r--r--src/client/main.js37
1 files changed, 4 insertions, 33 deletions
diff --git a/src/client/main.js b/src/client/main.js
index ca7625aa..5c837b75 100644
--- a/src/client/main.js
+++ b/src/client/main.js
@@ -1,5 +1,5 @@
-define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core', 'view/selection', 'util', 'view/completer'],
-function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core, selection, util, completer) {
+define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core', 'view/selection', 'util', 'view/search'],
+function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core, selection, util, search) {
function expand(obj){
if (!obj.savesize) {
@@ -23,13 +23,9 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop,
}
this.main = function() {
- var json,
- search = $('#search'),
- search_completer = completer(search, $('#search-suggestion'),
- {triggerStart:' ', triggerEnd:' '});
+ var json;
console.log('Rhizi main started');
- search_completer.options.plug(textanalysis.suggestions_options);
drag_n_drop.init();
$('#editname').onkeyup = function() { expand(this); };
$('#editlinkname').onkeyup = function() { expand(this); };
@@ -63,32 +59,6 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop,
// TODO: rz_core.main_graph.undo();
}
};
- // TODO: move me somewhere
- function search_on_submit() {
- var text = search[0].value.trim(),
- r;
-
- try {
- r = new RegExp(text.replace(/ /, '|'), 'i');
- } catch (e) {
- return; // don't clear selection either
- }
- if (text.length > 0) {
- selection.byVisitors(function (n) { return n.name.match(r); });
- } else {
- selection.clear();
- }
- rz_core.update_view__graph(false);
- };
- search.on('input', search_on_submit);
- search.on('keydown', function(e) {
- if (e.which == 13 && !search_completer.handleEnter()) {
- e.preventDefault();
- search_on_submit(e);
- return false;
- }
- return undefined;
- });
var intro_task_elem = $('#intro-task');
// TODO: messages (why tasks?) - this one is special but we want them to be handled in their own file.
@@ -103,6 +73,7 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop,
// TODO: interaction between the hack above and this
model_core.init(rz_config);
textanalysis.init(rz_core.main_graph);
+ search.init();
}
return {