mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Add Keys enum; use it when detecting keystrokes in the input suggestions component.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
inputSuggestionsController = ($scope, $element, $attrs) ->
|
||||
inputSuggestionsController = ($scope, $element, $attrs, Keys) ->
|
||||
ctrl = @
|
||||
ctrl.showHint = false
|
||||
ctrl.hasFocus = false
|
||||
@@ -14,7 +14,7 @@ define [
|
||||
ctrl.suggestion = null
|
||||
ctrl.onBlur()
|
||||
ctrl.handleKeyDown = ($event) ->
|
||||
if ($event.which == 9 or $event.which == 13) and ctrl.suggestion? and ctrl.suggestion != ""
|
||||
if ($event.which == Keys.TAB or $event.which == Keys.ENTER) and ctrl.suggestion? and ctrl.suggestion != ""
|
||||
$event.preventDefault()
|
||||
ctrl.localNgModel += ctrl.suggestion
|
||||
ctrl.suggestion = null
|
||||
|
||||
@@ -22,6 +22,7 @@ define [
|
||||
"main/learn"
|
||||
"main/affiliations/controllers/UserAffiliationsController"
|
||||
"main/affiliations/factories/UserAffiliationsDataService"
|
||||
"main/keys"
|
||||
"analytics/AbTestingManager"
|
||||
"directives/asyncForm"
|
||||
"directives/stopPropagation"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.constant "Keys",
|
||||
ENTER : 13
|
||||
TAB : 9
|
||||
ESCAPE : 27
|
||||
SPACE : 32
|
||||
BACKSPACE : 8
|
||||
UP : 38
|
||||
DOWN : 40
|
||||
LEFT : 37
|
||||
RIGHT : 39
|
||||
PERIOD : 190
|
||||
COMMA : 188
|
||||
END : 35
|
||||
Reference in New Issue
Block a user