Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
javascript
javascript
gadgets.ee.registerContextListener(function(context) {
  //Do something with the context
});

Additional Considerations:

We also need to support the ability for a gadget to get the parent object containing the embedded experience.  There should be a similar API to accomplish that as well, but those discussions are on going at the moment.  See this wiki page.

<static> gadgets.ee.registerRootContextListener(listener)

Description: Registers a listener for when the root object containing this embedded experience is passed to the object.  The embedded experience data model is contained within the root object being passed.

Parameters:

Name

Type

Description

listener

Function

A function that will be called when the root object containing this embedded experience is passed to the gadget.  The function should take one parameter which is a JSON object representing a root context object.

Example:

...


gadgets.ee.registerRootContextListener(function(rootContext) {
  var eeDataModel;
  if(rootContext.type === opensocial.type.Activity) {
    eeDataModel = rootContext.root.openSocial.embed;
  } else if(rootContext.type === opensocial.type.Message) {  //At the time this proposal was written EE was not integrated into the OpenSocial Message object
    eeDataModel = rootContext.root.embed;
  } else if(rootContext.type === opensocial.type.SearchResult) {  //At the time this proposal was written there is no SearchResult object in the OpenSocial spec
    eeDataModel = rootContext.root.embed;
  } else {
    gadgets.error('Unknown type');
  }
});

Embedded Experiences Root Context Object

The embedded experience root context object is an object that represents the type of OpenSocial data object containing the embedded experience.  The possible data types include

  • An Activity Stream activity.
  • A Message - We need to define this.
  • A Search Object - We need to define this.

The embedded experiences root context object has two fields.

Name

Type

Description

type

opensocial.type

Indicates the type of OpenSocial object containing the embedded experience.

root

Object

A JSON object containing the embedded experience.

opensocial.type

This is basically a set of constants defining the different OpenSocial data types.

<static> opensocial.type.ActivityEntry

Description: A constant for an activity entry in an activity stream.

<static> opensocial.type.Message

Description: A constant for the OpenSocial Message type.

<static> opensocial.type.SearchResult

Description: A constant for a search result.