Google TV

Google TV Closure UI Lib Reference (1.0)

This is the API reference for the Google TV Closure UI Library.

The library code can be found at: http://code.google.com/p/gtv-ui-lib

Library Reference

Table of Contents

Class tv.ui.Button

Extends .

Field Summary

object onAction
Handles action event.
 

Constructor Summary

tv.ui.Button()
Constructs button.
 

Method Summary

decorate(element)
getClass()
 boolean isEager()
onClick(event)
Handles click event.
onKey(event)
Handles key event.
onMouseDown(event)
 

Field Detail

onAction

object onAction
    Handles action event. To be used in subclasses.

Constructor Detail

tv.ui.Button

tv.ui.Button()
    Constructs button.

Method Detail

decorate

decorate(element)
    Parameters:
      element

getClass

getClass()

isEager

boolean isEager()
    Returns:
      boolean  Whether ACTION event is dispatched on mouse down.

onClick

onClick(event)
    Handles click event. Dispatches ACTION event.
    Parameters:
      goog.events.Event event - Click event.

onKey

onKey(event)
    Handles key event. Dispatches ACTION event if Enter is pressed.
    Parameters:
      goog.events.KeyEvent event - Key event.

onMouseDown

onMouseDown(event)
    Parameters:
      event

Back to top

Class tv.ui.Component

Extends .

Field Summary

object onKey
Handles key event.
 

Constructor Summary

tv.ui.Component()
Constructs component.
 

Method Summary

decorate(element)
Decorates given DOM element and makes it root element for component.
dispatchBlur_()
Called by tv.ui.Document when component loses focus.
dispatchFocus_()
Called by tv.ui.Document when component gains focus.
dispatchKey_(event)
Called by tv.ui.Document on focused component when document receives key event.
disposeInternal()
 string getClass()
 tv.ui.Document getDocument()
 Element getElement()
 goog.events.EventHandler getEventHandler()
 tv.ui.Container getParent()
 tv.ui.Component getSelectedDescendantOrSelf()
 boolean isEnabled()
 boolean isFocused()
 boolean isVisible()
onBlur(event)
Handles blur event.
onFocus(event)
Handles focus event.
onMouseDown(event)
Handles mouse down event.
render()
Updates styles and layout according to state of component.
scheduleRender()
Schedules eventual rendering of component.
 boolean selectFirstChild()
Does nothing for non-container components.
setParent(parent)
setVisible(visible)
 

Field Detail

onKey

object onKey
    Handles key event. To be used in subclasses.

Constructor Detail

tv.ui.Component

tv.ui.Component()
    Constructs component.

Method Detail

decorate

decorate(element)
    Decorates given DOM element and makes it root element for component.
    Parameters:
      Element element - DOM element to decorate.

dispatchBlur_

dispatchBlur_()
    Called by tv.ui.Document when component loses focus.

dispatchFocus_

dispatchFocus_()
    Called by tv.ui.Document when component gains focus.

dispatchKey_

dispatchKey_(event)
    Called by tv.ui.Document on focused component when document receives key event.
    Parameters:
      goog.events.KeyEvent event - Key event. Warning: method is destructive against event object.

disposeInternal

disposeInternal()

getClass

string getClass()
    Returns:
      string  Main CSS class that triggers decoration.

getDocument

tv.ui.Document getDocument()
    Returns:
      tv.ui.Document  Document where component is located.

getElement

Element getElement()
    Returns:
      Element  Root DOM element of component.

getEventHandler

goog.events.EventHandler getEventHandler()
    Returns:
      goog.events.EventHandler  Event handler.

getParent

tv.ui.Container getParent()
    Returns:
      tv.ui.Container  Parent container.

getSelectedDescendantOrSelf

tv.ui.Component getSelectedDescendantOrSelf()
    Returns:
      tv.ui.Component  Self, or null if component cannot accept focus.

isEnabled

boolean isEnabled()
    Returns:
      boolean  Whether component can be selected.

isFocused

boolean isFocused()
    Returns:
      boolean  Whether element is focused.

isVisible

boolean isVisible()
    Returns:
      boolean  Whether component is visible.

onBlur

