Environment
The Environment Base class provide base functions to run an UWA Widget Execution Environnement. It is an abstract class, and must be extended to be useful. The object must be filled with DOM elements (at least body), in the “<onInit>” or “<onRegisterModule>” callbacks for example.
| Environment | The Environment Base class provide base functions to run an UWA Widget Execution Environnement. |
| Properties | |
| widget | Widget: current widget registered in this environnement. |
| html | Object: HTML Dom elements related to this environnement |
| loaded | Boolean: flag to know if the Environnement is loaded. |
| registered | Boolean: flag to know if a Widget is registered. |
| debugMode | Boolean: activates or desactivates the debug mode for the widget. |
| periodicals | Object: Stores environment’s periodical events. |
| delays | Object: Stores environment’s delayed events. |
| height | Integer: The current height of the widget in pixel. |
| Functions | |
| init | Initialize the Environment, when DOM is ready |
| getModule | Returns the widget (= module) currently registered in the Environment. |
| registerModule | Registers a Widget (module) into the execution Environment. |
| launchModule | Launch the registered widget by fire the widget.launch method. |
| callback | Fire Environment.key then the callback method associated with the given callback name (key). |
| setPeriodical | Register a function as periodical event. |
| clearPeriodical | Unregister a periodical event previously registered with setPeriodical |
| setDelayed | Registers a function as delayed event. |
| clearDelayed | Unregister a delayed event previously registered with setDelayed |
| log | Logs environment’s messages in the console, if one exists and if the debugMode is true. |
debugMode
Boolean: activates or desactivates the debug mode for the widget.
The default value is TRUE. When TRUE, messages written with log method will appear in the console.
periodicals
Object: Stores environment’s periodical events.
The object is initially empty. It is filled by the setPeriodical method.
delays
Object: Stores environment’s delayed events.
The object is initially empty. It is filled by the setDelayed method.
callback
callback: function( name, args, bind )
Fire Environment.key then the callback method associated with the given callback name (key). Returns false if no callback method is associated with the given key.
Parameters
- String name: the callback name (e.g. “onUpdateTitle”);
- Object args: one optional argument
- Object: an object to bind the callback to
Returns
- Nothing, but calls the method associated with the given callback name (key)
setPeriodical
setPeriodical: function( name, fn, delay, force )
Register a function as periodical event.
The function will automatically be binded to the current environment object.
Parameters
- String name: the name of the event
- Function fn: the function to register
- Integer delay: the execution delay in milliseconds
- Boolean force: If true, fire the function for the time right now.
Notes
internal or advanced use only
clearPeriodical
clearPeriodical: function( name )
Unregister a periodical event previously registered with setPeriodical
Parameters
- String name: the name of the event
Notes
internal or advanced use only
setDelayed
setDelayed: function( name, fn, delay, bind )
Registers a function as delayed event.
If ‘bind’ is not defined, the function will automatically be bound to the current environment object.
Parameters
- String name: the name of the event
- Function fn: the function to register
- Integer delay: the delay in milliseconds
- Object bind: A javascript object to bind the function to.
Notes
internal or advanced use only
clearDelayed
clearDelayed: function( name )
Unregister a delayed event previously registered with setDelayed
Parameters
- String name: the name of the event
Notes
internal or advanced use only
log
log: function( string )
Logs environment’s messages in the console, if one exists and if the debugMode is true. It is using <UWA.log> which usually works with Firebug, Safari and Opera.
Parameters
- String message: the message to display in the console.
Example
widget.log("Environment is loading");Initialize the Environment, when DOM is ready
init: function()
Returns the widget (= module) currently registered in the Environment.
getModule: function()
Registers a Widget (module) into the execution Environment.
registerModule: function( module )
Launch the registered widget by fire the widget.launch method.
launchModule: function()
Fire Environment.key then the callback method associated with the given callback name (key).
callback: function( name, args, bind )
Register a function as periodical event.
setPeriodical: function( name, fn, delay, force )
Unregister a periodical event previously registered with setPeriodical
clearPeriodical: function( name )
Registers a function as delayed event.
setDelayed: function( name, fn, delay, bind )
Unregister a delayed event previously registered with setDelayed
clearDelayed: function( name )
Logs environment’s messages in the console, if one exists and if the debugMode is true.
log: function( string )