mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
9ed5aad186
no issue - the upcoming Module Unification re-organisation in Ember will no longer support nested components - this PR pre-emptively moves our usage of nested components into a flat file structure
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
import Component from '@ember/component';
|
|
import {invokeAction} from 'ember-invoke-action';
|
|
import {isBlank} from '@ember/utils';
|
|
import {run} from '@ember/runloop';
|
|
|
|
export default Component.extend({
|
|
open() {
|
|
this.get('select.actions').open();
|
|
},
|
|
|
|
close() {
|
|
this.get('select.actions').close();
|
|
},
|
|
|
|
actions: {
|
|
captureMouseDown(e) {
|
|
e.stopPropagation();
|
|
},
|
|
|
|
search(term) {
|
|
if (isBlank(term) === this.get('select.isOpen')) {
|
|
run.scheduleOnce('afterRender', this, isBlank(term) ? this.close : this.open);
|
|
}
|
|
|
|
invokeAction(this, 'select.actions.search', term);
|
|
},
|
|
|
|
focusInput() {
|
|
this.$('input')[0].focus();
|
|
},
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
});
|