Class: XOpatPlugin

XOpatPlugin

xOpat Plugin API. Plugins must have a parent class that is registered and inherits from XOpatPlugin. JS String to use in DOM callbacks to access self instance.

Constructor

new XOpatPlugin()

Source:

Extends

Members

POSTStore

Overrides:
Source:

THIS :string

JS String to use in DOM callbacks to access self instance.
Type:
string
Source:

cache

Overrides:
Source:

id

Overrides:
Source:

uid

Overrides:
Source:

xoContext

Overrides:
Source:

Methods

addFilter()

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

addHandler()

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

addOnceHandler()

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

applyFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Overrides:
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.
Overrides:
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
Overrides:
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.
Overrides:
Source:

getLocaleFile(locale) → {string}

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

getOption(key, defaultValue, cache) → {*}

Read the plugin online configuration parameters/options. The defaultValue is read from a static configuration if not provided. Note that this behavior will read static values such as 'permaLoad', 'includes' etc..
Parameters:
Name Type Default Description
key string
defaultValue *
cache boolean true
Source:
Returns:
Type
*

getOptionOrConfiguration(optKey, staticKey, defaultValue, cache)

Read plugin configuration value - either from a static configuration or dynamic one. More generic function that reads any option available (configurable via dynamic JSON or include.json)
Parameters:
Name Type Default Description
optKey string dynamic param key, overrides anything
staticKey string static param key, used if dynamic value is undefined
defaultValue any
cache boolean true
Source:

getStaticMeta(metaKey, defaultValue) → {undefined|*}

Read static metadata - include.json contents and additional meta attached at runtime
Parameters:
Name Type Description
metaKey key to read
defaultValue
Source:
Returns:
Type
undefined | *

(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
Overrides:
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
Overrides:
Source:
Returns:
data store reference, or false if import failed
Type
PostDataStore

integrateWithPlugin(pluginId, callback) → {boolean}

To simplify plugin interaction, you can register a callback executed when a certain plugin gets loaded into the system.
Parameters:
Name Type Description
pluginId string
callback function that receives the plugin instance
Source:
Returns:
true if finished immediatelly, false if registered handler for the future possibility of plugin being loaded
Type
boolean

integrateWithSingletonModule(moduleId, callback) → {boolean}

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

(async) loadLocale(locale, data)

Load localization data
Parameters:
Name Type Description
locale the current locale if undefined
data possibly custom locale data if not fetched from a file
Source:

numberOfHandlers()

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

(async) pluginReady()

Function called once a viewer is fully loaded
Source:

raiseAwaitEvent()

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

raiseEvent()

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

registerAsEventSource()

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

removeAllHandlers()

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

removeFilter()

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

removeHandler()

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

setLocalOption(key, value)

Ability to cache a value locally into the browser, the value can be retrieved using this.getOption(...) todo rename to setCacheOption
Parameters:
Name Type Description
key
value
Source:

setOption(key, value, cache)

Store the plugin online configuration parameters/options todo: options are not being documented, enforce
Parameters:
Name Type Default Description
key string
value *
cache boolean true
Source:

t(key, options) → {*}

Translate the string in given element context
Parameters:
Name Type Description
key
options
Overrides:
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.
Overrides:
Source: