Class: XOpatElement

XOpatElement

Implements common interface for plugins and modules. Cannot be instantiated as it is hidden in closure. Private, but available in docs due to its API nature.

Constructor

(abstract) new XOpatElement()

Source:

Members

POSTStore

Source:

cache

Source:

id

Source:

uid

Source:

xoContext

Source:

Methods

addFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Source:

addHandler()

Add an event handler for a given event. See OpenSeadragon.EventSource::addHandler Note: noop if registerAsEventSource() not called.
Source:

addOnceHandler()

Add an event handler to be triggered only once (or X times). See OpenSeadragon.EventSource::addOnceHandler Note: noop if registerAsEventSource() not called.
Source:

applyFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Source:

error(e, notifyUser)

Raise error event. If the module did register as event source, it is fired on the item instance. Otherwise, it is fired on the VIEWER. todo better warn mechanism: -> simple way of module/plugin level context warns and errors (no feedback) -> advanced way of event warnings (feedback with E code)
Parameters:
Name Type Description
e
Properties
Name Type Description
code
message
error
notifyUser boolean fires error-user if true, error-system otherwise.
Source:

(async) exportData() → {Promise.<any>}

Called to export data within 'export-data' event: automatically the post data store object (returned from initPostIO()) is given the output of this method: `await dataStore.set(options.exportKey || "", await this.exportData());` note: for multiple objects, you can either manually add custom keys to the `dataStore` reference upon the event 'export-data', or simply nest objects to fit a single output
Source:
Returns:
Type
Promise.<any>

getHandler()

Get a function which iterates the list of all handlers registered for a given event, calling the handler for each. See OpenSeadragon.EventSource::getHandler Note: noop if registerAsEventSource() not called.
Source:

getLocaleFile(locale) → {string}

Relative locale file location as locales/[locale].json. Override for custom locales file location.
Parameters:
Name Type Description
locale
Source:
Returns:
relative file path
Type
string

(async) importData(data)

Called automatically within this.initPostIO if data available note: parseImportData return value decides if data is parsed data or passed as raw string
Parameters:
Name Type Description
data string | * data
Source:

(async) initPostIO(optionsnullable) → {PostDataStore}

Initialize IO in the Element - enables use of export/import functions
Parameters:
Name Type Attributes Description
options XOpatStorage.StorageOptions <nullable>
where id value is ignored (overridden)
Properties
Name Type Attributes Default Description
exportKey string <optional>
<nullable>
"" optional export key for the globally exported data through exportData
Source:
Returns:
data store reference, or false if import failed
Type
PostDataStore

integrateWithSingletonModule(moduleId, callback) → {boolean}

TODO: this does not wait once module is fully loaded!
Parameters:
Name Type Description
moduleId
callback
Source:
Returns:
true if finished immediatelly, false if registered handler for the future possibility of the module being loaded
Type
boolean

numberOfHandlers()

Get the amount of handlers registered for a given event. See OpenSeadragon.EventSource::numberOfHandlers Note: noop if registerAsEventSource() not called.
Source:

raiseAwaitEvent()

Trigger an event, optionally passing additional information. See OpenSeadragon.EventSource::raiseAwaitEvent. Awaits async handlers. Note: noop if registerAsEventSource() not called.
Source:

raiseEvent()

Trigger an event, optionally passing additional information. See OpenSeadragon.EventSource::raiseEvent Note: noop if registerAsEventSource() not called.
Source:

registerAsEventSource()

Set the element as event-source class. Re-uses EventSource API from OpenSeadragon.
Source:

removeAllHandlers()

Remove all event handlers for a given event type. See OpenSeadragon.EventSource::removeAllHandlers Note: noop if registerAsEventSource() not called.
Source:

removeFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Source:

removeHandler()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Source:

t(key, options) → {*}

Translate the string in given element context
Parameters:
Name Type Description
key
options
Source:
Returns:
Type
*

warn(e, notifyUser)

Raise warning event. If the module did register as event source, it is fired on the item instance. Otherwise, it is fired on the VIEWER. todo better warn mechanism: -> simple way of module/plugin level context warns and errors (no feedback) -> advanced way of event warnings (feedback with E code)
Parameters:
Name Type Description
e
Properties
Name Type Description
code
message
error
notifyUser boolean fires error-user if true, error-system otherwise.
Source:

Events

error-system

Raise event from instance. Instances that register as event source fire on themselves.
Properties:
Name Type Description
originType string `"module"`, `"plugin"` or other type of the source
originId string
Source:

warn-system

Raise event from instance. Instances that register as event source fire on themselves.
Properties:
Name Type Description
originType string `"module"`, `"plugin"` or other type of the source
originId string
Source: