mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
Make avatar edit menu extensible
This commit is contained in:
parent
82dc0cdd7b
commit
3fcf8f3da5
|
@ -1,6 +1,9 @@
|
||||||
import Component from 'flarum/component';
|
import Component from 'flarum/component';
|
||||||
import avatar from 'flarum/helpers/avatar';
|
import avatar from 'flarum/helpers/avatar';
|
||||||
import icon from 'flarum/helpers/icon';
|
import icon from 'flarum/helpers/icon';
|
||||||
|
import listItems from 'flarum/helpers/list-items';
|
||||||
|
import ItemList from 'flarum/utils/item-list';
|
||||||
|
import ActionButton from 'flarum/components/action-button';
|
||||||
import LoadingIndicator from 'flarum/components/loading-indicator';
|
import LoadingIndicator from 'flarum/components/loading-indicator';
|
||||||
|
|
||||||
export default class AvatarEditor extends Component {
|
export default class AvatarEditor extends Component {
|
||||||
|
@ -20,13 +23,32 @@ export default class AvatarEditor extends Component {
|
||||||
m('a.dropdown-toggle[href=javascript:;][data-toggle=dropdown]', {onclick: this.quickUpload.bind(this)}, [
|
m('a.dropdown-toggle[href=javascript:;][data-toggle=dropdown]', {onclick: this.quickUpload.bind(this)}, [
|
||||||
this.loading() ? LoadingIndicator.component() : icon('pencil icon')
|
this.loading() ? LoadingIndicator.component() : icon('pencil icon')
|
||||||
]),
|
]),
|
||||||
m('ul.dropdown-menu', [
|
m('ul.dropdown-menu', listItems(this.controlItems().toArray()))
|
||||||
m('li', m('a[href=javascript:;]', {onclick: this.upload.bind(this)}, [icon('upload icon'), ' Upload'])),
|
|
||||||
m('li', m('a[href=javascript:;]', {onclick: this.remove.bind(this)}, [icon('times icon'), ' Remove']))
|
|
||||||
])
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
controlItems() {
|
||||||
|
var items = new ItemList();
|
||||||
|
|
||||||
|
items.add('upload',
|
||||||
|
ActionButton.component({
|
||||||
|
icon: 'upload',
|
||||||
|
label: 'Upload',
|
||||||
|
onclick: this.upload.bind(this)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
items.add('remove',
|
||||||
|
ActionButton.component({
|
||||||
|
icon: 'times',
|
||||||
|
label: 'Remove',
|
||||||
|
onclick: this.remove.bind(this)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
quickUpload(e) {
|
quickUpload(e) {
|
||||||
if (!this.props.user.avatarUrl()) {
|
if (!this.props.user.avatarUrl()) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user