mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
48e3bf003d
no issue - https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/order-in-components.md - https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/order-in-controllers.md - https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/order-in-routes.md
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import Component from '@ember/component';
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
export default Component.extend({
|
|
actions: {
|
|
captureMouseDown(e) {
|
|
e.stopPropagation();
|
|
},
|
|
|
|
search(term) {
|
|
// open dropdown if not open and term is present
|
|
// close dropdown if open and term is blank
|
|
if (isBlank(term) === this.get('select.isOpen')) {
|
|
isBlank(term) ? this.close() : this.open();
|
|
|
|
// ensure focus isn't lost when dropdown is closed
|
|
if (isBlank(term)) {
|
|
this._focusInput();
|
|
}
|
|
}
|
|
|
|
this.get('select').actions.search(term);
|
|
},
|
|
|
|
focusInput() {
|
|
this._focusInput();
|
|
},
|
|
|
|
resetInput() {
|
|
this.$('input').val('');
|
|
},
|
|
|
|
handleKeydown(e) {
|
|
let select = this.get('select');
|
|
|
|
// TODO: remove keycode check once EPS is updated to 1.0
|
|
if (!select.isOpen || e.keyCode === 32) {
|
|
e.stopPropagation();
|
|
}
|
|
}
|
|
},
|
|
|
|
open() {
|
|
this.get('select.actions').open();
|
|
},
|
|
|
|
close() {
|
|
this.get('select.actions').close();
|
|
},
|
|
|
|
_focusInput() {
|
|
this.$('input')[0].focus();
|
|
}
|
|
});
|