1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-30 05:18:55 +02:00

MDL-53349 Autocomplete: Support multi lingual COMMA keycode (44)

This commit is contained in:
Nadav Kavalerchik 2017-01-25 00:44:26 +02:00 committed by John Okely
parent 5130953c8a
commit e375029ea0
2 changed files with 15 additions and 10 deletions

File diff suppressed because one or more lines are too long

@ -33,7 +33,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
ENTER: 13,
SPACE: 32,
ESCAPE: 27,
COMMA: 188,
COMMA: 44,
UP: 38
};
@ -543,14 +543,6 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
// We handled this event, so prevent it.
e.preventDefault();
return false;
case KEYS.COMMA:
if (options.tags) {
// If we are allowing tags, comma should create a tag (or enter).
createItem(options, state, originalSelect);
}
// We handled this event, so prevent it.
e.preventDefault();
return false;
case KEYS.UP:
// Choose the previous active item.
activatePreviousItem(state);
@ -581,6 +573,19 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
}
return true;
});
// Support multi lingual COMMA keycode (44).
inputElement.on('keypress', function(e) {
if (e.keyCode === KEYS.COMMA) {
if (options.tags) {
// If we are allowing tags, comma should create a tag (or enter).
createItem(options, state, originalSelect);
}
// We handled this event, so prevent it.
e.preventDefault();
return false;
}
return true;
});
// Handler used to force set the value from behat.
inputElement.on('behat:set-value', function() {
var suggestionsElement = $(document.getElementById(state.suggestionsId));