2016-04-19 10:55:10 -05:00
|
|
|
import Ember from 'ember';
|
2016-04-28 10:34:36 -05:00
|
|
|
import {invokeAction} from 'ember-invoke-action';
|
2016-04-19 10:55:10 -05:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-04-28 10:34:36 -05:00
|
|
|
invokeAction(this, 'select.actions.search', term);
|
2016-04-19 10:55:10 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
focusInput() {
|
|
|
|
this.$('input')[0].focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
resetInput() {
|
|
|
|
this.$('input').val('');
|
|
|
|
},
|
|
|
|
|
|
|
|
handleKeydown(e) {
|
|
|
|
let select = this.get('select');
|
|
|
|
if (!select.isOpen) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|