Class Index | File Index

## Classes

- _global_
- OWF
- OWF.Chrome
- OWF.DragAndDrop
- OWF.Eventing
- OWF.Intents
- OWF.Lang
- OWF.Launcher
- OWF.Log
- OWF.Metrics
- OWF.Preferences
- OWF.RPC
- OWF.Util
- Ozone.chrome.WidgetChrome
- Ozone.dragAndDrop.WidgetDragAndDrop
- Ozone.eventing.Widget
- Ozone.eventing.WidgetProxy
- Ozone.lang
- Ozone.launcher.WidgetLauncher
- Ozone.launcher.WidgetLauncherUtils
- Ozone.log
- Ozone.metrics
- Ozone.pref.PrefServer
- Ozone.state.WidgetState
- Ozone.state.WidgetStateHandler
- Ozone.util
- Ozone.util.pageLoad

# Class Ozone.state.WidgetState

Defined in: WidgetState.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Ozone.state.WidgetState(cfg) The Ozone.state.WidgetState object manages the two-way communication between an OWF widget and its OWF Container.

Field Summary
Field Attributes | Field Name and Description
--- | ---
| version version number

Method Summary
Method Attributes | Method Name and Description
--- | ---
| activateWidget(cfg) Activates a widget.
| addStateEventListeners(cfg) Adds custom state event handlers to listen to widget events.
| addStateEventOverrides(cfg) Adds custom state event handlers to override a widget event.
| closeWidget(cfg) Closes a widget.
<static> | Ozone.state.WidgetState.getInstance(cfg) Retrieves Ozone.state.WidgetState Singleton instance.
| getRegisteredStateEvents(cfg) Gets registered widget state events
| getWidgetState(cfg) Gets current widget state.
| init(cfg) Initializes the WidgetState object.
| onStateEventReceived() The default callback function when an event is received.
| removeStateEventListeners(cfg) Removes custom state event listeners from a widget.
| removeStateEventOverrides(cfg) Removes custom state event listeners from a widget.

Class Detail
Ozone.state.WidgetState(cfg)
The Ozone.state.WidgetState object manages the two-way communication between an OWF widget and its OWF Container.

    var widgetState = new Ozone.state.WidgetState({
        onStateEventReceived: function(sender, msg) {
        		// do something
        }
    });

Parameters:
{Object} cfg Optional
  config object see below for properties
{String} cfg.widgetEventingController Optional
  The widgetEventingController
{Boolean} cfg.autoInit Optional
  Whether or not to automatically start listening to the state channel. Default is true.
{String} cfg.widgetGuid Optional
  The guid of the widget to monitor. Default is itself.
{String} cfg.onStateEventReceived Optional
  The callback function when an event is received.

Deprecated:
Since OWF 3.7.0 You should use Ozone.state.WidgetState.getInstance

Requires:
  Ozone.eventing.Widget for eventing

