Class: BrowserDevice

.devices.BrowserDevice

new BrowserDevice(config)

Base class for Antie browser-based devices.
Parameters:
Name Type Description
config Object Device configuration document.
Source:
Requires:
  • module:antie.events.KeyEvent

Extends

Requires

  • module:antie.events.KeyEvent

Methods

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.
Overrides:
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.
Overrides:
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.
Overrides:
Source:

clearElement(el)

Clears the content of an element.
Parameters:
Name Type Description
el Element The element you are removing the content from.
Source:

cloneElement(el, deepopt, appendClassopt, appendIDopt)

Clones an element.
Parameters:
Name Type Attributes Description
el Element The element to clone.
deep Boolean <optional>
If true, children are also cloned recursively.
appendClass String <optional>
Append this class name to the clone (top level only).
appendID String <optional>
Append this string to the ID of the clone (top level only).
Source:
Returns:
The clone.

createBroadcastSource() → {Object}

Create a new widget giving control over broadcast television. Check whether the broadcast television API is available first with isBroadcastSourceSupported().
Inherited From:
Source:
See:
  • antie.widgets.broadcastsource
Returns:
Device-specific implementation of antie.widgets.broadcastsource
Type
Object

createButton(idopt, classNamesopt)

CreatesetElementContent a button (an element that can be selected by the user to perform an action) in the device's user-agent.
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.
Overrides:
Source:
Returns:
A button within the device's user-agent.

createContainer(idopt, classNamesopt)

Creates a generic container element in the device's user-agent.
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.
Overrides:
Source:
Returns:
A container element within the device's user-agent.

createImage(idopt, classNamesopt, src, sizeopt)

Creates an image in the device's user-agent.
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.
size Size <optional>
The size of the image.
Overrides:
Source:
Returns:
An image within the device's user-agent.

createLabel(idopt, classNamesopt, textopt)

Creates a label (an element that only contains text) in the device's user-agent.
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.
Overrides:
Source:
Returns:
A label within the device's user-agent.

createList(idopt, classNamesopt)

Creates a list in the device's user-agent.
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.
Overrides:
Source:
Returns:
A list within the device's user-agent.

createListItem(idopt, classNamesopt)

Creates a list item in the device's user-agent.
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.
Overrides:
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.
Inherited From:
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.
Inherited From:
Source:

decodeJson(json)

Decodes JSON.
Parameters:
Name Type Description
json String JSON to decode.
Inherited From:
Source:

encodeJson(obj)

Encodes an object as JSON.
Parameters:
Name Type Description
obj object Object to encode.
Inherited From:
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
Name Type Attributes Description
onSuccess function <optional>
Will be called with the decoded JSON object if the call is successful.
onError function <optional>
Will be called with error text, and HTTP status for CORS requests, if the calls fails.
bearerToken String <optional>
Used when making requests for resources that require authentication. For CORS requests, the token is used as a Bearer token in an Authorization header (see RFC 6750, section 2.1), and for JSON-P requests the token is included as a query string parameter. If not specified, no token is included in the request.
jsonpOptions Object <optional>
Options for the JSON-P fallback behaviour. All optional with sensible defaults.
Properties
Name Type Attributes Default Description
timeout Number <optional>
5000 Timeout for the JSON-P call in ms. Default: 5000.
id String <optional>
Used in the callback function name for the JSON-P call. Default: a random string.
callbackKey String <optional>
callback Key to use in query string when passing callback function name for JSON-P call. Default: callback
Inherited From:
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
Name Type Attributes Description
fieldName String Name to be used for the POST form field for form based (non-CORS) requests.
onLoad function <optional>
Will be called with the decoded JSON response if the POST is successful.
onError function <optional>
Will be called with error text or an Exception object if the POST fails.
bearerToken String <optional>
Used when making POST requests for resources that require authentication. For CORS requests, the token is used as a Bearer token in an Authorization header (see RFC 6750, section 2.1), and for form requests the token is included as a bearerToken form field value. If not specified, no token is included in the request.
Inherited From:
Source:

