# Fusion

This is the top-level namespace of the Fusion library

Summary

Fusion | This is the top-level namespace of the Fusion library
Constants |
UNKNOWN | An unknown unit
INCHES | Inch unit
FEET | Feet unit
YARDS | Yard unit
MILES | Mile unit
NAUTICALMILES | Nautical Mile unit
MILLIMETERS | Millimeter unit
CENTIMETERS | Centimeter unit
METERS | Meter unit
KILOMETERS | Kilometer unit
DEGREES | Degree unit
DECIMALDEGREES | Decimal Degree unit
DMS | DMS unit
PIXELS | Pixel unit
Functions and Properties |
initialize | Initialize the Fusion application.
initializeLocale | Initialize the Strings hash with the requested locale.
setLoadState | set the current initialization state of the application.
loadQueuedScripts | load any scripts that have been queued for loading.
queueScript | Insert a new script into the loading queue.
scriptFailed | Called when a script fails to load for some reason.
scriptLoaded | a script has loaded.
checkLoadingScripts | check if scripts have loaded.
loadConfig | asynchronously load the application definition.
getConfigCB | the server has returned the application configuration file that contains enough information to bootstrap the application.
serverSet | the server has returned the application configuration file that contains enough information to bootstrap the application.
serverFailed | the application failed to load the application configuration file.
ajaxRequest | convenience function to issue an {XmlHttpRequest} to the server relative to the Fusion installation.
ajaxException | trap exceptions produced in handling an ajax response.
getXmlAsJson | Convert XML to JSON using a server-side script for requests that aren’t available in JSON.
parseJSON | Parses the given JSON string to a javascript object.
trim | Utility function to trim a given string of any trailing whitespace
xml2json | Callback method to convert the XHR response into an actual json object and triggers the call to the callback method
getMapByName | return a map widget with the given name
getMapById | return a map widget that is associated with the given DOM element by id.
getMapByIndice | return the map widget at the given index if there are more than one map elements specified in the AppDef
getWidgetById | return a reference to a widget by the id of the DOM Element that it was created in.
getApplicationURL | returns the applicaiton’s absolute URL minus the filename.html part
getFusionURL | returns the application’s absolute URL minus the filename.html part
getConfigurationItem | returns individual elements out of the Fusion config.json file
getScriptLanguage | Accessor to return the server-side script language
getRedirectScript | Accessor to return the URL of the redirect script
getBroker | Accessor to return the broker object (for MapGuide only).
require | Marks a JavaScript file as required which puts it into the queue for loading during Fusion initialization.
reportFatalError | Triggers the <Fusion.Event.FUSION_ERROR> and passes along a <Fusion.DetailedError> object to the callback functions registered for this event.
reportError | Triggers the <Fusion.Event.FUSION_ERROR> and passes along the error object to the callback functions registered for this event.
unitFromName | returns index into the units array for the given unit name or abbreviation
unitSystem | imperial, metric, degrees or device units
unitName | Given a unit, this method returns the units name
unitAbbr | Given a unit, this method returns the units abbreviation
toMeter | Converts a length value from native units into meters.
fromMeter | Converts a length value from meters into native units.
convert | Converts a length value from one unit system into another.
initUnits | initializes the meters per unit values when a new map is loaded.
getClosestUnits | find the OpenLayers units identifier given the Fusion metersPerUnit value
addWidgetStyleSheet | Dynamically load a CSS stylesheet.
parseQueryString | An initialization time function to parse the application URL parameters and stores them in an array.
getQueryParam | Returns the query parameter value for a given parameter name
_scriptName | {String} Relative path of this script.
_getScriptLocation | Return the path to this script for bootstrapping Fusion.
createSessionId | Pre-create a session to avoid the 401 Unauthorized dialog

### Constants

### UNKNOWN

An unknown unit

### INCHES

Inch unit

### FEET

Feet unit

### YARDS

Yard unit

### MILES

Mile unit

### NAUTICALMILES