onBlur(event)
    Handles blur event.
    Parameters:
      goog.events.Event event - Blur event.

onFocus

onFocus(event)
    Handles focus event.
    Parameters:
      goog.events.Event event - Focus event.

onMouseDown

onMouseDown(event)
    Handles mouse down event.
    Parameters:
      goog.events.Event event - Mouse down event.

render

render()
    Updates styles and layout according to state of component. Supposed to be used for computation-heavy updates that are too costly to call after every state mutation.

scheduleRender

scheduleRender()
    Schedules eventual rendering of component. Render is performed only once, no matter how many times it was scheduled.

selectFirstChild

boolean selectFirstChild()
    Does nothing for non-container components. Used solely because of return value.
    Returns:
      boolean  True if component can be selected.

setParent

setParent(parent)
    Parameters:
      tv.ui.Container parent - Sets parent container.

setVisible

setVisible(visible)
    Parameters:
      boolean visible - Sets whether component is visible.

Back to top

Class tv.ui.Container

Extends .

Constructor Summary

tv.ui.Container()
Constructs container.
 

Method Summary

addChild(child)
Adds child component.
decorate(element)
disposeInternal()
 Array.<tv.ui.Component> getChildren()
getClass()
 Element getHighlightElement()
 tv.ui.Component getSelectedChild()
 tv.ui.Component getSelectedDescendantOrSelf()
 boolean isHorizontal()
 boolean isStack()
 boolean isVertical()
onBlur(event)
Handles blur event.
onChildSelectabilityChange(child)
Updates selected child if necessary.
onChildVisibilityChange(child)
Updates DOM styles.
onFocus(event)
Handles focus event.
onKey(event)
Handles key event.
removeChildren()
Removes all child components.
render()
 boolean selectFirstChild()
Tries to select one of the child components starting from first one.
 boolean selectNextChild()
Tries to select one of the child components after currently selected one.
 boolean selectPreviousChild()
Tries to select one of the child components before currently selected one.
setHighlightElement(highlightElement)
Sets highlight element.
setSelectedChild(selectedChild)
 

Constructor Detail

tv.ui.Container

tv.ui.Container()
    Constructs container.

Method Detail

addChild

addChild(child)
    Adds child component.
    Parameters:
      tv.ui.Component child - Child component.

decorate

decorate(element)
    Parameters:
      element

disposeInternal

disposeInternal()

getChildren

Array.<tv.ui.Component> getChildren()
    Returns:
      Array.<tv.ui.Component>  List of children.

getClass

getClass()

getHighlightElement

Element getHighlightElement()
    Returns:
      Element  Highlight element.

getSelectedChild

tv.ui.Component getSelectedChild()
    Returns:
      tv.ui.Component  Currently selected child. Guaranteed to be focusable or have focusable child selected.

getSelectedDescendantOrSelf

tv.ui.Component getSelectedDescendantOrSelf()
    Returns:
      tv.ui.Component  Selected grand-...-grandchild, or null if no child is selected.

isHorizontal

boolean isHorizontal()
    Returns:
      boolean  Whether container has horizontal orientation.

isStack

boolean isStack()
    Returns:
      boolean  Whether container has stack orientation.

isVertical

boolean isVertical()
    Returns:
      boolean  Whether container has vertical orientation.

onBlur

onBlur(event)
    Handles blur event. Exits mode when container is allowed to control external highlight and updates look of highlight element.
    Parameters:
      event

onChildSelectabilityChange

onChildSelectabilityChange(child)
    Updates selected child if necessary. Called by child component to notify parent container that one of conditions affecting selected child choice has changed.
    Parameters:
      tv.ui.Component child - Child component which property has changed.

onChildVisibilityChange

onChildVisibilityChange(child)
    Updates DOM styles. Called by child component to notify parent container that its visibility has changed.
    Parameters:
      tv.ui.Component child - Child component which visibility has changed.

onFocus

onFocus(event)
    Handles focus event. Enters mode when container is allowed to control external highlight and updates position and look of highlight element.
    Parameters:
      event

onKey

onKey(event)
    Handles key event. Controls child component focus.
    Parameters:
      goog.events.KeyEvent event - Key event.

removeChildren