exit()

Exits the application directly - no history.
Inherited From:
Source:

exitToBroadcast()

Exits to broadcast if this function has been overloaded by a modifier. Otherwise, calls exit().
Inherited From:
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.
Overrides:
Source:
Returns:
An array of elements having the provided tag name.

getConfig()

Gets the current device configuration.
Inherited From:
Source:
Returns:
The current device configuration document.

getCurrentRoute()

Gets the current route (a reference pointing to a location within the application).
Overrides:
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.
Overrides:
Source:
Returns:
An literal object containing properties, top and left.

getElementParent(el)

Gets the parent element of a given element.
Parameters:
Name Type Description
el Element The element.
Source:
Returns:
The parent element.

getElementSize(el)

Gets the size of an element.
Parameters:
Name Type Description
el Element The element of which to return the size.
Overrides:
Source:
Returns:
A size object containing the width and height of the element.

getHistorian() → {antie.Historian}

gets historian for current location
Source:
Returns:
an object that can be used to get a back or forward url between applications while preserving history
Type
antie.Historian

getKeyMap()

Gets the current key map from the device configuration.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:
Returns:
Media player for the current device.
Type
antie.devices.mediaplayer.MediaPlayer

getMuted()

Check to see if the volume is currently muted.
Inherited From:
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".
Inherited From:
Source:
Returns:
The embed mode of the current player

getReferrer()

Gets the reference (e.g. URL) of the resource that launched the application.
Overrides:
Source:
Returns:
A reference (e.g. URL) of the resource that launched the application.

getScreenSize()

Gets the available browser screen size.
Overrides:
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.
Inherited From:
Source:
Returns:
StorageProvider object.

getStylesheetElements()

Returns all the loaded stylesheet elements.
Overrides:
Source:
Returns:
An array containing all stylesheet related DOM elements (link and style elements)

getTextHeight(text, maxWidth, classNames)

Get the height (in pixels) of a given block of text (of a provided set of class names) when constrained to a fixed width.
Parameters:
Name Type Description
text String The text to measure.
maxWidth Integer The width the text is constrained to.
classNames Array An array of class names which define the style of the text.
Deprecated:
  • This function does not always give accurate results. When measuring size, it only takes into account the classes on the text element being measured. It doesn't consider any CSS styles that may have been passed down through the DOM.
Source:
Returns:
The height (in pixels) that is required to display this block of text.

getTopLevelElement()

Returns the top-level element. This is the target of layout class names.
Overrides:
Source:
Returns:
The top-level DOM element.

getVolume()

Get the current volume.
Inherited From:
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.
Overrides:
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
Name Type Attributes Default Description
el Element The element you wish to hide.
skipAnim Boolean <optional>
By default the hiding of the element will be animated (faded out). Pass true here to prevent animation.
onComplete function <optional>
Callback function to be called when the element has been hidden.
fps Number <optional>
25 Frames per second for fade animation.
duration Number <optional>
840 Duration of fade animation, in milliseconds (ms).
easing String <optional>
linear Easing style for fade animation.
Inherited From:
Source:
See:
Returns:
A handle to any animation started.
Type
Object

insertChildElementAt(to, el, index)

Inserts an element as a child of another at the given index.
Parameters:
Name Type Description
to Element Append as a child of this element.
el Element The new child element.
index Integer The index at which the element will be inserted.
Source:

insertChildElementBefore(to, el, ref)

Inserts an element as a child of another before a reference element.
Parameters:
Name Type Description
to Element Append as a child of this element.
el Element The new child element.
ref Element The reference element which will appear after the inserted element.
Source:

isAnimationDisabled() → {Boolean}

Check to see whether device has disabled animation.
Inherited From:
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.
Inherited From:
Source:
Returns:
true if the API is available, false if not.
Type
Boolean

