2015-11-24 05:45:05 +08:00
|
|
|
import { on, observes } from 'ember-addons/ember-computed-decorators';
|
2016-03-18 21:48:57 +08:00
|
|
|
import autosize from 'discourse/lib/autosize';
|
2015-11-24 05:45:05 +08:00
|
|
|
|
|
|
|
export default Ember.TextArea.extend({
|
|
|
|
@on('didInsertElement')
|
|
|
|
_startWatching() {
|
|
|
|
Ember.run.scheduleOnce('afterRender', () => {
|
|
|
|
this.$().focus();
|
|
|
|
autosize(this.element);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
@observes('value')
|
|
|
|
_updateAutosize() {
|
|
|
|
const evt = document.createEvent('Event');
|
|
|
|
evt.initEvent('autosize:update', true, false);
|
|
|
|
this.element.dispatchEvent(evt);
|
|
|
|
},
|
|
|
|
|
|
|
|
@on('willDestroyElement')
|
|
|
|
_disableAutosize() {
|
|
|
|
autosize.destroy(this.$());
|
|
|
|
}
|
|
|
|
});
|