Nautical Mile unit

### MILLIMETERS

Millimeter unit

### CENTIMETERS

Centimeter unit

### METERS

Meter unit

### KILOMETERS

Kilometer unit

### DEGREES

Degree unit

### DECIMALDEGREES

Decimal Degree unit

### DMS

DMS unit

### PIXELS

Pixel unit

### Functions and Properties

### initialize

> initialize: function( | options | )

Initialize the Fusion application. This method must be called from the template’s onload method once all script files have been loaded. Applications can register for the event {<Fusion.Event.FUSION_INITIALIZED>} to carry out further application initialization when all the Fusion objects have been created and are available.

#### Valid optional parameters that can be passed include

{String} applicationDefinitionURL: a URL or resource ID for an ApplicationDefinition file

{String} sessionId: a session id to start the application with. Normally, applications are started without a session id and create one. However, sometimes it is desirable to use an existing session.

#### Parameters

options | {Object} Optional parameters

### initializeLocale

> initializeLocale: function( | locale | )

Initialize the Strings hash with the requested locale. This method simply extends the OpenLayers strings hash with strings specific to Fusion. Add strings to the files in fusion/text/[locale].json. This method can be called before Fusion.initialize if localized strings are required in the template initialization.

#### Parameters

locale | {String} the locale value e.g. ‘en-CA’ or simply ‘en’ for English

### setLoadState

> setLoadState: function( | state | )

set the current initialization state of the application. Depending on the state, this will cause various scripts to be loaded.

#### Parameters

state | {Integer} the new loading state

### loadQueuedScripts

> loadQueuedScripts: function()

load any scripts that have been queued for loading. As the scripts load, they are removed. When all queued scripts have been loaded, the load state is advanced. If any of the loaded scripts require other scripts (for inheritance), they will be queued and loaded before the load state is advanced.

### queueScript

> queueScript: function( | url | )

Insert a new script into the loading queue. The URL should be relative to the Fusion base url. The script will not actually be loaded until Fusion.loadQueuedScripts is called.

#### Parameters

url | {String} The url of the script.

### scriptFailed

> scriptFailed: function( | url | )

Called when a script fails to load for some reason.

#### Parameters

url | {String} the url that failed to load

TODO: the application probably won’t work if a script fails to load so we need to decide how to inform the user and fail gracefully.

### scriptLoaded

> scriptLoaded: function( | url | )

a script has loaded. It is removed from the various tracking arrays. When all requested scripts have been loaded, we check to see if any scripts where required by the ones just loaded. If yes, then we Fusion.loadQueuedScripts again, otherwise we advance the load state.

#### Parameters

url | {String} the url of the script that was loaded.

### checkLoadingScripts

> checkLoadingScripts: function()

check if scripts have loaded. In IE, scripts don’t seem to fire the onload event. Safari also seems to have some problems.

### loadConfig

> loadConfig: function()

asynchronously load the application definition. For MapGuide, also set up the broker object. Once the AppDef is loaded/created advance the load state.

### getConfigCB

> getConfigCB: function( | r | )

the server has returned the application configuration file that contains enough information to bootstrap the application.

#### Parameters

r | {XMLHttpRequest} an XMLHttpRequest object

### serverSet

> serverSet: function()

the server has returned the application configuration file that contains enough information to bootstrap the application.

#### Parameters

r | {XMLHttpRequest} an XMLHttpRequest object

### serverFailed

> serverFailed: function( | r | )

the application failed to load the application configuration file. Not much point in continuing, but we can inform the user why this happened.

#### Parameters

r | {XMLHttpRequest} the XMLHttpRequest object

TODO: do something more useful in here?

### ajaxRequest

> ajaxRequest: function( | scriptURL,
> | options | )

convenience function to issue an {XmlHttpRequest} to the server relative to the Fusion installation.

#### Parameters

scriptURL | {String} the URL (relative to Fusion) to request
options | {Object} optional parameters to send with the request, passed directly to the <OpenLayers Ajax.Request> function

