new UWA.Embedded(url, options)
Render an UWA appplication into a frame without requiring full UWA Js Runtime loaded into main document.
Features
- Provide widget callbacks mapping.
- UWA application soft or hard sandboxing.
- Remote UWA application communication and events controls.
- Remote UWA application preferences manipulation.
- Async Script Snipets for loading UWA application into third party website.
Examples
Simple Example:
var MyWidget = new UWA.Embedded('http://example.com/apps/mywidget.html');
Example with offline capabilitie:
var MyWidget = new UWA.Embedded('http://example.com/apps/mywidget.html', {
useAppCache: true,
offlineMode: true
});
Example to handle title and preference update:
var MyWidget = new UWA.Embedded('http://example.com/apps/mywidget.html');
MyWidget.addCallback('setTitle', function(title) {
// setTitle called with value <title>
});
MyWidget.addCallback('setValue', function(name, value) {
// setValue called for key <name> with value <value>
});
Parameters
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
String | a valid UWA widget url |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object | Options hash or a option/value pair. Properties
|
Mixes In
- UWA.Class.Options
- UWA.Class.Debug
- UWA.Class.Events
Index
Members
Methods
Members
-
url :String
-
Current UWA Widget Url used by current Embedded instance.
Type
- String
-
id :String
-
Current Embedded instance unique identifier.
Type
- String
-
data :Object
-
Stores widget's data.
This property can be modified by the <setValue> method. This property may automatically updated by widget using <publicInterface>.
Type
- Object
-
version :String
-
Identifier of UWA assets version.
Type
- String
-
elements
-
Embedded Elements (container, header, footer, frame, ...).
-
preferences :Array
-
Stores widget's preferences. The array is initially empty. It is initialised by the <onRegisterWidget> method. This property may automatically updated by widget using <publicInterface>.
Type
- Array
-
disableRemote :Boolean
-
Activates or desactivates the remote message for the widget. The default value is TRUE. When TRUE, messages written with <sendRemote> method will sent to the widget.
Type
- Boolean
-
<protected> socket
-
Properties:
Name Type Description socket
Object Stores Embedded's socket for UWA.InterCom usage.
Methods
-
setOptions(options) → {Object}
-
Set options values of current instance.
Parameters
Name Type Description options
Object The options to add
Returns
The current UWA.Embedded instance.
- Type
- Object
-
generateId() → {String}
-
Generate a new uniq embbedded Id based on <url>.
Returns
new uniq embbedded Id.
- Type
- String
-
render()
-
Render Iframe and Iframe Container.
-
getIframeUrl()
-
Get current iframe Url with rights parameters.
-
getIframeDomain() → {String}
-
Get current module domain for iframe mode.
Returns
Module Domain related to <UWA.hosts.exposition> value.
- Type
- String
-
initRemote()
-
Init Remote controls system to exchange data between module frame and current document.
Internal or advanced use only.
-
sendRemote(event, args)
-
Send message throught remote controls to the widget.
Example
embedded.sendRemote('onUpdateTitle', ["My new Title"])
Parameters
Name Type Description event
String A event name for remote interface
args
Array Event data for remote interface
-
launch(data, readOnly)
-
Load or reLoad the Widget.
Parameters
Name Type Description data
Object Widget's data values
readOnly
Bool Default to
false
. True if the widget is currently read only for the viewer -
setChromeColor(color)
-
Sets the color value of widget header.
Example
embedded.setChromeColor("red");
Parameters
Name Type Description color
String The name of the color we want to set
-
setTitle(title)
-
Sets the title of the Widget.
Example
embedded.setTitle('Netvibes Blog');
Parameters
Name Type Description title
String The title of the widget
-
setIcon(url, search)
-
Sets the icon for the Widget.
Example
embedded.setIcon("http://www.netvibes.com/favicon.ico"); // OR embedded.setIcon("http://www.netvibes.com", true);
Parameters
Name Type Description url
String The url of the icon. The URL should include the protocol (http://)
search
Boolean If
true
, try to autodiscover the icon for the given url. Internal use only -
setValue(name, value)
-
Sets the value of the given preference.
Example
embedded.setValue("nbItems", "5");
Parameters
Name Type Description name
String The name of the preference we want to set
value
String The value of the preference
-
setValues(values)
-
Sets the values of the given preferences.
Example
embedded.setValue({ "nbItems", "5", "openOutside": true });
Parameters
Name Type Description values
Object The preferences indexed by name value we want to set
-
resizeHeight(height)
-
Sets the height value of widget iframe.
Example
embedded.resizeHeight(100);
Parameters
Name Type Description height
Number the height we want to set
-
resizeWidth(width)
-
Sets the width value of widget iframe.
Example
embedded.resizeWidth(100);
Parameters
Name Type Description width
Number The width we want to set
-
onRegisterWidget()
-
Call when a Widget Register into the execution Environment. Once done, fire the <launch> callback if autoLaunch options is
false
. -
onUpdateTitle(title)
-
Triggered when the widget's title is modified. Implementations MUST trigger it when widget.setTitle() is used. Implementations MAY also trigger for internal reasons.
Parameters
Name Type Description title
String The title of the widget. Can contain HTML code
-
onUpdateIcon(url)
-
Triggered when the widget's icon is modified. Implementations MUST trigger it when widget.setIcon() is used. Implementations MAY also trigger for internal reasons.
Parameters
Name Type Description url
String The url of the icon. The URL should include the protocol (http://)
-
getCode(asynchronous) → {String}
-
Get Javascript
<script>
tags to display widget.Parameters
Name Type Description asynchronous
Boolean using asynchronous Javascript
Returns
Javascript
<script>
tags to display widget- Type
- String