Map

Singleton class for mapping Controllers to pages and/or DOM elements.

Example

// sample JSON sitemap
sample.SiteMap = [
{pattern: "#menu-navigation",
controllers: [
{controller: "sample.controller.MenuController", params: {selected: 0}}
]},
{pattern: "home.htm",
controllers: [
{controller: "sample.controller.HomeController"}
]}
]
// map controllers to Mojo application
var sampleApp = mojo.controller.Map.getInstance();
sampleApp.setSiteMap(sample.SiteMap);
sampleApp.mapControllers(window.location.href);
Summary
Singleton class for mapping Controllers to pages and/or DOM elements.
This event fires when the mapping of controllers completes.
Creates an instance of the mojo.controller.Map class.
Retrieves the JSON sitemap associated with the application.
Sets the JSON sitemap for the application.
Traverses the associated SiteMap configuration, and maps Controllers to pages and/or DOM elements.
Initializes a controller, and associates it with a specified context.
Static function.
Static function.

Events

onComplete

This event fires when the mapping of controllers completes.

Functions

constructor

constructor: function()

Creates an instance of the mojo.controller.Map class.

getSiteMap

getSiteMap: function()

Retrieves the JSON sitemap associated with the application.

Returns

{object} siteMapObj

Example

// get instance of mojo.controller.Map
var map = mojo.controller.Map.getInstance();
var sitemap = map.getSiteMap();

setSiteMap

setSiteMap: function(siteMapObj)

Sets the JSON sitemap for the application.

Parameters

siteMapObj{object}

Example

//See above for sample implementation usage.

mapControllers

mapControllers: function(mapContextObj)

Traverses the associated SiteMap configuration, and maps Controllers to pages and/or DOM elements.

Parameters

mapContextObj{string | object} (optional)

Example

//See above for sample implementation usage.

mapController

mapController: function(controllerName,
contextElementObj,
controllerParams)

Initializes a controller, and associates it with a specified context.

Parameters

controllerName{string}
contextElementObj{DOMElement} (optional)

mapControllers

mojo.controller.Map.mapControllers = function(mapContextObj)

Static function.  Re-maps controllers based on the associated SiteMap

Parameters

mapContextObj{object} (optional)

Example

// re-map controllers
mojo.controller.Map.mapControllers();

getInstance

mojo.controller.Map.getInstance = function()

Static function.  Returns the instance of the mojo.controller.Map singleton object

Returns

{object} mojo.controller.Map object

Example

// get instance of mojo.controller.Map
var map = mojo.controller.Map.getInstance();
constructor: function()
Creates an instance of the mojo.controller.Map class.
getSiteMap: function()
Retrieves the JSON sitemap associated with the application.
setSiteMap: function(siteMapObj)
Sets the JSON sitemap for the application.
mapControllers: function(mapContextObj)
Traverses the associated SiteMap configuration, and maps Controllers to pages and/or DOM elements.
mapController: function(controllerName,
contextElementObj,
controllerParams)
Initializes a controller, and associates it with a specified context.
mojo.controller.Map.getInstance = function()
Static function.