Module: utils

Utils module.

Source:

Methods

(static) defaults(object, defaults) → {object}

Populates an object with defaults if the key is not yet defined. Similar to _.defaults except this takes only a single defaults object.

Parameters:
Name Type Description
object object

the object to populate defaults on

defaults object

the defaults to use

Source:
Returns:
Type
object

(static) getAppSelf(callback) → {undefined}

Get the App object returned from mozApps.getSelf()

Parameters:
Name Type Description
callback module:utils~getAppSelfCallback

the callback function.

Source:
Returns:
Type
undefined

(static) getCenteredCoordinates(w, h) → {list}

Gets the center coordinates for a passed width and height. Uses centering calcs that work on multiple monitors (bug 1122683).

Parameters:
Name Type Description
w number

width

h number

height

Source:
Returns:
Type
list

(static) getSelfOrigin() → {string}

Gets the app origin

Source:
Returns:
Type
string

(static) getUrlOrigin(url) → {string}

Gets the the origin of the URL provided.

Parameters:
Name Type Description
url string

the URL to introspect the origin from

Source:
Returns:
Type
string

(static) logDeprecation(msg, versionDeprecated) → {undefined}

Log a deprecation message with some extra info.

Parameters:
Name Type Description
msg string

log message

versionDeprecated string

the version when deprecated

Source:
Returns:
Type
undefined

(static) openWindow(optionsopt) → {object}

Open a window

Parameters:
Name Type Attributes Description
options object <optional>

the settings object

Properties
Name Type Attributes Description
url string <optional>

the window url

title string <optional>

the window title

w number <optional>

the window width

h number <optional>

the window height

Source:
Returns:

windowRef - a window reference.

Type
object

(static) reCenterWindow(winRef, wopt, hopt) → {undefined}

Re-center an existing window.

Parameters:
Name Type Attributes Description
winRef object

A reference to an existing window

w number <optional>

width

h number <optional>

height

Source:
Returns:
Type
undefined

(static) serialize(obj) → {string}

Take an object of key value pairs and serialize it into a url-encoded query string.

Parameters:
Name Type Description
obj object

object to serialize

Source:
Returns:
Type
string
Example
// returns foo=bar&baz=zup
utils.serialize({"foo": "bar", "baz": "zup"});

Type Definitions

getAppSelfCallback(error, appSelf)

The callback called by module:utils.getAppSelf

Parameters:
Name Type Description
error object

an error object. Will be null if no error.

appSelf object

the appSelf object

Source: