mirror of
https://github.com/flarum/framework.git
synced 2025-01-09 20:44:05 +08:00
8683025ef6
This means the component instance is created in the template, meaning properties can be overridden in the view helper. It also just makes more sense - a view instance doesn’t need to exist until it is rendered in the template.
34 lines
826 B
JavaScript
34 lines
826 B
JavaScript
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) {
|
|
this.addActionItem(items, 'submit', this.get('submitLabel')).reopen({className: 'btn btn-primary'});
|
|
},
|
|
|
|
actions: {
|
|
submit: function() {
|
|
this.sendAction('submit', this.get('value'));
|
|
}
|
|
}
|
|
});
|