2015-02-10 15:35:40 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
import HasItemLists from 'flarum/mixins/has-item-lists';
|
|
|
|
import ActionButton from 'flarum/components/ui/action-button';
|
|
|
|
|
|
|
|
/**
|
|
|
|
A text editor. Contains a textarea and an item list of `controls`, including
|
|
|
|
a submit button.
|
|
|
|
*/
|
|
|
|
export default Ember.Component.extend(HasItemLists, {
|
|
|
|
classNames: ['text-editor'],
|
|
|
|
itemLists: ['controls'],
|
|
|
|
|
|
|
|
value: '',
|
|
|
|
disabled: false,
|
|
|
|
|
|
|
|
didInsertElement: function() {
|
|
|
|
var component = this;
|
|
|
|
this.$('textarea').bind('keydown', 'meta+return', function() {
|
|
|
|
component.send('submit');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
populateControls: function(items) {
|
2015-03-03 18:00:52 +08:00
|
|
|
this.addActionItem(items, 'submit', this.get('submitLabel'), 'check').reopen({className: 'btn btn-primary', listItemClass: 'primary-control'});
|
2015-02-10 15:35:40 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
submit: function() {
|
|
|
|
this.sendAction('submit', this.get('value'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|