isHDEnabled()

Checks to see if HD output is currently enabled.
Overrides:
Source:
Returns:
True if HD is currently enabled.

isVolumeControlSupported()

Check to see if volume control is supported on this device.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Overrides:
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.
Inherited From:
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
Name Type Attributes Default Description
el Element The element you wish to move.
to.left Integer <optional>
The x-coordinate you wish to position the top-left corner on. If null, the x-coordinate will not be altered.
to.top Integer <optional>
The y-coordinate you wish to position the top-left corner on. If null, the y-coordinate will not be altered.
skipAnim Boolean <optional>
By default the movement will be animated, pass true here to prevent animation.
onComplete function <optional>
Callback function to be called when the move has been completed.
fps Number <optional>
25 Frames per second for move animation
duration Number <optional>
840 Duration of move animation in milliseconds (ms).
easing.linear String <optional>
Easing move for scroll animation.
Inherited From:
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.
Overrides:
Source:

prependChildElement(to, el)

Prepends an element as a child of another.
Parameters:
Name Type Description
to Element Prepend as a child of this element.
el Element The new child element.
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.
Overrides:
Source:

removeElement(el)

Removes an element from its parent.
Parameters:
Name Type Description
el Element The element to remove.
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
Name Type Attributes Default Description
el Element The element you wish to scroll.
to.left Integer <optional>
The x-coordinate you wish to position the top-left corner on. If null, the x-coordinate will not be altered.
to.top Integer <optional>
The y-coordinate you wish to position the top-left corner on. If null, the y-coordinate will not be altered.
skipAnim Boolean <optional>
By default the movement will be animated, pass true here to prevent animation.
onComplete function <optional>
Callback function to be called when the scroll has been completed.
fps Number <optional>
25 Frames per second for scroll animation
duration Number <optional>
840 Duration of scroll animation in milliseconds (ms).
easing.linear String <optional>
Easing move for scroll animation.
Inherited From:
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.
Inherited From:
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.
Overrides:
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.
Overrides:
Source:

setElementContent(el, content)

Sets the inner content of an element.
Parameters:
Name Type Description
el Element The element of which to change the content.
content String The new content for the element.
Source:

setElementPosition(el, size)

Sets the position of an element
Parameters:
Name Type Description
el Element The element of which to reposition.
size Size The new position of the element.
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.
Overrides:
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.
Inherited From:
Source:

setVolume(volume)

Set the current volume.
Parameters:
Name Type Description
volume Float The new volume level (0.0 to 1.0).
Inherited From:
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.
Overrides:
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
Name Type Attributes Default Description
el Element The element you wish to show.
skipAnim Boolean <optional>
By default the showing of the element will be animated (faded in). Pass true here to prevent animation.
onComplete function <optional>
Callback function to be called when the element has been shown.
fps Number <optional>
25 Frames per second for fade animation.
duration Number <optional>
840 Duration of fade animation, in milliseconds (ms).
easing String <optional>
linear Easing style for fade animation.
Inherited From:
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.
Inherited From:
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
Name Type Attributes Description
el Element The element with a style you wish to tween.
to Object A property: value map of the style properties you wish to tween and the numerical value of its destination, e.g { width: 30 }
duration: Number The duration of the tween in ms
from Object A property: value map of the style properties you wish to set at the start of the animation, e.g. { width: 0 }. If unset, the existing value will be used.
skipAnim Boolean <optional>
By default the tween will be animated. Set this to true for the tween to occur immediately. Any onComplete callback will still fire.
onComplete function <optional>
Callback function to be called when the tween is complete.
easing String <optional>
Easing style for animation.
units Object <optional>
Units to be appended to the style values in a property -> value map. (e.g. { width: 'px' }). Defaults are set in antie.devices.anim.shared.transitionendpoints
fps Number <optional>
Frames per second of animation (styletopleft only)
Inherited From:
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