Class Index

Classes


Class gadgets.Prefs

Provides access to user preferences, module dimensions, and messages. Clients can access their preferences by constructing an instance of gadgets.Prefs and passing in their module id. Example:

var prefs = new gadgets.Prefs();
var name = prefs.getString("name");
var lang = prefs.getLang();

Defined in: gadgets.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new Prefs object.
Method Summary
Method Attributes Method Name and Description
 
getArray(key)
Retrieves a preference as an array.
 
getBool(key)
Retrieves a preference as a boolean.
 
Gets the current country, returned as ISO 3166-1 alpha-2 code.
 
getFloat(key)
Retrieves a preference as a floating-point value.
 
getInt(key)
Retrieves a preference as an integer.
 
Gets the current language the gadget should use when rendering, returned as a ISO 639-1 language code.
 
Gets the module id for the current instance.
 
getMsg(key)
Fetches an unformatted message.
 
getString(key)
Retrieves a preference as a string.
 
set(key, val)
Stores a preference.
 
setArray(key, val)
Stores an array preference.
<static>  
gadgets.Prefs.setInternal_(key, value)
Sets internal values
<static>  
gadgets.Prefs.setMessages_(messages)
Initializes message bundles.
Class Detail
gadgets.Prefs()
Creates a new Prefs object. Note: this is actually a singleton. All prefs are linked. If you're wondering why this is a singleton and not just a collection of package functions, the simple answer is that it's how the spec is written. The spec is written this way for legacy compatibility with igoogle.
Method Detail
{Array.<String>} getArray(key)
Retrieves a preference as an array. UserPref values that were not declared as lists are treated as one-element arrays.
Parameters:
{String} key
The preference to fetch
Returns:
{Array.<String>} The preference; if not set, an empty array

{Boolean} getBool(key)
Retrieves a preference as a boolean.
Parameters:
{String} key
The preference to fetch
Returns:
{Boolean} The preference; if not set, false

{String} getCountry()
Gets the current country, returned as ISO 3166-1 alpha-2 code.
Returns:
{String} The country for this module instance

{Number} getFloat(key)
Retrieves a preference as a floating-point value.
Parameters:
{String} key
The preference to fetch
Returns:
{Number} The preference; if not set, 0

{Number} getInt(key)
Retrieves a preference as an integer.
Parameters:
{String} key
The preference to fetch
Returns:
{Number} The preference; if not set, 0

{String} getLang()
Gets the current language the gadget should use when rendering, returned as a ISO 639-1 language code.
Returns:
{String} The language for this module instance

{String | Number} getModuleId()
Gets the module id for the current instance.
Returns:
{String | Number} The module id for this module instance

{String} getMsg(key)
Fetches an unformatted message.
Parameters:
{String} key
The message to fetch
Returns:
{String} The message

{String} getString(key)
Retrieves a preference as a string. Returned value will be html entity escaped.
Parameters:
{String} key
The preference to fetch
Returns:
{String} The preference; if not set, an empty string

set(key, val)
Stores a preference. To use this call, the gadget must require the feature setprefs.

Note: If the gadget needs to store an Array it should use setArray instead of this call.

Parameters:
{String} key
The pref to store
{Object} val
The values to store

setArray(key, val)
Stores an array preference. To use this call, the gadget must require the feature setprefs.
Parameters:
{String} key
The pref to store
{Array} val
The values to store

<static> gadgets.Prefs.setInternal_(key, value)
Sets internal values
Parameters:
key
value

<static> gadgets.Prefs.setMessages_(messages)
Initializes message bundles.
Parameters:
messages

Documentation generated by JsDoc Toolkit 2.0.2 on Wed Nov 12 2008 12:35:37 GMT-0800 (PST)