### ajaxException

> ajaxException: function( | r,
> | e | )

trap exceptions produced in handling an ajax response.

#### Parameters

r | {XmlHttpRequest}
e | {Exception}

### getXmlAsJson

> getXmlAsJson: function( | url,
> | callback | )

Convert XML to JSON using a server-side script for requests that aren’t available in JSON.

#### Parameters

url | {String} the URL of the XML object to be converted; this can be any URL and is not prepended with the Fusion URL
callback | {Function} a callback function to be called if the request is successful

boolean indicator if the content is JSON or not.

### parseJSON

> parseJSON: function( | str | )

Parses the given JSON string to a javascript object. This is safer than using eval() as there is no possibility of arbitrary code execution

#### Parameters

str | {String} The JSON string to parse

### trim

> trim: function( | str | )

Utility function to trim a given string of any trailing whitespace

### xml2json

> xml2json: function( | callback,
> | r,
> | json | )

Callback method to convert the XHR response into an actual json object and triggers the call to the callback method

#### Parameters

callback | {Function} callback method to be executed on success and will be passed a parsed json object
r | {XmlHttpRequest} the XmlHttpRequest object
json | {Boolean} boolean indicator if the content is JSON or not (set by OpenLayers)

### getMapByName

> getMapByName: function( | name | )

return a map widget with the given name

#### Parameters

name | {String} The map name to return

#### Return

{Fusion.Widget.Map} a map object or null if not found.

### getMapById

> getMapById: function( | id | )

return a map widget that is associated with the given DOM element by id.

#### Parameters

id | {String} The map id to return

#### Return

{Fusion.Widget.Map} a map object or null if not found.

### getMapByIndice

> getMapByIndice: function( | indice | )

return the map widget at the given index if there are more than one map elements specified in the AppDef

#### Parameters

indice | {String} The map indice to return

#### Return

{Fusion.Widget.Map} a map object or null if not found.

### getWidgetById

> getWidgetById: function( | id | )

return a reference to a widget by the id of the DOM Element that it was created in.

#### Parameters

id | {String} the DOM id to get the widget for

#### Return

{Fusion.Widget} the widget or null

### getApplicationURL

> getApplicationURL: function()

returns the applicaiton’s absolute URL minus the filename.html part

#### Return

{String} a URL

### getFusionURL

> getFusionURL: function()

returns the application’s absolute URL minus the filename.html part

#### Return

{String} a URL

### getConfigurationItem

> getConfigurationItem: function( | arch,
> | key | )

returns individual elements out of the Fusion config.json file

#### Parameters

arch | {String} the server architecture (mapguide or mapserver)
key | {String} the config item to be returned

#### Return

{String} a the value for the key of null if not found

### getScriptLanguage

> getScriptLanguage: function()

Accessor to return the server-side script language

#### Return

{String} the script language e.g. ‘php’

### getRedirectScript

> getRedirectScript: function()

Accessor to return the URL of the redirect script

#### Return

{String} a URL

### getBroker

> getBroker: function()

Accessor to return the broker object (for MapGuide only). The broker is used to prepare various queries to the MapGuide server.

#### Return

{Fusion.Lib.MGBroker} the broker object

### require

> require: function( | url | )

Marks a JavaScript file as required which puts it into the queue for loading during Fusion initialization. Widget code is included through this mecahnism

#### Parameters

url | {String} the URL of the JS file to be loaded

### reportFatalError

> reportFatalError: function( | msg | )

Triggers the <Fusion.Event.FUSION_ERROR> and passes along a <Fusion.DetailedError> object to the callback functions registered for this event. Widgets call Fusion.reportError to inform the system of errors. Applications will typically register an event listener for the error event and do something to report the error to the user. By default, errors are not reported since there is no listener

Unlike reportError, errors reported through reportFatalError carry valuable information such as stack traces, which errors sent via reportError will not contain

#### Parameters

msg | {String} The error message

### reportError

> reportError: function( | o | )

Triggers the <Fusion.Event.FUSION_ERROR> and passes along the error object to the callback functions registered for this event. Widgets call Fusion.reportError to inform the system of errors. Applications will typically register an event listener for the error event and do something to report the error to the user. By default, errors are not reported since there is no listener

For fatal errors, it is recommended to use reportFatalError instead

#### Parameters

o | {Object} the error object which is typically a string or a Fusion.Error object

### unitFromName

> unitFromName: function( | unit | )

returns index into the units array for the given unit name or abbreviation

#### Parameters

unit | {String} the units name to look up

#### Return

{Integer} index into the units array

### unitSystem

> unitSystem: function( | unit | )

#### Given a unit, this method returns if the units system is one of

imperial, metric, degrees or device units

#### Parameters

unit | {Integer} the units array index

#### Return

{String} the units system

### unitName

> unitName: function( | unit | )

Given a unit, this method returns the units name

#### Parameters

unit | {Integer} the units array index

#### Return

{String} the units name

### unitAbbr

> unitAbbr: function( | unit | )

Given a unit, this method returns the units abbreviation

#### Parameters

unit | {Integer} the units array index

#### Return

{String} the units abbreviation

### toMeter

> toMeter: function( | unit,
> | value | )

Converts a length value from native units into meters. This is the identity transform if the input units are meters

#### Parameters

unit | {Integer} the units array index
value | {Float} the value to be converted

#### Return

{Float} the value in meters

### fromMeter

> fromMeter: function( | unit,
> | value | )

Converts a length value from meters into native units. This is the identity transform if the native units are meters

#### Parameters

unit | {Integer} the units array index
value | {Float} the value to be converted

#### Return

{Float} the value in native units

### convert

> convert: function( | unitsIn,
> | unitsOut,
> | value | )

Converts a length value from one unit system into another.

#### Parameters

unitsIn | {Integer} the units array index of the input
unitsOut | {Integer} the units array index of the output
value | {Float} the value to be converted

#### Return

{Float} the value in output units

### initUnits

> initUnits: function( | metersPerUnit | )

initializes the meters per unit values when a new map is loaded. Some systems make different assumptions for the conversion of degrees to meters so this makes sure both Fusion and OpenLayers are using the same value.

#### Parameters

metersPerUnit | {Float} the value returned by LoadMap.php for meters per unit

### getClosestUnits

> getClosestUnits: function( | metersPerUnit | )

find the OpenLayers units identifier given the Fusion metersPerUnit value

#### Parameters

metersPerUnit | {Float} the value returned by LoadMap.php for meters per unit

### addWidgetStyleSheet

> addWidgetStyleSheet: function( | url | )

Dynamically load a CSS stylesheet. The url will be prepended with the Fusion URL.

#### Parameters

url | {String} the URL of the CSS file to be loaded

### parseQueryString

> parseQueryString: function()

An initialization time function to parse the application URL parameters and stores them in an array. They can be retrieved using {Fusion.getQueryParam}

#### Return

{Array} an array of the query params from when the page was loaded

### getQueryParam

> getQueryParam: function( | p | )

Returns the query parameter value for a given parameter name

#### Parameters

p | {String} the parameter to lookup

#### Return

parameter value or the empty string ‘’ if not found

### _scriptName

{String} Relative path of this script.

### _getScriptLocation

> _getScriptLocation: function ()

Return the path to this script for bootstrapping Fusion.

#### Return

{String} Path to this script

### createSessionId

> var createSessionId = function( | user,
> | pass | )

Pre-create a session to avoid the 401 Unauthorized dialog

> initialize: function( | options | )

Initialize the Fusion application.

> initializeLocale: function( | locale | )

Initialize the Strings hash with the requested locale.

> setLoadState: function( | state | )

set the current initialization state of the application.

> loadQueuedScripts: function()

load any scripts that have been queued for loading.

