Methods to get, set, load, and save settings for FCOOs applications
bower install https://github.com/FCOO/fcoo-settings.git --save
http://FCOO.github.io/fcoo-settings/demo/ (see control panel)
In namespace window.fcoo
two object are created:
fcoo.globalSetting //Contains all global settings (language, date-format etc.)
fcoo.appSetting //Contains the setting for the current application
options = {id, applyFunc, validator, defaultValue, onError )
id [String]
: The id for the settingapplyFunc [Function( value )]
: Called when the value of settingid
is changed. Used to change elements etc. on the page with the new settingvalidator
(optional): See fcoo/url.js-extensions.defaultValue [any]
(optional): Used if no value was found inlocalStorage
callApply [Boolean]
(optional) default=true: If true theapplyFunc
is called when the setting is addedglobalEvents
(optional): Name(s) of events defined in fcoo/fcoo-global-events to be fired when the setting is changed.saveOnChanging [BOOLEAN]
. If true the setting is saved during editing. When false the setting is only saved when edit-form submitsonError [Function( value, id )]
(optional): Called if a new value is invalid according to validatormodernizr BOOLEAN
(optional) default=false: If true the modernizr-class descriped insrc\_fcoo-settings.scss
is updatedmodernizrOnlyValues []ID
: List of the only values that are modernizr'ed. If empty all values are modernizr
Sets the value for settings ID
If value
is undefined
=> use the saved value
The applyFunc
is called with the new value
Return the current value (any type) of settings for id
Load the setting's data from indexedDB
id
(optional) Load a different data-set
load()
is called on loading the page, and normally it would not need to be called again
Save the settings to indexedDB
Save the settings to indexedDB
with a new id
Delete the settings with id or default-id from indexedDB
To allow the user to edit the global settings the following methods are defined to retrieve and display the modal.
The modal contain an accordion with e card for each of the global events in fcoo/fcoo-global-events
The different "Administrator" (see FCOO/fcoo-web-application-settings) will provide the content for each accordion card by calling fcoo.settings.addModalContent(globalEventId, content)
The modal is displayed by calling fcoo.globalSetting.edit()
Add content to for accordion card with id
and content
as array of bsOptions
(see FCOO/jquery-bootstrap)
Create and display the modal-window with edit-fields for the different groups given by the global events
If id
is given the card with the id is open by default
This plugin is licensed under the MIT license.
Copyright (c) 2016 FCOO
Niels Holt [email protected]