diff options
author | Rogan Creswick <creswick@gmail.com> | 2013-01-02 14:56:40 -0800 |
---|---|---|
committer | Rogan Creswick <creswick@gmail.com> | 2013-01-02 14:56:40 -0800 |
commit | 75139375b76cb277546da2429d8e983ca6758f61 (patch) | |
tree | 5b8d180f5f6dc9809eeec1612726a1de36cb7365 /tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md | |
parent | dbf076b39ca655500f2c0546b0ea57ceffca33b3 (diff) |
added addon-sdk-1.7, without any changes
Diffstat (limited to 'tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md')
-rw-r--r-- | tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md b/tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md new file mode 100644 index 0000000..b3cd076 --- /dev/null +++ b/tools/addon-sdk-1.7/packages/addon-kit/docs/simple-prefs.md @@ -0,0 +1,75 @@ +<!-- This Source Code Form is subject to the terms of the Mozilla Public + - License, v. 2.0. If a copy of the MPL was not distributed with this + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> + +<!-- contributed by Erik Vold [erikvvold@gmail.com] --> + +#### *Experimental* + +The `simple-prefs` module lets you easily and persistently store preferences +across application restarts, which can be configured by users in the +Add-ons Manager. + +Introduction +------------ + +With the simple preferences module you can store booleans, integers, and string +values. + + +Inline Options & Default Values +------------------------------- + +In order to have a `options.xul` (for inline options) generated, or a +`defaults/preferences/prefs.js` for default preferences, you will need to +define the preferences in your `package.json`, like so: + + { + "fullName": "Example Add-on", + ... + "preferences": [{ + "name": "somePreference", + "title": "Some preference title", + "description": "Some short description for the preference", + "type": "string", + "value": "this is the default string value" + }] + } + + +<api name="prefs"> +@property {object} + *experimental* A persistent object private to your add-on. Properties with boolean, + number, and string values will be persisted in the Mozilla preferences system. +</api> + + +<api name="on"> +@function + *experimental* Registers an event `listener` that will be called when a preference is changed. + +**Example:** + + function onPrefChange(prefName) { + console.log("The " + prefName + " preference changed."); + } + require("simple-prefs").on("somePreference", onPrefChange); + require("simple-prefs").on("someOtherPreference", onPrefChange); + + +@param prefName {String} + The name of the preference to watch for changes. +@param listener {Function} + The listener function that processes the event. +</api> + +<api name="removeListener"> +@function + *experimental* Unregisters an event `listener` for the specified preference. + +@param prefName {String} + The name of the preference to watch for changes. +@param listener {Function} + The listener function that processes the event. +</api> + |