summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/templates/index.html2
-rw-r--r--src/client/textanalysis.ui.js5
-rw-r--r--src/client/view/textanalyser_input.js23
3 files changed, 23 insertions, 7 deletions
diff --git a/res/templates/index.html b/res/templates/index.html
index 87f7b2f6..d083fa61 100644
--- a/res/templates/index.html
+++ b/res/templates/index.html
@@ -115,7 +115,7 @@ var rz_config = { // set as a global variable
</div>
<div id="graph-view__canvas"></div>
<div class="type_selection" style="display:none">
- <div class="type_selection__row" id="type_selection__intro">Change node type with <span class="kbd-button">Tab</span></div>
+ <div class="type_selection__row" id="type_selection__intro">Change node type with <span class="kbd-button">Shift</span>+<span class="kbd-button">Up</span> and <span class="kbd-button">Shift</span>+<span class="kbd-button">Down</span></div>
<div class="type_selection__row" id="type_selection__chosen_type_label">Chosen Type: <span id="type_selection__chosen_type_name"/></div>
<div class="type_selection__row" id="type_selection__chosen_type_desc"></div>
</div>
diff --git a/src/client/textanalysis.ui.js b/src/client/textanalysis.ui.js
index 33dafafe..02ba8b0f 100644
--- a/src/client/textanalysis.ui.js
+++ b/src/client/textanalysis.ui.js
@@ -136,10 +136,9 @@ var main = function ()
finalize: false,
});
});
- input.on_tab.onValue(function (e) {
+ input.on_type.onValue(function (up) {
if (textanalysis.lastnode(rz_core.edit_graph, input.selectionStart())) {
- e.preventDefault();
- changeType(e.shiftKey ? "up" : "down");
+ changeType(up ? "up" : "down");
ret = false;
}
});
diff --git a/src/client/view/textanalyser_input.js b/src/client/view/textanalyser_input.js
index 299d96ae..f6f7bc04 100644
--- a/src/client/view/textanalyser_input.js
+++ b/src/client/view/textanalyser_input.js
@@ -5,7 +5,9 @@ function($, Bacon, _, util, completer, rz_b
var value = util.value;
// Constants
-var nbsp = String.fromCharCode(160);
+var nbsp = String.fromCharCode(160),
+ VK_UP = 38,
+ VK_DOWN = 40;
function textanalyser_input(spec) {
var selectionStart = function () {
@@ -14,10 +16,16 @@ function textanalyser_input(spec) {
function key(val) {
return function (e) {
- return e.keyCode == val;
+ return e.keyCode === val;
};
};
+ function shift_key(val) {
+ return function(e) {
+ return e.keyCode === val && e.shiftKey;
+ }
+ }
+
function current_value() {
return nbsp_to_spaces(value(element_raw));
}
@@ -103,9 +111,18 @@ function textanalyser_input(spec) {
rz_bus.ui_key.plug(document_keydown);
+ function prevent_default_and_stop_propagation(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ return e;
+ }
+ function stream_shift_key(key) {
+ return element.asEventStream('keydown').filter(shift_key(key)).map(prevent_default_and_stop_propagation)
+ }
+
ta.on_sentence = enters.filter(function (v) { return v !== false; });
ta.on_analysis.plug(enters.filter(function (v) { return v === false; }).map(current_value));
- ta.on_tab = element.asEventStream('keydown').filter(key(9));
+ ta.on_type = stream_shift_key(VK_UP).map(true).merge(stream_shift_key(VK_DOWN).map(false));
element.asEventStream('keydown').onValue(function (e) {
document_keydown.push({where: consts.KEYSTROKE_WHERE_TEXTANALYSIS, keys: [e.keyCode]});