mirror of
https://github.com/flarum/framework.git
synced 2025-01-10 04:53:53 +08:00
41 lines
963 B
JavaScript
41 lines
963 B
JavaScript
|
import Ember from 'ember';
|
||
|
|
||
|
import HasItemLists from 'flarum/mixins/has-item-lists';
|
||
|
|
||
|
/**
|
||
|
This component is a base class for a composer body. It provides a template
|
||
|
with a list of controls, a text editor, and some default behaviour.
|
||
|
*/
|
||
|
export default Ember.Component.extend(HasItemLists, {
|
||
|
layoutName: 'components/composer/composer-body',
|
||
|
|
||
|
itemLists: ['controls'],
|
||
|
|
||
|
submitLabel: '',
|
||
|
placeholder: '',
|
||
|
content: '',
|
||
|
originalContent: '',
|
||
|
user: null,
|
||
|
submit: null,
|
||
|
loading: false,
|
||
|
confirmExit: '',
|
||
|
|
||
|
disabled: Ember.computed.alias('composer.minimized'),
|
||
|
|
||
|
actions: {
|
||
|
submit: function(content) {
|
||
|
this.get('submit')({
|
||
|
content: content
|
||
|
});
|
||
|
},
|
||
|
|
||
|
willExit: function(abort) {
|
||
|
// If the user has typed something, prompt them before exiting
|
||
|
// this composer state.
|
||
|
if (this.get('content') !== this.get('originalContent') && !confirm(this.get('confirmExit'))) {
|
||
|
abort();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|