2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2016-04-28 18:34:36 +03:00
|
|
|
import {invokeAction} from 'ember-invoke-action';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {isBlank} from '@ember/utils';
|
|
|
|
import {run} from '@ember/runloop';
|
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');
|
2016-09-14 18:11:41 +03:00
|
|
|
|
|
|
|
// TODO: remove keycode check once EPS is updated to 1.0
|
|
|
|
if (!select.isOpen || e.keyCode === 32) {
|
2016-04-19 18:55:10 +03:00
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|