Fusion

declare global namespace object for Fusion library to use

Summary
declare global namespace object for Fusion library to use
A set of utility classes that provide common tools for applications
A set of classes that implement the functionlity required for applications
A class to provide for event handling at application runtime
A set of classes to provide core funtionality
A set of classes that implement layer functionality for various server technologies.
Application scope constants
Initialize the Fusion application.
Initialize the Strings hash with the requested locale.
set the current initialization state of the application.
load any scripts that have been queued for loading.
Insert a new script into the loading queue.
Called when a script fails to load for some reason.
a script has loaded.
check if scripts have loaded.
asynchronously load the application definition.
the server has returned the application configuration file that contains enough information to bootstrap the application.
the server has returned the application configuration file that contains enough information to bootstrap the application.
the application failed to load the application configuration file.
convenience function to issue an XmlHttpRequest to the server relative to the Fusion installation.
trap exceptions produced in handling an ajax response.
Convert XML to JSON using a server-side script for requests that aren’t available in JSON.
Callback method to convert the XNR response into an actual json object and triggers the call to the callback method
return a map widget with the given name
return a map widget that is associated with the given DOM element by id.
return the map widget at the given index if there are more than one map elements specified in the AppDef
return a reference to a widget by the id of the DOM Element that it was created in.
returns the applicaiton’s absolute URL minus the filename.html part
returns the application’s absolute URL minus the filename.html part
returns individual elements out of the Fusion config.json file
Accessor to return the server-side script language
Accessor to return the URL of the redirect script
Accessor to return the broker object (for MapGuide only).
Marks a JavaScript file as required which puts it into the queue for loading during Fusion initialization.
Triggers the Fusion.Event.FUSION_ERROR and passes along the error object to the callback functions registered for this event.
returns index into the units array for the given unit name or abbreviation
imperial, metric, degrees or device units
Given a unit, this method returns the units name
Given a unit, this method returns the units abbreviation
Converts a length value from native units into meters.
Converts a length value from meters into native units.
Converts a length value from one unit system into another.
initializes the meters per unit values when a new map is loaded.
find the OpenLayers units identifier given the Fusion metersPerUnit value
Dynamically load a CSS stylesheet.
An initialization time function to parse the application URL parameters and stores them in an array.
Returns the query parameter value for a given parameter name
{String} Relative path of this script.
Return the path to this script for bootstrapping Fusion.
Pre-create a session to avoid the 401 Unauthorized dialog

Fusion. Tools

A set of utility classes that provide common tools for applications

Fusion. Widget

A set of classes that implement the functionlity required for applications

Fusion. Event

A class to provide for event handling at application runtime

Fusion.Lib

A set of classes to provide core funtionality

Fusion. Layers

A set of classes that implement layer functionality for various server technologies.

Fusion. Constant

Application scope constants

Summary
Initialize the Fusion application.
Initialize the Strings hash with the requested locale.
set the current initialization state of the application.
load any scripts that have been queued for loading.
Insert a new script into the loading queue.
Called when a script fails to load for some reason.
a script has loaded.
check if scripts have loaded.
asynchronously load the application definition.
the server has returned the application configuration file that contains enough information to bootstrap the application.
the server has returned the application configuration file that contains enough information to bootstrap the application.
the application failed to load the application configuration file.
convenience function to issue an XmlHttpRequest to the server relative to the Fusion installation.
trap exceptions produced in handling an ajax response.
Convert XML to JSON using a server-side script for requests that aren’t available in JSON.
Callback method to convert the XNR response into an actual json object and triggers the call to the callback method
return a map widget with the given name
return a map widget that is associated with the given DOM element by id.
return the map widget at the given index if there are more than one map elements specified in the AppDef
return a reference to a widget by the id of the DOM Element that it was created in.
returns the applicaiton’s absolute URL minus the filename.html part
returns the application’s absolute URL minus the filename.html part
returns individual elements out of the Fusion config.json file
Accessor to return the server-side script language
Accessor to return the URL of the redirect script
Accessor to return the broker object (for MapGuide only).
Marks a JavaScript file as required which puts it into the queue for loading during Fusion initialization.
Triggers the Fusion.Event.FUSION_ERROR and passes along the error object to the callback functions registered for this event.
returns index into the units array for the given unit name or abbreviation
imperial, metric, degrees or device units
Given a unit, this method returns the units name
Given a unit, this method returns the units abbreviation
Converts a length value from native units into meters.
Converts a length value from meters into native units.
Converts a length value from one unit system into another.
initializes the meters per unit values when a new map is loaded.
find the OpenLayers units identifier given the Fusion metersPerUnit value
Dynamically load a CSS stylesheet.
An initialization time function to parse the application URL parameters and stores them in an array.
Returns the query parameter value for a given parameter name
{String} Relative path of this script.
Return the path to this script for bootstrapping Fusion.
Pre-create a session to avoid the 401 Unauthorized dialog

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.

@param {Object} options

Optional paramters that can be passed to initialize are

{String} applicationDefinitionURLa URL or resource ID for an ApplicationDefinition file
{String} sessionIda 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.

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.

@param {String} localethe 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.

Parameter {Integer} state

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 loadQueuedScripts is called.

Parameter: {String} url

The url of the script.

scriptFailed

scriptFailed: function(url)

Called when a script fails to load for some reason.

Parameter: 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 loadQueuedScripts again, otherwise we advance the load state.

Parameter: 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 laod state.

getConfigCB

getConfigCB: function(r)

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

Parameter {Object} r an XMLHttpRequest object

serverSet

serverSet: function()

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

Parameter {Object} r 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.

Parameter: {Object} r

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.

Parameter: {String} scriptURL

the URL (relative to Fusion) to request

Parameter: {Object} options

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.

Parameter: {XmlHttpRequest} r

Parameter: {Exception} e

getXmlAsJson

getXmlAsJson: function(url,
callback)

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

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

boolean indicator if the content is JSON or not.

xml2json

xml2json: function(callback,
r,
json)

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

Parameter: callback

callback method to be executed on success and will be passed a parsed json object

Parameter: {XmlHttpRequest} r

the XmlHttpRequest object

Parameter: json

boolean indicator if the content is JSON or not (set by OpenLayers)

getMapByName

getMapByName: function(name)

return a map widget with the given name

Parameter: {String} name

The map name to return

Returns: {Object} 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.

Parameter: {String} id

The map id to return

Returns: {Object} 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

Parameter: {String} indice

The map indice to return

Returns: {Object} 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.

Parameter: {String} id

the DOM id to get the widget for

Returns: {Fusion.Widget} the widget or null

getApplicationURL

getApplicationURL: function()

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

Returns: {String} a URL

getFusionURL

getFusionURL: function()

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

Returns: {String} a URL

getConfigurationItem

getConfigurationItem: function(arch,
key)

returns individual elements out of the Fusion config.json file

Parameter: {String} archthe server architecture (mapguide or mapserver)
Parameter: {String} keythe config item to be returned

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

getScriptLanguage

getScriptLanguage: function()

Accessor to return the server-side script language

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

getRedirectScript

getRedirectScript: function()

Accessor to return the URL of the redirect script

Returns: {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.

Returns: {Object} 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

Parameter: {String} urlthe URL of the JS file to be loaded

Returns: none

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(o) 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

Parameter: {Object} othe error object which is typically a string

Returns: none

unitFromName

unitFromName: function(unit)

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

Parameter: {String} unitthe units name to look up

Returns: {Integer} index into the units array

unitFromName

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

imperial, metric, degrees or device units

Parameter: {Integer} unitthe units array index

Returns: {String} the units system

unitName

unitName: function(unit)

Given a unit, this method returns the units name

Parameter: {Integer} unitthe units array index

Returns: {String} the units name

unitAbbr

unitAbbr: function(unit)

Given a unit, this method returns the units abbreviation

Parameter: {Integer} unitthe units array index

Returns: {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

Parameter: {Integer} unitthe units array index
Parameter: {Float} valuethe value to be converted

Returns: {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

Parameter: {Integer} unitthe units array index
Parameter: {Float} valuethe value to be converted

Returns: {Float} the value in native units

convert

convert: function(unitsIn,
unitsOut,
value)

Converts a length value from one unit system into another.

Parameter: {Integer} unitsInthe units array index of the input
Parameter: {Integer} unitsOutthe units array index of the output
Parameter: {Float} valuethe value to be converted

Returns: {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.

Parameter: {Float} metersPerUnitthe value returned by LoadMap.php for meters per unit

getClosestUnits

getClosestUnits: function(metersPerUnit)

find the OpenLayers units identifier given the Fusion metersPerUnit value

@param metersPerUnit 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.

Parameter: {String} urlthe URL of the CSS file to be loaded

Returns: none

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(key).

Returns: {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

Parameter: {String} pthe parameter to lookup

Returns: 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.

Returns

{String} Path to this script

createSessionId

var createSessionId = function()

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.
xml2json: function(callback,
r,
json)
Callback method to convert the XNR 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.
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
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()
Pre-create a session to avoid the 401 Unauthorized dialog
A set of classes that implement the functionlity required for applications