CommentFormOperation

CommentFormOperation

Class representing a single comment form operation.

Constructor

new CommentFormOperation(registry, type, options)

Source:
Parameters:
Name Type Description
registry CommentFormOperationRegistry

Operation registry.

type 'load' | 'preview' | 'viewChanges' | 'submit'

Operation type.

options object

Methods

close()

Source:

Mark the operation as closed if it is not; unregister it. Should be done when an operation has finished (either successfully or not).

delay()

Source:

Mark the operation as delayed.

getDate() → {Date}

Source:

Get the date of the operation.

Returns:
Type
Date

getOption(name) → {*}

Source:

Get the value of an option.

Parameters:
Name Type Description
name string

Option name.

Returns:
Type
*

getType() → {'load'|'preview'|'viewChanges'|'submit'}

Source:

Get the type of the operation.

Returns:
Type
'load' | 'preview' | 'viewChanges' | 'submit'

isClosed() → {boolean}

Source:

Check whether the operation is closed (settled).

Returns:
Type
boolean

isDelayed() → {boolean}

Source:

Check whether the operation is delayed.

Returns:
Type
boolean

maybeClose() → {boolean}

Source:

Check for conflicts of the operation with other pending operations, and if there are such, close the operation and return true to abort it. The rules are the following:

  • preview and viewChanges operations can be overriden with other of one of these types (every new request replaces the old, although a new automatic preview request cannot be made while the old is pending).
  • submit operations cannot be overriden (and are not checked by this function), but also don't override existing preview and viewChanges operations (so that the user gets the last autopreview even after they have sent the comment).

For convenience, can also check for an arbitrary condition and close the operation if it is true.

Returns:
Type
boolean

open(clearMessages)

Source:

Mark the operation as open (run after its creation).

Parameters:
Name Type Description
clearMessages boolean

Whether to clear messages above the comment form.

undelay()

Source:

Unmark the operation as delayed.