> queueScript: function( | url | )

Insert a new script into the loading queue.

> scriptFailed: function( | url | )

Called when a script fails to load for some reason.

> scriptLoaded: function( | url | )

a script has loaded.

> checkLoadingScripts: function()

check if scripts have loaded.

> loadConfig: function()

asynchronously load the application definition.

> getConfigCB: function( | r | )

the server has returned the application configuration file that contains enough information to bootstrap the application.

> serverSet: function()

the server has returned the application configuration file that contains enough information to bootstrap the application.

> serverFailed: function( | r | )

the application failed to load the application configuration file.

> ajaxRequest: function( | scriptURL,
> | options | )

convenience function to issue an {XmlHttpRequest} to the server relative to the Fusion installation.

> ajaxException: function( | r,
> | e | )

trap exceptions produced in handling an ajax response.

> getXmlAsJson: function( | url,
> | callback | )

Convert XML to JSON using a server-side script for requests that aren’t available in JSON.

> parseJSON: function( | str | )

Parses the given JSON string to a javascript object.

> trim: function( | str | )

Utility function to trim a given string of any trailing whitespace

> xml2json: function( | callback,
> | r,
> | json | )

Callback method to convert the XHR response into an actual json object and triggers the call to the callback method

> getMapByName: function( | name | )

return a map widget with the given name

> getMapById: function( | id | )

return a map widget that is associated with the given DOM element by id.

> getMapByIndice: function( | indice | )

return the map widget at the given index if there are more than one map elements specified in the AppDef

> getWidgetById: function( | id | )

return a reference to a widget by the id of the DOM Element that it was created in.

> getApplicationURL: function()

returns the applicaiton’s absolute URL minus the filename.html part

> getFusionURL: function()

returns the application’s absolute URL minus the filename.html part

> getConfigurationItem: function( | arch,
> | key | )

returns individual elements out of the Fusion config.json file

> getScriptLanguage: function()

Accessor to return the server-side script language

> getRedirectScript: function()

Accessor to return the URL of the redirect script

> getBroker: function()

Accessor to return the broker object (for MapGuide only).

> require: function( | url | )

Marks a JavaScript file as required which puts it into the queue for loading during Fusion initialization.

> reportFatalError: function( | msg | )

Triggers the Fusion.Event.FUSION_ERROR and passes along a Fusion.DetailedError object to the callback functions registered for this event.

> reportError: function( | o | )

Triggers the Fusion.Event.FUSION_ERROR and passes along the error object to the callback functions registered for this event.

> unitFromName: function( | unit | )

returns index into the units array for the given unit name or abbreviation

> unitSystem: function( | unit | )

imperial, metric, degrees or device units

> unitName: function( | unit | )

Given a unit, this method returns the units name

> unitAbbr: function( | unit | )

Given a unit, this method returns the units abbreviation

> toMeter: function( | unit,
> | value | )

Converts a length value from native units into meters.

> fromMeter: function( | unit,
> | value | )

Converts a length value from meters into native units.

> convert: function( | unitsIn,
> | unitsOut,
> | value | )

Converts a length value from one unit system into another.

> initUnits: function( | metersPerUnit | )

initializes the meters per unit values when a new map is loaded.

> getClosestUnits: function( | metersPerUnit | )

find the OpenLayers units identifier given the Fusion metersPerUnit value

> addWidgetStyleSheet: function( | url | )

Dynamically load a CSS stylesheet.

> parseQueryString: function()

An initialization time function to parse the application URL parameters and stores them in an array.

> getQueryParam: function( | p | )

Returns the query parameter value for a given parameter name

> _getScriptLocation: function ()

Return the path to this script for bootstrapping Fusion.

> var createSessionId = function( | user,
> | pass | )

Pre-create a session to avoid the 401 Unauthorized dialog
generic class for map widgets.
This is the base class for all widgets.
MGBroker is used to broker requests to the MapGuide Open Source mapagent interface.
General purpose Error object
Close