WireCloud provides context at three levels: platform, mashup and widget/operator levels. Those context are accesible through the following objects:
MashupPlatform.widget.context // Widget context (Only available to widgets)
MashupPlatform.operator.context // Operator context (Only available to operators)
MashupPlatform.mashup.context // Mashup context
MashupPlatform.context // Platform context
Each of these context managers supports three methods:
getAvailableContext
: That provides information about what concepts are available for the given levelget
: Retrieves the current value for a conceptregisterCallback
: Allows to register a callback that will be called when any of the concepts are modifiedBasically you'll make use of the get
method. For example:
MashupPlatform.widget.context.get('heightInPixels');
MashupPlatform.mashup.context.get('name');
MashupPlatform.context.get('username');
The available context information depends on the version and the list of addons installed in the concrete instance of WireCloud. Here you have to options:
getAvailableContext
methodOne of the main uses that developers can give to the context support is using it for receiving notification about changes in the size of a widget. This is due to the fact that CSS is better prepared for managing horizontal dimensions than vertical ones. In addition to this, the resize event is not fired inside widgets as they are wrapped in iframe elements, so if the developer need to resize the content programmatically, this becomes the best choice. This code snippet shows how to use the context support for resizing the widget's content:
MashupPlatform.widget.context.registerCallback(function (new_values) {
...
if ('heightInPixels' in new_values) {
repaint();
}
...
});
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |