diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-02 15:03:30 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-02 15:03:30 +0200 |
| commit | 69db98f2cfcaac2a720b6fa73f452fd653de114f (patch) | |
| tree | e68e4f3e99df75393d66df47d7beffbe28b129a7 /src/client/view/completer.js | |
| parent | 8cb62074eaa6f7c2105c2e0944294186384c6fef (diff) | |
completer: update to work with both input and div elements
Diffstat (limited to 'src/client/view/completer.js')
| -rw-r--r-- | src/client/view/completer.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/client/view/completer.js b/src/client/view/completer.js index 2e12b9b1..f2aac257 100644 --- a/src/client/view/completer.js +++ b/src/client/view/completer.js @@ -2,6 +2,9 @@ define( ['jquery', 'Bacon', 'util'], function($, Bacon, util) { +var value = util.value, + selectionStart = util.selectionStart; + function quoted__double(string) { // quote string using double quotes return '"' + string + '"'; } @@ -22,9 +25,9 @@ function unquoted(name) { return name; } -function setCaret(e, num) +function setCaret(e_raw, num) { - e.selectionStart = e.selectionEnd = num; + util.setSelection(e_raw, num, num); } var completer = (function (input_element, dropdown, base_config) { @@ -67,7 +70,7 @@ var completer = (function (input_element, dropdown, base_config) { default: // This catches cursor move due to keyboard events. no event for cursor movement itself // below we catch cursor moves due to mouse click - oninput(input_element_raw.value, input_element_raw.selectionStart); + oninput(value(input_element_raw), selectionStart(input_element_raw)); } return ret; }); @@ -239,8 +242,8 @@ var completer = (function (input_element, dropdown, base_config) { function _applySuggestion(str) { var cur = input_element.val(), start = cur.slice(0, completion_start) + str + (config.appendSpaceOnEnter ? ' ' : ''); - input_element.val(start + cur.slice(completion_end)); - setCaret(input_element, start.length); + value(input_element_raw, start + cur.slice(completion_end)); + setCaret(input_element_raw, start.length); oninput('', 0); } function handleEnter() { |
