Class: SettingsPlugin

PSV.plugins.SettingsPlugin

new PSV.plugins.SettingsPlugin (psv, options)

Adds a button to access various settings.

Name Type Description
psv PSV.Viewer
options PSV.plugins.SettingsPlugin.Options

Extends

Members

PSV.plugins.SettingsPlugin.EVENTS string staticconstant

Available events

PSV.plugins.SettingsPlugin.TYPE_OPTIONS string staticconstant

PSV.plugins.SettingsPlugin.TYPE_TOGGLE string staticconstant

id string readonly inherited overrides

Unique identifier of the plugin

Reference to main controller

Methods

addSetting (setting)

Registers a new setting

Name Type Description
setting PSV.plugins.SettingsPlugin.Setting

applySettingOption (setting, optionId) package

Changes the value of an setting

Name Type Description
setting PSV.plugins.SettingsPlugin.OptionsSetting
optionId string

destroy () package overrides

hideSettings ()

Hides the settings menu

init () package overrides

removeSetting (id)

Removes a setting

Name Type Description
id string

showSettings ()

Shows the settings menu

toggleSettings ()

Toggles the settings menu

toggleSettingValue (setting) package

Toggles a setting

Name Type Description
setting PSV.plugins.SettingsPlugin.ToggleSetting

updateButton ()

Updates the badge in the button

Type Definitions

PSV.plugins.SettingsPlugin.Option Object

Option of an 'option' setting

Properties:
Name Type Description
id string

identifier of the option

label string

label of the option

PSV.plugins.SettingsPlugin.Options Object

Properties:
Name Type Argument Default Description
persist boolean <optional>
false

should the settings be saved accross sessions

storage Object <optional>

custom storage handler, defaults to LocalStorage

Properties
Name Type Argument Description
get PSV.plugins.SettingsPlugin.StorageGetter <optional>
set PSV.plugins.SettingsPlugin.StorageSetter <optional>

PSV.plugins.SettingsPlugin.OptionsSetting PSV.plugins.SettingsPlugin.Setting

Description of a 'options' setting

Properties:
Name Type Description
type 'options'

type of the setting

current function

function which returns the current option id

options function

function which the possible options as an array of PSV.plugins.SettingsPlugin.Option

apply function

function called with the id of the selected option

PSV.plugins.SettingsPlugin.Setting Object

Description of a setting

Properties:
Name Type Argument Description
id string

identifier of the setting

label string

label of the setting

type 'options' | 'toggle'

type of the setting

badge function <optional>

function which returns the value of the button badge

PSV.plugins.SettingsPlugin.StorageGetter (settingId)boolean | string | Promise.<(boolean|string)>

Name Type Description
settingId string
Returns:
Type Description
boolean | string | Promise.<(boolean|string)>
  • return undefined or null if the option does not exist

PSV.plugins.SettingsPlugin.StorageSetter (settingId, value)

Name Type Description
settingId string
value boolean | string

PSV.plugins.SettingsPlugin.ToggleSetting PSV.plugins.SettingsPlugin.Setting

Description of a 'toggle' setting

Properties:
Name Type Description
type 'toggle'

type of the setting

active function

function which return whereas the setting is active or not

toggle function

function called when the setting is toggled

Events

PSV.plugins.SettingsPlugin.event:setting-changed

Triggered when a setting is changed

Name Type Description
settingId string
value any