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 |
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
|
|||||||
data |
Object | <optional> |
The data associated with this event. This |
(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.
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. |
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.
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
|
||||||||||||||||
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 |
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 |
signatureType |
string | <optional> |
The type of signature being created, as represented by the target mark. Possible values are |
onDone |
string | <optional> |
An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a signature object as the |
DeleteFields
Triggers deletion of the given fields.
Properties:
Name | Type | Description |
---|---|---|
markIds |
Array |
An array of Mark IDs to delete. |
Example
viewer.eventStore.trigger('DeleteFields', {
markIds: [1, 2, 3]
});
DeselectAllTemplateFields
Indicates that all previously selected fields are now deselected.
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. |
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. |
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. |
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 |
- See:
FormCopied
Indicates that the current form has successfully been copied.
FormLoaded
Indicates that a form has been loaded from the server.
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
|
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 |
selectedSignature |
Object | <optional> |
An object, consisting of the signature data (as returned by |
onDone |
string | <optional> |
An event name to trigger, in the style of module:event-store~onDoneCallback. It should provide a signature object as the |
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. |
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. |
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 |
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. |
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. |
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.
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
|
SaveTemplate
Indicates that the user needs to save the form template in its current state.
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.
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. |
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. |
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.
Example
viewer.eventStore.trigger('TemplateSaved');
TemplateSaveFailed
Indicates that a template failed to save.
Example
viewer.eventStore.trigger('TemplateSaveFailed');
ToggleChecklist
Triggers the checklist to toggle open or closed.