Class: Label

Label

new Label(idopt, textopt)

The Label widget displays text. It supports auto-truncation (with ellipsis) of text to fit.
Parameters:
Name Type Attributes Description
id String <optional>
The unique ID of the widget. If excluded, a temporary internal ID will be used (but not included in any output).
text String <optional>
The text content of this label.
Source:

Extends

Members

(static, constant) TRUNCATION_MODE_NONE

Do not truncate the text. Let the browser wrap to as many lines required to display all the text.
Source:

(static, constant) TRUNCATION_MODE_RIGHT_ELLIPSIS

Truncate text to fit into the number of lines specified by antie.widgets.Label#setMaximumLines by removing characters at the end of the string and append an ellipsis if text is truncated.
Source:

Methods

addClass(className)

Adds a CSS class to the widget if not already present.
Parameters:
Name Type Description
className String The class name to add.
Inherited From:
Source:

addEventListener(ev, func)

Add an event listener function to this widget.
Parameters:
Name Type Description
ev String The event type to listen for (e.g. keydown)
func function The handler to be called when the event is fired.
Inherited From:
Source:
See:

broadcastEvent(ev)

Broadcast an event from object, triggering any event listeners bound to this widget and any parent widgets. To halt bubbling of the event, see antie.events.Event#stopPropagation.
Parameters:
Name Type Description
ev antie.events.Event The event to bubble.
Inherited From:
Source:
See:

bubbleEvent(ev)

Bubbles an event from object, triggering any event listeners bound to this widget and any parent widgets. To halt bubbling of the event, see antie.events.Event#stopPropagation.
Parameters:
Name Type Description
ev antie.events.Event The event to bubble.
Inherited From:
Source:
See:

fireEvent(ev)

Fires an event on this object, triggering any event listeners bound to this widget only. Note: this does not bubble or propagate the event to other widgets, for that functionality see #bubbleEvent.
Parameters:
Name Type Description
ev antie.events.Event The event to fire.
Inherited From:
Source:
See:

getClasses()

Get an array of class names that this widget has.
Inherited From:
Source:
Returns:
An array of class names (Strings)

getComponent()

Returns the component this widget is a descendant of
Inherited From:
Source:

getCurrentApplication()

Gets a reference to the application responsible for creating the widget.
Inherited From:
Source:
See:
  • antie.RuntimeContext

getDataItem()

Get any data item associated with this widget.
Inherited From:
Source:

getText()

Gets the current text displayed by this label.
Source:
Returns:
The current text displayed by this label.

getTextAsRendered(device)

Will return text as rendered on the device
Parameters:
Name Type Description
device antie.devices.Device The device to render to.
Source:
Returns:
A string that will be displayed in the label after truncation, etc...

hasClass(className)

Checks to see if the widget has a given CSS class.
Parameters:
Name Type Description
className String The class name to check.
Inherited From:
Source:
Returns:
Boolean true if the device has the className. Otherwise boolean false.

hide(options)

Hides a widget. If animation is enabled the widget will be faded out of view.
Parameters:
Name Type Description
options Object Details of the element to be shown, with optional parameters.
Properties
Name Type Attributes Default Description
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:
Returns:
Boolean true if animation was called, otherwise false

isComponent() → {Boolean}

Returns whether the widget is a Component.
Inherited From:
Source:
Returns:
True if the widget is a Component.
Type
Boolean

isFocusable()

Checks to see if a widget is focussable, i.e. contains an enabled button.
Inherited From:
Source:
See:

isFocussed()

Get if this widget is in the current focus path.
Inherited From:
Source:
Returns:
Boolean true if this widget is in the focus path, otherwise false.

moveTo(options)

Moves a widget so that its top-left corner is at the given position.
Parameters:
Name Type Description
options Object Details of the element to be shown, with optional parameters.
Properties
Name Type Attributes Default Description
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:
Returns:
Boolean true if animation was called, otherwise false

removeClass(className)

Removes a CSS class from the widget if present.
Parameters:
Name Type Description
className String The class name to remove.
Inherited From:
Source:

removeEventListener(ev, func)

Removes an event listener function to this widget.
Parameters:
Name Type Description
ev String The event type that the listener is to be removed from (e.g. keydown)
func function The handler to be removed.
Inherited From:
Source:
See:

removeFocus()

Remove focus state from this widget.
Inherited From:
Source:

render(device)

Renders the widget and any child widgets to device-specific output.
Parameters:
Name Type Description
device antie.devices.Device The device to render to.
Overrides:
Source:
Returns:
A device-specific object that represents the widget as displayed on the device (in a browser, a DOMElement);

setDataItem(dataItem)

Associate a data item with this widget.
Parameters:
Name Type Description
dataItem object Object to associate with this widget.
Inherited From:
Source:

setMaximumLines(lines)

Sets the maximum lines displayed when a truncation mode is set.
Parameters:
Name Type Description
lines String The maximum number of lines to display.
Source:

setText(text)

Sets the text displayed by this label.
Parameters:
Name Type Description
text String The new text to be displayed.
Source:

setTruncationMode(mode)

Parameters:
Name Type Description
mode String The new truncation mode.
Deprecated:
  • TRUNCATION_MODE_RIGHT_ELLIPSIS relies on browserdevice.getTextHeight(), which can be inaccurate.
Source:

setWidth(width)

Sets the width of this label for use with truncation only.
Parameters:
Name Type Description
width Integer The width of this label in pixels
Source:

show(options)

Shows a widget. If animation is enabled the widget will be faded in.
Parameters:
Name Type Description
options Object Details of the element to be shown, with optional parameters.
Properties
Name Type Attributes Default Description
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:
Returns:
Boolean true if animation was called, otherwise false