Clean up/refactor composer, add escape hotkey

This commit is contained in:
Toby Zerner
2015-02-03 16:59:53 +10:30
parent 74d8b0e377
commit 6544052da6
7 changed files with 259 additions and 211 deletions

View File

@ -7,37 +7,43 @@ var precompileTemplate = Ember.Handlebars.compile;
export default Ember.Component.extend(Ember.Evented, {
layoutName: 'components/discussions/composer-body',
placeholder: 'Write your reply...',
submitLabel: 'Post Reply',
placeholder: '',
value: '',
submit: null,
loading: false,
didInsertElement: function() {
var headerItems = TaggedArray.create();
this.trigger('populateHeader', headerItems);
this.set('headerItems', headerItems);
var controls = TaggedArray.create();
this.trigger('populateControls', controls);
this.set('controls', controls);
},
populateHeader: function(header) {
populateControls: function(controls) {
var title = Ember.Component.create({
tagName: 'h3',
layout: precompileTemplate('Replying to <em>{{component.discussion.title}}</em>'),
component: this
});
header.pushObjectWithTag(title, 'title');
controls.pushObjectWithTag(title, 'title');
},
actions: {
submit: function(value) {
this.get('submit').call(this, value);
this.get('submit')(value);
},
willExit: function(abort) {
// If the user has typed something, prompt them before exiting
// this composer state.
if (this.get('value') && ! confirm('You have not posted your reply. Do you wish to discard it?')) {
abort();
}
},
reset: function() {
this.set('loading', false);
this.set('value', '');
},
}
}
});

View File

@ -4,6 +4,8 @@ import TaggedArray from '../../../utils/tagged-array';
import ActionButton from './action-button';
export default Ember.Component.extend({
disabled: false,
classNames: ['text-editor'],
didInsertElement: function() {