0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/app/mixins/text-input.js

26 lines
673 B
JavaScript
Raw Normal View History

2015-02-12 21:22:32 -07:00
import Ember from 'ember';
const {Mixin} = Ember;
export default Mixin.create({
selectOnClick: false,
stopEnterKeyDownPropagation: false,
click(event) {
if (this.get('selectOnClick')) {
event.currentTarget.select();
}
},
keyDown(event) {
// stop event propagation when pressing "enter"
// most useful in the case when undesired (global) keyboard shortcuts are getting triggered while interacting
// with this particular input element.
if (this.get('stopEnterKeyDownPropagation') && event.keyCode === 13) {
event.stopPropagation();
return true;
}
}
});