removeChildren()
    Removes all child components.

render

render()

selectFirstChild

boolean selectFirstChild()
    Tries to select one of the child components starting from first one. Only components that can receive focus (or have children that can receive focus) are qualified.
    Returns:
      boolean  Whether focusable child has been found.

selectNextChild

boolean selectNextChild()
    Tries to select one of the child components after currently selected one. Only components that can receive focus (or have children that can receive focus) are qualified.
    Returns:
      boolean  Whether selection changed.

selectPreviousChild

boolean selectPreviousChild()
    Tries to select one of the child components before currently selected one. Only components that can receive focus (or have children that can receive focus) are qualified.
    Returns:
      boolean  Whether selection changed.

setHighlightElement

setHighlightElement(highlightElement)
    Sets highlight element. This method is the only way to set external highlight element.
    Parameters:
      Element highlightElement - highlight element.

setSelectedChild

setSelectedChild(selectedChild)
    Parameters:
      tv.ui.Component selectedChild - Sets currently selected child.

Back to top

Class tv.ui.DecorateHandler

Constructor Summary

tv.ui.DecorateHandler(opt_context)
Creates handler.
 

Method Summary

addClassHandler(className, handler)
Adds handler to be called when element with specific CSS class is decorated.
addIdHandler(id, handler)
Adds handler to be called when element with specific id is decorated.
 Function getHandler()
 

Constructor Detail

tv.ui.DecorateHandler

tv.ui.DecorateHandler(opt_context)
    Creates handler.
    Parameters:
      Object= opt_context - Context to call handlers in.

Method Detail

addClassHandler

addClassHandler(className, handler)
    Adds handler to be called when element with specific CSS class is decorated.
    Parameters:
      string className - CSS class name.
      Function handler - Handler to call.

addIdHandler

addIdHandler(id, handler)
    Adds handler to be called when element with specific id is decorated.
    Parameters:
      string id - Element id.
      Function handler - Handler to call.

getHandler

Function getHandler()
    Returns:
      Function  Handler to pass to tv.ui.decorate() function.

Back to top

Class tv.ui.Grid

Extends .

Constructor Summary

tv.ui.Grid()
Constructs grid.
 

Method Summary

addChild(child)
getClass()
 

Constructor Detail

tv.ui.Grid

tv.ui.Grid()
    Constructs grid.

Method Detail

addChild

addChild(child)
    Parameters:
      child

getClass

getClass()

Back to top

Class tv.ui.Input

Extends .

Constructor Summary

tv.ui.Input()
Constructs input.
 

Method Summary

decorate(element)
disposeInternal()
getClass()
 Element getInputElement()
onBlur(event)
onFocus(event)
onInput(event)
Handles input event.
onKey(event)
Handles key event.
 

Constructor Detail

tv.ui.Input

tv.ui.Input()
    Constructs input.

Method Detail

decorate

decorate(element)
    Parameters:
      element

disposeInternal

disposeInternal()

getClass

getClass()

getInputElement

Element getInputElement()
    Returns:
      Element  'input' element.

onBlur

onBlur(event)
    Parameters:
      event

onFocus

onFocus(event)
    Parameters:
      event

onInput

onInput(event)
    Handles input event.
    Parameters:
      goog.events.BrowserEvent event - Input event.

onKey

onKey(event)
    Handles key event. Consumes navigation keys if cursor is not on the boundaries of input.
    Parameters:
      goog.events.KeyEvent event - Key event.

Back to top

Class tv.ui.Lightbox

Extends .

Field Summary

Element backgroundElement_
Acompanion background element put under lightbox container.
 

Constructor Summary

tv.ui.Lightbox()
Constructs photo lightbox.
 

Method Summary

disposeInternal()
Disposes lightbox.
onKey(event)
 

Field Detail

backgroundElement_

Element backgroundElement_
    Acompanion background element put under lightbox container.

Constructor Detail

tv.ui.Lightbox

tv.ui.Lightbox()
    Constructs photo lightbox.

Method Detail

disposeInternal

disposeInternal()
    Disposes lightbox. Removes from document background and conaiter elements.

onKey

onKey(event)
    Parameters:
      event

Back to top

Class tv.ui.Link

Extends .

Constructor Summary

tv.ui.Link()
Constructs button.
 

Method Summary

getClass()
onAction(event)
Handles action event.
 

Constructor Detail

tv.ui.Link

tv.ui.Link()
    Constructs button.

Method Detail

getClass

getClass()

onAction

onAction(event)
    Handles action event. Follows the hyperlink.
    Parameters:
      goog.events.Event event - Action event.

Back to top

Class tv.ui.Menu

Extends .

Constructor Summary

tv.ui.Menu()
Constructs menu.
 

Method Summary

addChild(child)
getClass()
onBarAction(event)
Handles action event on tab bar.
onBarFocus(event)
onBarSelectChild(event)
onContentAction(event)
Handles action event on tab content.
onContentKey(event)
Handles key event on tab content.
 

Constructor Detail

tv.ui.Menu

tv.ui.Menu()
    Constructs menu.

Method Detail

addChild

addChild(child)
    Parameters:
      child

getClass

getClass()

onBarAction

onBarAction(event)
    Handles action event on tab bar. Focuses sub-menu that corresponds to selected menu item.
    Parameters:
      goog.events.Event event - Action event.

onBarFocus

onBarFocus(event)
    Parameters:
      event

onBarSelectChild

onBarSelectChild(event)
    Parameters:
      event

onContentAction

onContentAction(event)
    Handles action event on tab content. Focuses menu item that corresponds to selected sub-menu if 'Back' button was pressed.
    Parameters:
      goog.events.Event event - Action event.

onContentKey

onContentKey(event)
    Handles key event on tab content. Focuses menu item that corresponds to selected sub-menu if Esc is pressed.
    Parameters:
      goog.events.KeyEvent event - Key event.

Back to top

Class tv.ui.TabContainer

Extends .

Constructor Summary

tv.ui.TabContainer()
Constructs tab container.
 

Method Summary

addChild(child)
 tv.ui.Container getBarContainer()
getClass()
 tv.ui.Container getContentContainer()
 boolean hasFocusAttractor()
onBarFocus(event)
Handles focus on bar container.
onBarSelectChild()
Handles child selection in bar container.
onContentSelectChild()
Handles child selection in content container.
selectNextChild()
selectPreviousChild()
tryFocusSelectedDescendant(component)
Focuses given component if it is able to receive focus.
 

Constructor Detail

tv.ui.TabContainer

tv.ui.TabContainer()
    Constructs tab container.

Method Detail

addChild

addChild(child)
    Parameters:
      child

getBarContainer

tv.ui.Container getBarContainer()
    Returns:
      tv.ui.Container  Bar container.

getClass

getClass()

getContentContainer

tv.ui.Container getContentContainer()
    Returns:
      tv.ui.Container  Content container.

hasFocusAttractor

boolean hasFocusAttractor()
    Returns:
      boolean  Whether tab content container is focus attractor.

onBarFocus

onBarFocus(event)
    Handles focus on bar container.
    Parameters:
      event

onBarSelectChild

onBarSelectChild()
    Handles child selection in bar container.

onContentSelectChild

onContentSelectChild()
    Handles child selection in content container.

selectNextChild

selectNextChild()

selectPreviousChild

selectPreviousChild()

tryFocusSelectedDescendant

tryFocusSelectedDescendant(component)
    Focuses given component if it is able to receive focus. Does nothing otherwise.
    Parameters:
      goog.ui.Component component - Component to focus.

Back to top

Class tv.ui.ToggleButton

Extends .

Constructor Summary

tv.ui.ToggleButton()
Constructs button.
 

Method Summary

getClass()
 boolean isOn()
onAction(event)
Handles action event.
setOn(on)
Sets on/off state.
 

Constructor Detail

tv.ui.ToggleButton

tv.ui.ToggleButton()
    Constructs button.

Method Detail

getClass

getClass()

isOn

boolean isOn()
    Returns:
      boolean  Whether button is in 'on' state.

onAction

onAction(event)
    Handles action event. Toggles button state.
    Parameters:
      goog.events.Event event - Action event.

setOn

setOn(on)
    Sets on/off state.
    Parameters:
      boolean on - Button state.

Back to top

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.