handler

A minimalistic Event handling library for Apple TV applications
Author:
Source:

Methods

(static) addAll(doc, cfg)

Sets the event handlers as per the event configuration. Also adds the default page level handlers.
Source:
Parameters:
Name Type Description
doc Document The page document.
cfg Obejct Page configuration object

(static) addListeners(doc, cfg)

Iterates over the events configuration and add event listeners to the document.
Source:
To Do:
  • Implement querySelectorAll polyfill (it doesn't seem to exist on the xml document)
Parameters:
Name Type Description
doc Document The document to add the listeners on.
cfg Object The page object configuration.
Example
ATV.Handler.addListeners(tvmlDoc,
{
    events: {
        'scroll': function(e) { // do the magic here },
        'select listItemLockup title': 'onTitleSelect',
        'someOtherEvent': ['onTitleSelect', function(e) { // some other magic }, ...]
    },
    onTitleSelect: function(e) {
        // do the magic here
    }
});

(static) removeAll(doc, cfg)

Unset the event handlers as per the event configuration. Also removes the default page level handlers.
Source:
Parameters:
Name Type Description
doc Document The page document.
cfg Obejct Page configuration object

(static) removeListeners(doc, cfg)

Iterates over the events configuration and remove event listeners from document. ATV.Handler.removeListeners(tvmlDoc, { events: { 'scroll': function(e) { // do the magic here }, 'select listItemLockup title': 'onTitleSelect', 'someOtherEvent': ['onTitleSelect', function(e) { // some other magic }, ...] }, onTitleSelect: function(e) { // do the magic here } });
Source:
To Do:
  • Implement querySelectorAll polyfill (it doesn't seem to exist on the xml document)
Parameters:
Name Type Description
doc Document The document to add the listeners on.
cfg Object The page object configuration.

(static) setOptions(cfg)

Sets the default handlers options
Source:
Parameters:
Name Type Description
cfg Object The configuration object {defaults}