Load, save and apply options to HTML options page.
- Source:
Members
(inner) RUN_ALL_SAFE_TRIGGER :Symbol
- Source:
Denotes to run all the currently registered save trigger.
These do not include the triggers that override the save functions.
Type:
- Symbol
Methods
(inner) addCustomLoadOverride(optionTrigger, callback) → {void}
- Source:
Registers a load trigger for special handling when loading an option.
The trigger get the values (optionValue, option, …) passed as parameters.
See overrideLoad
for details.
Usually there should only be one of these triggers.
Parameters:
Name | Type | Description |
---|---|---|
optionTrigger |
string | |
callback |
overrideLoad |
Returns:
- Type
- void
(inner) addCustomSaveOverride(optionTrigger, callback) → {void}
- Source:
Registers a save trigger for special handling when saving an option.
The trigger get the values (optionValue, option) passed as parameters.
See overrideSave
for details.
Usually there should only be one of these triggers.
Parameters:
Name | Type | Description |
---|---|---|
optionTrigger |
string | |
callback |
overrideSave |
Returns:
- Type
- void
(inner) overrideContinue(optionValueopt, optionopt, elOptionopt) → {Object}
- Source:
Call this and return the return value if you want to continue saving or
loading some data in the overrideSave
or overrideLoad
trigger at the end.
If you return any other value, it is expected that you saved all the data on your own.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
optionValue |
Object |
<optional> |
if omitted, the original option value will be used |
option |
string |
<optional> |
if omitted, the current option name wil be used |
elOption |
HTMLElement |
<optional> |
overwrite HTML element to modify, only possible when this is called from a load overwrite trigger. |
Returns:
- Type
- Object
(inner) registerAfterLoad(callback) → {void}
- Source:
Registers an afterLoad trigger.
This trigger is executed after the options have been loaded.
You can pass the special option RUN_ALL_SAFE_TRIGGER
to this to register
a trigger for all the triggers registered via registerSave
.
This is a common scenario when you modify your GUI in the save triggers and want
it to be up-to-date/displayed correctly when the options page is first opened/the
options are loaded.
Parameters:
Name | Type | Description |
---|---|---|
callback |
afterLoadTrigger | RUN_ALL_SAFE_TRIGGER |
Returns:
- Type
- void
(inner) registerBeforeLoad(callback) → {void}
- Source:
Registers an beforeLoad trigger.
This trigger is executed before the options are loaded. You can e.g. use it to reset some display styles that may have been changed by one of your other callbacks, as this is e.g. also called when the user manually resets the options. (i.e. they are reloaded then).
Parameters:
Name | Type | Description |
---|---|---|
callback |
beforeLoadTrigger |
Returns:
- Type
- void
(inner) registerChange(optionTrigger, callback) → {void}
- Source:
Registers an change trigger.
This trigger is executed, when the option value is changed by the user, but not (necessarily) saved. Internally, it binds to the "input" event.
Parameters:
Name | Type | Description |
---|---|---|
optionTrigger |
string | |
callback |
onChangeTrigger |
Returns:
- Type
- void
(inner) registerSave(optionTrigger, callback) → {void}
- Source:
Registers a save trigger.
The trigger get the values (optionValue, option) passed as parameters.
See saveTrigger
for details.
Parameters:
Name | Type | Description |
---|---|---|
optionTrigger |
string | |
callback |
saveTrigger |
Returns:
- Type
- void
(inner) registerUpdate(optionTrigger, callback) → {void}
- Source:
Registers an update trigger.
This trigger is executed, when the option value is updated by the user, and thus, usually saved. However, it does not get the new value yet. The trigger get the values (optionValue, option, event) passed as parameters.
Parameters:
Name | Type | Description |
---|---|---|
optionTrigger |
string | |
callback |
onUpdateTrigger |
Returns:
- Type
- void
(inner) unregisterAll() → {void}
- Source:
Reset all registered triggers/callbacks.
Returns:
- Type
- void