(abstract) new Device(config)
Abstract base class for Antie devices.
Device classes contain an abstraction layer between the Application and the environment in which
the application runs (usually a web-browser).
Any of the methods below can be overriden by a device-specific subclass or implementation common to multiple
devices can be loaded via requirejs modifiers for this module (referenced in the device config).
Device-specific implementations take precendence over those in requirejs modifiers.
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | Device configuration document. |
- Source:
Requires:
- module:antie.events.KeyEvent
Extends
- antie.Class
Requires
- module:antie.events.KeyEvent
Methods
(static) addLoggingMethod(moduleId, loggingMethods)
Adds a logging method at device init time
Parameters:
Name | Type | Description |
---|---|---|
moduleId |
String | of require module that defined the logging methods - eg antie/devices/logging/default |
loggingMethods |
Object | object that contains implementations of each logging interface ( log,debug,info,warn,error ) |
- Source:
(static) load(config, callbacks)
Loads a device configuration document, and its modifiers.
Parameters:
Name | Type | Description |
---|---|---|
config |
Object | Device configuration document. |
callbacks |
Object | Object containing onSuccess and onError callback functions. |
- Source:
addClassToElement(el, className)
Adds a class name to an element
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element which will receive new class name. |
className |
String | The new class name to add. |
- Source:
addKeyEventListener()
Adds global key event listener(s) to the user-agent.
This must be added in a way that all key events within the user-agent
cause self._application.bubbleEvent(...) to be called with a KeyEvent
object with the mapped keyCode.
- Source:
Example
document.onkeydown = function(e) {
self._application.bubbleEvent(new KeyEvent("keydown", keyMap[e.keyCode]));
};
appendChildElement(to, el)
Appends an element as a child of another.
Parameters:
Name | Type | Description |
---|---|---|
to |
Element | Append as a child of this element. |
el |
Element | The new child element. |
- Source:
createBroadcastSource() → {Object}
Create a new widget giving control over broadcast television. Check whether
the broadcast television API is available first with isBroadcastSourceSupported().
- Source:
- See:
-
- antie.widgets.broadcastsource
Returns:
Device-specific implementation of antie.widgets.broadcastsource
- Type
- Object
(protected) createButton(idopt, classNamesopt)
-PROTECTED- Creates a button (an element that can be selected by the user to perform an action) in the device's user-agent.
Do not use outside of antie. Create antie.widgets.Button objects if you need to use buttons within an application.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
- Source:
Returns:
A button within the device's user-agent.
(protected) createContainer(idopt, classNamesopt)
-PROTECTED- Creates a generic container element in the device's user-agent.
Do not use outside of antie. Create antie.widgets.Container objects to use containers within applications.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
- Source:
Returns:
A container element within the device's user-agent.
(protected) createImage(idopt, classNamesopt, src)
-PROTECTED- Creates an image in the device's user-agent.
Do not use outside of antie. Create antie.widgets.Image objects if you want to use images within an application
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
src |
String | The source URL of the image. |
- Source:
Returns:
An image within the device's user-agent.
(protected) createLabel(idopt, classNamesopt, textopt)
-PROTECTED- Creates a label (an element that only contains text) in the device's user-agent.
Do not use outside of antie. Create antie.widgets.Label objects if you need to use labels within an application.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
text |
String |
<optional> |
The text within the label. |
- Source:
Returns:
A label within the device's user-agent.
(protected) createList(idopt, classNamesopt)
-PROTECTED- Creates a list in the device's user-agent.
Do not use outside of antie. Create antie.widgets.List objects if you need to use lists within an application.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
- Source:
Returns:
A list within the device's user-agent.
(protected) createListItem(idopt, classNamesopt)
-PROTECTED- Creates a list item in the device's user-agent.
Do not use outside of antie. Create antie.widgets.ListItem objects or add widgets to a List if you want use list items within an application
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
String |
<optional> |
The id of the element to create. |
classNames |
Array |
<optional> |
An array of class names to apply to the element. |
- Source:
Returns:
A list item within the device's user-agent.
createMediaInterface(id, mediaType, eventCallback)
Creates the interface that Media widgets use to communicate
with the device.
Parameters:
Name | Type | Description |
---|---|---|
id |
ID to be used when creating DOM elements. | |
mediaType |
Type of media. "audio" or "video" | |
eventCallback |
Function that is called to processes media events. |
- Source:
crossDomainPost(url, data, opts)
Performs a POST HTTP request to a URL on a different host/domain.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The URL to post to. |
data |
Object | Associative array of fields/values to post. |
opts |
Object | Object containing onLoad and onError callback functions. |
- Source:
decodeJson(json)
Decodes JSON.
Parameters:
Name | Type | Description |
---|---|---|
json |
String | JSON to decode. |
- Source:
encodeJson(obj)
Encodes an object as JSON.
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | Object to encode. |
- Source:
executeCrossDomainGet(url, opts, jsonpOptionsopt)
Performs a cross domain GET for a decoded JSON object utilising CORS if supported by
the device, falling back to a JSON-P call otherwise.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
String | The URL to load. A callback GET parameter will be appended if JSON-P is used. | |||||||||||||||||||||
opts |
Object | Object containing callbacks and an optional bearer token.
Properties
|
|||||||||||||||||||||
jsonpOptions |
Object |
<optional> |
Options for the JSON-P fallback behaviour. All optional with sensible defaults.
Properties
|
- Source:
executeCrossDomainPost(url, data, opts)
Performs a cross domain POST HTTP using CORS or the content delivered as a single form field value depending on device capability
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
String | The URL to post to. | ||||||||||||||||||||
data |
Object | JavaScript object to be JSON encoded and delivered as payload. | ||||||||||||||||||||
opts |
Object | Object containing callback functions, a form field name and an optional bearer token.
Properties
|
- Source:
exit()
Exits the application directly - no history.
- Source:
exitToBroadcast()
Exits to broadcast if this function has been overloaded by a modifier. Otherwise, calls exit().
- Source:
getChildElementsByTagName(el, tagName)
Returns all direct children of an element which have the provided tagName.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element who's children you wish to search. |
tagName |
String | The tag name you are looking for. |
- Source:
Returns:
An array of elements having the provided tag name.
getConfig()
Gets the current device configuration.
- Source:
Returns:
The current device configuration document.
getCurrentRoute()
Gets the current route (a reference pointing to a location within the application).
- Source:
Returns:
The current route (location within the application).
getElementOffset(el)
Returns the offset of the element within its offset container.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element you wish to know the offset of. |
- Source:
Returns:
An literal object containing properties, top and left.
getElementSize(el)
Gets the size of an element.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element of which to return the size. |
- Source:
Returns:
A size object containing the width and height of the element.
getKeyMap()
Gets the current key map from the device configuration.
- Source:
Returns:
The current key map.
getLivePlayer() → {antie.devices.mediaplayer.MediaPlayer}
Get the live media player.
This will return the correct implementation for the current device.
- Source:
Returns:
Live media player for the current device.
- Type
- antie.devices.mediaplayer.MediaPlayer
getLiveSupport() → {String}
Get the level of live support.
This will return the correct level of support for the current device.
- Source:
Returns:
Live support level matching a value in {antie.devices.mediaplayer.MediaPlayer.LIVE_SUPPORT}.
- Type
- String
getLogger()
Get the logging object for the current device.
- Source:
Returns:
The current device logging object.
getMediaPlayer() → {antie.devices.mediaplayer.MediaPlayer}
Get the media player.
This will return the correct implementation for the current device.
- Source:
Returns:
Media player for the current device.
- Type
- antie.devices.mediaplayer.MediaPlayer
getMuted()
Check to see if the volume is currently muted.
- Source:
Returns:
Boolean true if the device is currently muted. Otherwise false.
getPlayerEmbedMode(mediaType)
Gets the player embed mode for the current device
Parameters:
Name | Type | Description |
---|---|---|
mediaType |
String | "video" or "radio". |
- Source:
Returns:
The embed mode of the current player
getReferrer()
Gets the reference (e.g. URL) of the resource that launched the application.
- Source:
Returns:
A reference (e.g. URL) of the resource that launched the application.
getScreenSize()
Gets the available screen size.
- Source:
Returns:
An object with width and height properties.
getStorage(storageType, namespace)
Get a storage provider of a given type for the specified namespace.
Parameters:
Name | Type | Description |
---|---|---|
storageType |
Number | The type of storage required (either StorageProvider.STORAGE_TYPE_SESSION or StorageProvider.STORAGE_TYPE_PERSISTENT ). |
namespace |
String | The storage namespace. |
- Source:
Returns:
StorageProvider object.
getStylesheetElements()
Returns all the loaded stylesheet elements.
- Source:
Returns:
An array containing all loaded stylesheet elements (link and style elements)
getTopLevelElement()
Returns the top-level element. This is the target of layout class names.
- Source:
Returns:
The top-level DOM element.
getVolume()
Get the current volume.
- Source:
Returns:
The current volume (0.0 to 1.0)
getWindowLocation() → {Object}
Get an object giving access to the current URL, query string, hash etc.
- Source:
Returns:
Object containing, at a minimum, the properties:
hash, host, href, pathname, protocol, search. These correspond to the properties
in the window.location DOM API.
Use getCurrentAppURL(), getCurrentAppURLParams() and getCurrentRoute() to get
this information in a more generic way.
- Type
- Object
hideElement(options) → {Object}
Hides an element.
Note: fps parameter currently only implemented when using styletopleft animation modifier.
Consider using higher-level methods on the widget you want to hide (e.g. Component.hide()).
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Details of the element to be hidden, with optional parameters.
Properties
|
- Source:
- See:
Returns:
A handle to any animation started.
- Type
- Object
isAnimationDisabled() → {Boolean}
Check to see whether device has disabled animation.
- Source:
Returns:
true if animation is disabled, false if animation is not disabled.
- Type
- Boolean
isBroadcastSourceSupported() → {Boolean}
Check to see whether the device has an API to control broadcast television.
- Source:
Returns:
true if the API is available, false if not.
- Type
- Boolean
isHDEnabled()
Checks to see if HD output is currently enabled.
- Source:
Returns:
True if HD is currently enabled.
isVolumeControlSupported()
Check to see if volume control is supported on this device.
- Source:
Returns:
Boolean true if volume control is supported.
loadAuthenticatedURL(url, opts)
Loads a resource from a URL protected by device authentication.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The URL to load. |
opts |
Object | Object containing onLoad and onError callback functions. |
- Source:
Returns:
The request object used to load the resource.
loadScript(url, callbackFunctionRegExp, callbacks, timeout, callbackSuffixopt)
Loads an external script that calls a specified callback function.
Used for loading data via JSON-P.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
String | The URL of the script. | |
callbackFunctionRegExp |
RegExp | Regular expression to replace matches with callback function name. | |
callbacks |
Object | Object containing onSuccess and onLoad callback functions. | |
timeout |
Integer | Timeout in milliseconds. | |
callbackSuffix |
String |
<optional> |
Suffix to append to end of callback function name. |
- Source:
Returns:
The script element that will load the script.
loadStyleSheet(url, callbackopt)
Loads an external style sheet.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
String | The URL of the style sheet. | |
callback |
function |
<optional> |
Callback function when style has loaded/failed |
- Source:
Returns:
The link element that will load the style sheet.
loadURL(url, opts) → {XMLHttpRequest}
Loads a resource from a URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The URL to load. |
opts |
Object | Object containing onLoad and onError callback functions. |
- Source:
Returns:
The request object used to load the resource.
- Type
- XMLHttpRequest
moveElementTo(options) → {Object}
Moves an element so that its top-left corner is at the given position.
Note: fps parameter currently only implemented when using styletopleft animation modifier.
Consider using any animation methods on the widget you want to move. This method may be deprecated in future.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
- See:
Returns:
A handle to any animation started
- Type
- Object
preloadImage(url)
Forces the device to pre-load an image.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | The URL of the image to preload. |
- Source:
removeClassFromElement(el, className, deepopt)
Removes a class from an element (and optionally descendants)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
el |
Element | The element from which to remove the class. | |
className |
String | The class to remove. | |
deep |
Boolean |
<optional> |
If true, and this element has the given class, remove the class from it's children recursively. |
- Source:
scrollElementTo(options) → {Object}
Scroll an element (within some masking container) so that its top-left corner is at the given position.
Note: fps parameter currently only implemented when using styletopleft animation modifier.
Consider using scrolling methods on the widget you wish to scroll (e.g. carousels). This method may be deprecated in future.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
- See:
Returns:
A handle to any animation started
- Type
- Object
setApplication(application)
Set a reference to the application the device is running.
Parameters:
Name | Type | Description |
---|---|---|
application |
antie.Application | The application the device is running. |
- Source:
setCurrentRoute(route)
Sets the current route (a reference pointing to a location within the application).
Parameters:
Name | Type | Description |
---|---|---|
route |
Array | A route pointing to a location within the application. |
- Source:
setElementClasses(el, classNames)
Sets the classes of an element.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element which will receive new class names. |
classNames |
Array | An array of class names. |
- Source:
setElementSize(el, size)
Sets the size of an element.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | The element of which to set the size. |
size |
Size | The new size of the element. |
- Source:
setMuted(muted)
Mute or unmute the device.
Parameters:
Name | Type | Description |
---|---|---|
muted |
Boolean | The new muted state. Boolean true to mute, false to unmute. |
- Source:
setVolume(volume)
Set the current volume.
Parameters:
Name | Type | Description |
---|---|---|
volume |
Float | The new volume level (0.0 to 1.0). |
- Source:
setWindowLocationUrl(url)
Browse to the specified location. Use launchAppFromURL() and setCurrentRoute() under Application
to manipulate the current location more easily.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | Full URL to navigate to, including search and hash if applicable. |
- Source:
showElement(options) → {Object}
Shows an element.
Note: fps and easing parameters only used by styletopleft modifier.
Consider using higher-level methods on the widget you want to show (e.g. ComponentContainer.show()).
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Details of the element to be shown, with optional parameters.
Properties
|
- Source:
- See:
Returns:
A handle to any animation started.
- Type
- Object
stopAnimation(anim)
Stops the specified animation. The any completeHandler for the animation will be executed.
Parameters:
Name | Type | Description |
---|---|---|
anim |
object | A handle to the animation you wish to stop. |
- Source:
tweenElementStyle(options) → {Object}
Tweens a property (or properties) of an element's style from one value to another.
Note: fps parameter currently only implemented when using styletopleft animation modifier.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Details of the element whose style will be tweened, with parameters describing tween.
Properties
|
- Source:
Returns:
A handle to animation started. This should only be used for passing to stopAnimation and nothing else should be inferred by its value. If no animation occurs, null may be returned but should not be used as an indicator.
- Type
- Object