PrizmDoc v13.0 - Updated
Module: event-store

Module: event-store

An event API. This event store is used internally by the viewer, and should not need to be initialized outside of that usage.

Example
var EventStore = require('event-store.js');

// a generic Viewer constructor
function Viewer(opts) {
    // other modules will expect this to be present
    this.eventStore = EventStore(this);
}

Members

(inner) onDoneCallback

The format of the data provided in the onDone event. This will be an event triggered in the style of module:event-store~eventCallback.

Properties:
Name Type Description
status string

On a successful completion, this value will be success. It can also be cancel for when a user cancels the action.

data *

The data requested by the action. This can be any format that is needed by the event.

Methods

(inner) eventCallback(event, dataopt)

All event callbacks across the viewer follow this pattern.

Parameters:
Name Type Attributes Description
event Object

The event parameters.

Properties
Name Type Description
type string

The event name.

data Object <optional>

The data associated with this event. This data object will contain the information being forwarded with the event.

(inner) off(nameopt, callbackopt)

All event removals across the viewer follow the pattern of this off function.

Parameters:
Name Type Attributes Description
name string <optional>

The name of the event being listened to. If a name is not provided, all event listeners attached to this object will be removed.

callback eventCallback <optional>

The original function used to register the event listener that should be disconnected. If this parameter is not defined, all functions registered to listen to the provided event name will be removed.

(inner) on(name, callback)

All event registrations across the viewer follow the pattern of this on function.

Parameters:
Name Type Description
name string

The event name.

callback eventCallback

The function to execute.

Events

AccessGlobalSettings

Indicates that the user needs to access the global settings dialog for modifying the various global settings available for the templates.

See:

AlignFields

Triggers alignment of the given fields.

Properties:
Name Type Description
alignment string

The plane and direction of the alignment operation.

markIds Array

An array of Mark IDs to align.

See:
Example
viewer.eventStore.trigger('AlignFields', {
    alignment: 'horizontal-left',
    markIds: viewer.viewerControl.getSelectedMarks()
});

BurnForm

Indicates that the user wants to burn the signatures to the form.

See:

CreateDate

Triggers a user request to select a date.

Properties:
Name Type Attributes Description
position Object

The position to locate the UI, relative to a rectangle on the window.

Properties
Name Type Description
x number

The x-axis location.

y number

The y-axis location.

width number

The width of the rectangle.

height number

The height of the rectangle.

onDone string <optional>

An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a date string as the event's data attribute.

See:

CreateSignature

Triggers a user request to apply a signature to a field.

Properties:
Name Type Attributes Description
category string <optional>

The field type that this signature belongs to. If undefined, no category will be assigned. Known values for this are signature and initials.

signatureType string <optional>

The type of signature being created, as represented by the target mark. Possible values are FreehandSignature and TextSignature. When this value is not defined, a good experience would be to allow the user to choose.

onDone string <optional>

An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a signature object as the data attribute with the data returned from PCCViewer.SignatureControl, or undefined to signal that the user cancelled the action.

See:

DeleteFields

Triggers deletion of the given fields.

Properties:
Name Type Description
markIds Array

An array of Mark IDs to delete.

See:
Example
viewer.eventStore.trigger('DeleteFields', {
    markIds: [1, 2, 3]
});

DeselectAllTemplateFields

Indicates that all previously selected fields are now deselected.

See:

DisplayForm

Indicates that a module:state-store~FormDefinition is available for displaying on the document.

Properties:
Name Type Description
formDefinition module:state-store~FormDefinition

Provides the form definition as the data parameter.

See:
Example
viewer.eventStore.on('DisplayForm', function(ev, formDefinition) {
    // logic to convert the form data to visible marks on the document
    createMarksForFormData(formDefinition.formData);
});

DuplicateFields

Triggers duplication of the given fields.

Properties:
Name Type Description
markIds Array

An array of Mark IDs to duplicate.

See:
Example
viewer.eventStore.trigger('DuplicateFields', {
    markIds: [1, 2, 3]
});

FocusChecklistItem

Indicates that an item in the checklist has been focused.

Properties:
Name Type Attributes Description
markId string <optional>

The ID of the mark that corresponds to the focused checklist item.

See:

FormatDate

Triggers a request to format a given date using the default format.

Properties:
Name Type Attributes Description
data Date

The Date object to convert to the signatureDateFormat. This format can be defined in the form definition. If signatureDateFormat is not defined, MM/DD/YYYY is used.

onDone string <optional>

An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a date string as the event's data attribute.

See:

FormCopied

Indicates that the current form has successfully been copied.

See:

FormLoaded

Indicates that a form has been loaded from the server.

See:

KeyCombinationsTriggered

Indicates that the user pressed the keyboard key combinations.

Properties:
Name Type Description
state string

This should always be defined as the string "KeyCombinationsTriggered".

stateValue Object

An object containing data about the key combination.

Properties
Name Type Description
keyCombinations string

A string property containing keyboard keyCombinations that were pressed by the user.

See:

ManageSignatures

Triggers a user request to manage signatures in a list.

Properties:
Name Type Attributes Description
category string <optional>

The field type that this signature belongs to. When defined, only the signatures belonging to that category should be displayed. If undefined, all known signatures should be displayed. Known values for this are signature and initials.

selectedSignature Object <optional>

An object, consisting of the signature data (as returned by PCCViewer.SignatureControl), defining the signature that the user has selected. Unless the user changes the signature, this data should be returned in the onDone event as the signature data.

onDone string <optional>

An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a signature object as the data attribute with the data returned from PCCViewer.SignatureControl, or undefined to signal that the user has removed the selected signature.

See:

MatchSizeFields

Triggers changing width or height depending on direction (horizontal/vertical) of all selected fields to match that dimension of a field, selected first.

Properties:
Name Type Description
markIds Array

An array of Mark IDs to apply the change to.

direction string

Determines which dimension (width or height) to change.

See:
Example
viewer.eventStore.trigger('MatchSizeFields', {
    markIds: [1, 2, 3],
    direction: 'vertical'
});

ModifyMultipleTemplateFields

Indicates that multiple template fields need to be modified.

Properties:
Name Type Description
markIds array

An array of currently selected Mark IDs.

See:

ModifyState

Indicates that a module or external code would like to modify a known state value. Generally, a module should not listen to this event. It is handled by StateStore, which will in turn fire module:event-store#event:StateModified, to notify all other modules that a new state value is available.

Properties:
Name Type Attributes Default Description
state string

The name of the state being modified.

stateValue *

The new value of the state.

operation string <optional>
"extend"

Specifies how the modification should occur. By default, any modification will extend the current state, merging any additional values from stateValue into the current state that is stored in the State Store. You can also specify "replace" as the operation value, causing the old state to be discarded, and the exact value of stateValue to become the current state.

See:

ModifyTemplateField

Indicates that a template field needs to be modified.

Properties:
Name Type Description
markId string

The ID of the mark that corresponds to the template field.

See:

Notify

Triggers a notification.

Properties:
Name Type Attributes Default Description
type String

The type of notification, either "error" or "success".

message String

The message of the notification.

displayTime Number <optional>
0

The amount of time (in milliseconds) to display the notification. If a positive number is not specified, then the notification is displayed until the user closes it.

See:
Example
viewer.eventStore.trigger('Notify', {
    type: 'error',
    message: 'An error occurred.'
});

PersistSignatures

Triggers a manual save of the signatures. It will save all signatures currently in the PCCViewer.Signatures collection.

See:

RegisterKeyCombinations

Requests registration of a new keyboard key combination.

Properties:
Name Type Description
state string

This should always be defined as the string "KeyCombinations".

stateValue Object

An object containing data about the key combination.

Properties
Name Type Description
keyCombinations string

Keyboard key combinations when pressed would trigger KeyCombinationsTriggered event.

See:

SaveTemplate

Indicates that the user needs to save the form template in its current state.

See:

SaveTemplateCopy

Indicates that the user needs to save a new copy of the form template in its current state. This event is implemented to convert the viewer into using the newly created copy when the copying is complete.

See:

SelectTemplateField

Indicates that a template field needs to be selected.

Properties:
Name Type Description
markId string

The ID of the mark that corresponds to the template field.

See:

StateModified

Indicates that a state value has been modified. This event should only be fired by the StateStore module. It has the following data properties:

Properties:
Name Type Description
state string

The name of the state that was modified.

stateValue *

The current value of the state that was modified.

See:
Example
viewer.eventStore.on('StateModified', function(ev, data){
    if (data.state !== 'MyStateKey') { return; }

    // handle the state change here
});

TemplateSaved

Indicates that a template successfully saved.

See:
Example
viewer.eventStore.trigger('TemplateSaved');

TemplateSaveFailed

Indicates that a template failed to save.

See:
Example
viewer.eventStore.trigger('TemplateSaveFailed');

ToggleChecklist

Triggers the checklist to toggle open or closed.

See: