diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-12 00:33:53 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-12 00:34:10 +0200 |
| commit | 9e002baeb5e2770411e46b9dfd91e1bb26d4d668 (patch) | |
| tree | dd669f0d144839196ad67f99b71db2638f0c51b0 /src/client/view | |
| parent | ad98e69a60a012f6ea065be80e660fdc29c178ed (diff) | |
client: use some more VK constants
Diffstat (limited to 'src/client/view')
| -rw-r--r-- | src/client/view/node_info.js | 6 | ||||
| -rw-r--r-- | src/client/view/search.js | 6 | ||||
| -rw-r--r-- | src/client/view/svg_input.js | 8 | ||||
| -rw-r--r-- | src/client/view/textanalyser_input.js | 5 |
4 files changed, 13 insertions, 12 deletions
diff --git a/src/client/view/node_info.js b/src/client/view/node_info.js index d2b23e72..ef853a94 100644 --- a/src/client/view/node_info.js +++ b/src/client/view/node_info.js @@ -1,5 +1,5 @@ -define(['jquery', 'jquery-ui', 'util', 'view/helpers', 'view/internal', 'model/diff', 'model/types'], -function($, _unused_jquery_ui, util, view_helpers, internal, model_diff, model_types) { +define(['jquery', 'jquery-ui', 'util', 'consts', 'view/helpers', 'view/internal', 'model/diff', 'model/types'], +function($, _unused_jquery_ui, util, consts, view_helpers, internal, model_diff, model_types) { var d = null, msg_node = $('.info-card-message'), @@ -113,7 +113,7 @@ function setup_click_handlers() } setup_done = true; form_element.on('keydown', function (e) { - if (e.which == 13 && e.target !== delete_button[0]) { + if (e.which == consts.VK_ENTER && e.target !== delete_button[0]) { e.preventDefault(); } }); diff --git a/src/client/view/search.js b/src/client/view/search.js index e74877a2..39b84dd6 100644 --- a/src/client/view/search.js +++ b/src/client/view/search.js @@ -1,5 +1,5 @@ -define(['view/completer', 'textanalysis', 'rz_core', 'view/selection'], -function( completer, textanalysis, rz_core, selection) +define(['consts', 'view/completer', 'textanalysis', 'rz_core', 'view/selection'], +function(consts, completer, textanalysis, rz_core, selection) { var search, search_completer; @@ -21,7 +21,7 @@ function init() { search.asEventStream('input') .merge(search.asEventStream('keydown').filter( function(e) { - if (e.which == 13 && !search_completer.handleEnter()) { + if (e.which == consts.VK_ENTER && !search_completer.handleEnter()) { e.preventDefault(); return false; } diff --git a/src/client/view/svg_input.js b/src/client/view/svg_input.js index db9e190e..1810d814 100644 --- a/src/client/view/svg_input.js +++ b/src/client/view/svg_input.js @@ -1,5 +1,5 @@ -define(['jquery', 'Bacon_wrapper', 'model/diff', 'rz_bus', 'consts'], -function($, Bacon, model_diff, rz_bus, consts) +define(['jquery', 'Bacon_wrapper', 'consts', 'model/diff', 'rz_bus', 'consts'], +function($, Bacon, consts, model_diff, rz_bus, consts) { var svg_input_fo_node_y = '-.70em', svg_input_fo_height = '30px'; @@ -65,10 +65,10 @@ var svgInput = function(vis, graph) { console.log('unexpected editname_on_keypress this should be the svg-input element'); } - if (e.which == 13 || e.which == 27) { + if (e.which == consts.VK_ENTER || e.which == consts.VK_ESCAPE) { ret = false; d = jelement.data().d; - if (e.which == 13 && newname != d.name) { + if (e.which == consts.VK_ENTER && newname != d.name) { if (d.hasOwnProperty('__src')) { graph.update_link(d, {name: newname}); } else { diff --git a/src/client/view/textanalyser_input.js b/src/client/view/textanalyser_input.js index 113489aa..9defdef3 100644 --- a/src/client/view/textanalyser_input.js +++ b/src/client/view/textanalyser_input.js @@ -7,7 +7,8 @@ var value = util.value; // Constants var nbsp = String.fromCharCode(160), VK_UP = consts.VK_UP, - VK_DOWN = consts.VK_DOWN; + VK_DOWN = consts.VK_DOWN, + VK_ENTER = consts.VK_ENTER; function textanalyser_input(spec) { var selectionStart = function () { @@ -107,7 +108,7 @@ function textanalyser_input(spec) { util.assert(1 === element.length); - var enters = element.asEventStream('keydown').filter(key(13)) + var enters = element.asEventStream('keydown').filter(key(VK_ENTER)) .map(function (e) { var text; e.preventDefault(); |
