mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
43 lines
969 B
JavaScript
43 lines
969 B
JavaScript
import Ember from 'ember';
|
|
import {invokeAction} from 'ember-invoke-action';
|
|
|
|
const {run, isBlank, Component} = Ember;
|
|
|
|
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');
|
|
if (!select.isOpen) {
|
|
e.stopPropagation();
|
|
}
|
|
}
|
|
}
|
|
});
|