mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Merge pull request #4645 from katiefenn/issue-4356
This commit is contained in:
commit
3eb457a6aa
1 changed files with 18 additions and 7 deletions
|
@ -15,8 +15,7 @@ var PostTagsInputView = Ember.View.extend({
|
|||
ESCAPE: 27,
|
||||
UP: 38,
|
||||
DOWN: 40,
|
||||
NUMPAD_ENTER: 108,
|
||||
COMMA: 188
|
||||
NUMPAD_ENTER: 108
|
||||
},
|
||||
|
||||
didInsertElement: function () {
|
||||
|
@ -52,6 +51,23 @@ var PostTagsInputView = Ember.View.extend({
|
|||
this.get('parentView').set('hasFocus', false);
|
||||
},
|
||||
|
||||
keyPress: function (event) {
|
||||
// listen to keypress event to handle comma key on international keyboard
|
||||
var controller = this.get('parentView.controller'),
|
||||
isComma = ','.localeCompare(String.fromCharCode(event.keyCode || event.charCode)) === 0;
|
||||
|
||||
// use localeCompare in case of international keyboard layout
|
||||
if (isComma) {
|
||||
event.preventDefault();
|
||||
|
||||
if (controller.get('selectedSuggestion')) {
|
||||
controller.send('addSelectedSuggestion');
|
||||
} else {
|
||||
controller.send('addNewTag');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
keyDown: function (event) {
|
||||
var controller = this.get('parentView.controller'),
|
||||
keys = this.get('parentView.keys'),
|
||||
|
@ -71,11 +87,6 @@ var PostTagsInputView = Ember.View.extend({
|
|||
case keys.TAB:
|
||||
case keys.ENTER:
|
||||
case keys.NUMPAD_ENTER:
|
||||
case keys.COMMA:
|
||||
if (event.keyCode === keys.COMMA && event.shiftKey) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (controller.get('selectedSuggestion')) {
|
||||
event.preventDefault();
|
||||
controller.send('addSelectedSuggestion');
|
||||
|
|
Loading…
Reference in a new issue