2016-06-30 13:21:47 +03:00
|
|
|
import run from 'ember-runloop';
|
|
|
|
import {isBlank} from 'ember-utils';
|
|
|
|
import Component from 'ember-component';
|
2016-04-28 18:34:36 +03:00
|
|
|
import {invokeAction} from 'ember-invoke-action';
|
2016-04-19 18:55:10 +03:00
|
|
|
|
|
|
|
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 18:34:36 +03:00
|
|
|
invokeAction(this, 'select.actions.search', term);
|
2016-04-19 18:55:10 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
focusInput() {
|
|
|
|
this.$('input')[0].focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
resetInput() {
|
|
|
|
this.$('input').val('');
|
|
|
|
},
|
|
|
|
|
|
|
|
handleKeydown(e) {
|
|
|
|
let select = this.get('select');
|
|
|
|
if (!select.isOpen) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|