Home Reference Source
import CommentListViewController from '~/controllers/CommentListViewController.js'
public class | source

CommentListViewController

Extends:

ViewController → CommentListViewController

Manages a list of comments

Constructor Summary

Public Constructor
public

constructor(comment: HTMLElement, owner: Post | Answer, opts: Object)

Creates the comment list controller from HTML element.

Member Summary

Public Members
public

Method Summary

Public Methods
public

addInstance(html: HTMLElement, type: InstanceType)

Adds an instance

public

async createCommentInstance(comment: Comment, type: InstanceType): HTMLElement

Creates a comment in the list

public

Reports an error

public

createLoadingInstance(message: string, type: InstanceType, animated: boolean): Object

Creates a 'loading' instance in this comment list.

public

async createMultipleCommentInstances(comments: Comment[], type: InstanceType, animated: boolean, constructionOptions: Object): HTMLElement

Creates a 'grouped comment' instance.

public

For static construction this will setup the sublists

Inherited Summary

From class ViewController
public static

forClass(className: string, predicate: Function, root: HTMLElement)

Creates a view controller directly for all members of a class.

public static

of(elem: string | Element): ViewController

Returns a canolical VC of an element if it exists

Public Constructors

public constructor(comment: HTMLElement, owner: Post | Answer, opts: Object) source

Creates the comment list controller from HTML element.

Override:

ViewController#constructor

Params:

NameTypeAttributeDescription
comment HTMLElement

List physical element

owner Post | Answer

The owner

opts Object
  • optional
  • default: {}

] - additional options

Public Members

public owner: Post | Answer | Comment source

Public Methods

public addInstance(html: HTMLElement, type: InstanceType) source

Adds an instance

Params:

NameTypeAttributeDescription
html HTMLElement

HTML node

type InstanceType

The instance type

public async createCommentInstance(comment: Comment, type: InstanceType): HTMLElement source

Creates a comment in the list

Params:

NameTypeAttributeDescription
comment Comment

The comment to add

type InstanceType

Where it should be added

Return:

HTMLElement

created element

public createErrorInstance() source

Reports an error

public createLoadingInstance(message: string, type: InstanceType, animated: boolean): Object source

Creates a 'loading' instance in this comment list.

Params:

NameTypeAttributeDescription
message string

what to display in box

type InstanceType

The type of instance to add

animated boolean
  • optional
  • default: true

If we should animate element

Return:

Object

has async .destroy() function to destroy loading instance. Also .node

public async createMultipleCommentInstances(comments: Comment[], type: InstanceType, animated: boolean, constructionOptions: Object): HTMLElement source

Creates a 'grouped comment' instance. i.e. group of comments. The difference between this and calling createCommentInstance multiple times is this will perform a proper animation of the nodes.

Params:

NameTypeAttributeDescription
comments Comment[]

List of all comments

type InstanceType

Where it should be added

animated boolean
  • optional
  • default: false

If should be animated

constructionOptions Object

options when constructing each comment

Return:

HTMLElement

created element

public setupSublists() source

For static construction this will setup the sublists