Reference Source
import AvatarEditor from 'flarum/components/AvatarEditor'
public class | source

AvatarEditor

Extends:

src/common/Component.js~Component → AvatarEditor

The AvatarEditor component displays a user's avatar along with a dropdown menu which allows the user to upload/remove the avatar.

Attrs

  • className
  • user

Member Summary

Public Members
public

Whether or not an image has been dragged over the dropzone.

public

Whether or not an avatar upload is in progress.

Method Summary

Public Methods
public

Get the items in the edit avatar dropdown menu.

public

disableDragover(e: Event)

Disable dragover style

public

dropUpload(e: Event)

Upload avatar when file is dropped into dropzone.

public

enableDragover(e: Event)

Enable dragover style

public

oninit(vnode: *)

public

Upload avatar using file picker

public

quickUpload(e: Event)

If the user doesn't have an avatar, there's no point in showing the controls dropdown, because only one option would be viable: uploading.

public

remove()

Remove the user's avatar.

public

upload(file: File)

Upload avatar

public

view(): *

Protected Methods
protected

failure(response: Object)

If avatar upload/removal fails, stop loading.

protected

success(response: Object)

After a successful upload/removal, push the updated user data into the store, and force a recomputation of the user's avatar color.

Public Members

public isDraggedOver: Boolean source

Whether or not an image has been dragged over the dropzone.

public loading: Boolean source

Whether or not an avatar upload is in progress.

Public Methods

public controlItems(): ItemList source

Get the items in the edit avatar dropdown menu.

Return:

ItemList

public disableDragover(e: Event) source

Disable dragover style

Params:

NameTypeAttributeDescription
e Event

public dropUpload(e: Event) source

Upload avatar when file is dropped into dropzone.

Params:

NameTypeAttributeDescription
e Event

public enableDragover(e: Event) source

Enable dragover style

Params:

NameTypeAttributeDescription
e Event

public oninit(vnode: *) source

Params:

NameTypeAttributeDescription
vnode *

public openPicker() source

Upload avatar using file picker

public quickUpload(e: Event) source

If the user doesn't have an avatar, there's no point in showing the controls dropdown, because only one option would be viable: uploading. Thus, when the avatar editor's dropdown toggle button is clicked, we prompt the user to upload an avatar immediately.

Params:

NameTypeAttributeDescription
e Event

public remove() source

Remove the user's avatar.

public upload(file: File) source

Upload avatar

Params:

NameTypeAttributeDescription
file File

public view(): * source

Return:

*

Protected Methods

protected failure(response: Object) source

If avatar upload/removal fails, stop loading.

Params:

NameTypeAttributeDescription
response Object

protected success(response: Object) source

After a successful upload/removal, push the updated user data into the store, and force a recomputation of the user's avatar color.

Params:

NameTypeAttributeDescription
response Object