Field Detail
version
version number
Method Detail
activateWidget(cfg)
Activates a widget.

    widgetState.activateWidget({
        guid: "GUID_OF_A_WIDGET",
        callback: function(result) {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget to activate. Defaults to current widget's guid.
{Function} cfg.callback Optional
  Function to be called once after the widget has been activated. This function is passed back the following parameters.
  {Boolean} result: true if the widget has been activated, or else false.

addStateEventListeners(cfg)
Adds custom state event handlers to listen to widget events.

    widgetState.addStateEventListeners({
    	   events: ['beforeclose','maximize'],
        callback: function() {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose events should be monitored. Defaults to current widget guid.
{Array} cfg.events Optional
  Array of events. If no event is provided this method will add listeners to all registered events.
{Function} cfg.callback Optional
  Function to be called once after the listener is added.

addStateEventOverrides(cfg)
Adds custom state event handlers to override a widget event.

    widgetState.addStateEventOverrides({
    	   events: ['beforeclose','maximize'],
        callback: function() {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose events should be monitored. Defaults to current widget guid.
{Array} cfg.events Optional
  Array of events. If no event is provided this method will add listeners to all registered events.
{Function} cfg.callback Optional
  Function to be called once after the listener is added.

closeWidget(cfg)
Closes a widget.

    widgetState.closeWidget({
        guid: "GUID_OF_A_WIDGET",
        callback: function(result) {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget to close. Defaults to current widget's guid.
{Function} cfg.callback Optional
  Function to be called once after the widget is closed. Only use this if the widget is not closing itself. This function is passed back the following parameters.
  {Boolean} result: true if the widget has been closed, or else false.

<static> Ozone.state.WidgetState.getInstance(cfg)
Retrieves Ozone.state.WidgetState Singleton instance. Manages the two-way communication between an OWF widget and its OWF Container.

    var widgetState = Ozone.state.WidgetState.getInstance({
        onStateEventReceived: function(sender, msg) {
             // do something
        }
    });

Parameters:
{Object} cfg Optional
  config object see below for properties
{String} cfg.widgetEventingController Optional
  The widgetEventingController
{Boolean} cfg.autoInit Optional
  Whether or not to automatically start listening to the state channel. Default is true.
{String} cfg.widgetGuid Optional
  The guid of the widget to monitor. Default is itself.
{String} cfg.onStateEventReceived Optional
  The callback function when an event is received.

Since:
  OWF 3.7.0

Requires:
  Ozone.eventing.Widget for eventing

getRegisteredStateEvents(cfg)
Gets registered widget state events

    widgetState.getRegisteredStateEvents({
        callback: function(events) {
        		for (var i = 0; i < events.length; i++) {
        			// Do something
        		}
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose events should be retrieved. Defaults to current widget guid.
{Function} cfg.callback Optional
  Function to be called once after the stateWidget is executed.

getWidgetState(cfg)
Gets current widget state.

    widgetState.getWidgetState({
        callback: function(state) {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose state should be retrieved. Defaults to current widget guid.
{Function} cfg.callback Optional
  Function to be called once after the state is retrieved. This method will be passed the state object which has following properties.
  {String} name: name of the widget
  {Number} x: x-coordinate value of the top left corner of the widget
  {Number} y: y-coordinate value of the top left corner of the widget
  {Number} width: width of the widget
  {Number} height: height of the widget
  {Boolean} active: true if the widget is active, or else false. This property is applicable for desktop layout only.
  {Boolean} maximized: true if the widget is maximized, or else false
  {Boolean} minimized: true if the widget is minimized, or else false
  {Boolean} collapsed: true if the widget is collapsed, or else false
  {Boolean} singleton: true if the widget is singleton, or else false
  {Boolean} pinned: true if the widget is pinned, or else false
  {String} uniqueId: unique id of the widget
  {String} widgetGuid: guid of the widget
  {String} paneGuid: guid of the pane
  {String} dashboardGuid: guid of the dashboard the widget is opened on
  {String} region: region of the widget. This property is applicable for accordion layout only. Possible values for accordion layout are "accordion", "center" and "south". In other layouts, its value is "none".
  {Number} columnPos: column the widget is opened in. This property is applicable for portal layout only. Possible values for portal layout are 0, 1 and 2. In other layouts, its value is 0.
  {Number} zIndex: z-index of the widget.

init(cfg)
Initializes the WidgetState object. Using this function is only required if autoInit config is false in the constructor. This function is sometimes useful when it is necessary to defer event handling after creating the Ozone.state.WidgetState object

Parameters:
{Object} cfg Optional
  config object

See:
  constructor

onStateEventReceived()
The default callback function when an event is received.

removeStateEventListeners(cfg)
Removes custom state event listeners from a widget.

    widgetState.removeStateEventListeners({
    	   events: ['beforeclose','maximize'],
        callback: function() {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose events should be monitored. Defaults to current widget guid.
{Array} cfg.events Optional
  Array of events. If no event is provided this method will remove only custom listeners from all registered events.
{Function} cfg.callback Optional
  Function to be called once after the listener is removed.

removeStateEventOverrides(cfg)
Removes custom state event listeners from a widget.

    widgetState.removeStateEventOverrides({
    	   events: ['beforeclose','maximize'],
        callback: function() {
        		// Do something
        }
    });

Parameters:
{Object} cfg Optional
  Config object. See below for properties.
{String} cfg.guid Optional
  Id of the widget whose events should be monitored. Defaults to current widget guid.
{Array} cfg.events Optional
  Array of events. If no event is provided this method will remove only custom listeners from all registered events.
{Function} cfg.callback Optional
  Function to be called once after the listener is removed.

Documentation generated by JsDoc Toolkit 2.3.2 on Fri Oct 05 2012 16:51:05 GMT-0400 (EDT)