Zebra API Doc

zebra.ui.BaseList Class

Extends zebra.ui.Panel

Base UI list component class that has to be extended with a concrete list component implementation. The list component visualizes list data model (zebra.data.ListModel).

Methods

$select

(
  • o
)
protected

Select the given list item. The method is called when an item selection is triggered by a user interaction: key board, or mouse

Parameters:

  • o Integer

    an item index

calcMaxItemSize

() Integer protected

Calculate maximal width and maximal height the items in the list have


Return: Integer

a max items size

drawView

(
  • g
  • id
  • x
  • y
  • w
  • h
)
protected

Draw the given list view element identified by the given id at the specified location.

Parameters:

  • g 2DGraphics

    a graphical context

  • id String

    a view id

  • x Integer

    a x coordinate the view has to be drawn

  • y Integer

    a y coordinate the view has to be drawn

  • w Integer

    a view width

  • h Integer

    a view height

drawViewAt

(
  • g
  • id
  • index
)
protected

Draw the given list view element identified by the given id on the given list item.

Parameters:

  • g 2DGraphics

    a graphical context

  • id String

    a view id

  • index Integer

    a list item index

findSelectable

(
  • off
  • d
)
Integer protected

Find a next selectable list item starting from the given offset with the specified direction

Parameters:

  • off Integer

    a start item index to perform search

  • d Integer

    a direction increment. Cam be -1 or 1


Return: Integer

a next selectable item index

fireSelected

(
  • prev
)
protected

Fire selected event

Parameters:

  • prev Integer | Null

    a previous selected item index. null if the same item has been re-selected

getItemIdxAt

(
  • x
  • y
)
Integer

Detect an item by the specified location

Parameters:

  • x Integer

    a x coordinate

  • y Integer

    a y coordinate


Return: Integer

a list item that is located at the given position. -1 if no any list item can be found.

getItemLocation

(
  • i
)
Object

Return the given list item location.

Parameters:

  • i Integer

    a list item index


Return: Object

a location of the list item. The result is object that has the following structure: { x:{Integer}, y:{Integer} }

getItemSize

(
  • i
)
Object

Return the given list item size.

Parameters:

  • i Integer

    a list item index


Return: Object

a size of the list item. The result is object that has the following structure: { width:{Integer}, height:{Integer} }

getSelected

() Object

Get selected list item


Return: Object

an item

getValue

() Object

Get the list component selected item


Return: Object

a selected item

isItemSelectable

(
  • i
)
Boolean

Test if the given item is selectable.

Parameters:

  • i Integer

    an item index


Return: Boolean

true if the given item is selectable

isSelected

(
  • i
)
Boolean

Test if the given list item is selected

Parameters:

  • i Integer

    an item index


Return: Boolean

true if the item with the given index is selected

keyTyped

(
  • e
)

Define key typed events handler

Parameters:

pageSize

(
  • d
)
Integer protected

The method returns the page size that has to be scroll up or down

Parameters:

  • d Integer

    a scrolling direction. -1 means scroll up, 1 means scroll down


Return: Integer

a number of list items to be scrolled

pointerMoved

(
  • x
  • y
)
protected

Called when a pointer (mouse or finger on touch screen) is moved to a new location

Parameters:

  • x Integer

    a pointer x coordinate

  • y Integer

    a pointer y coordinate

repaintByOffsets

(
  • p
  • n
)
protected

Force repainting of the given list items

Parameters:

  • p Integer

    an index of the first list item to be repainted

  • n Integer

    an index of the second list item to be repainted

select

(
  • index
)

Select the given list item

Parameters:

  • index Integer

    an item index to be selected

setModel

(
  • m
)
chainable

Set the list model to be rendered with the list component

Parameters:

setPosition

(
  • c
)

Set the given position controller. List component uses position to track virtual cursor.

Parameters:

setValue

(
  • v
)
Integer

Select the specified list item.

Parameters:

  • v Object

    a list item to be selected. Use null as the parameter value to clean an item selection


Return: Integer

an index of a selected item

setViewProvider

(
  • v
)

Set the list items view provider. Defining a view provider allows developers to customize list item rendering.

Parameters:

  • v Object | Function

    a view provider class instance or a function that says which view has to be used for the given list model data. The function has to satisfy the following method signature: "function(list, modelItem, index)"

setViews

(
  • views
)

Sets the views for the list visual elements. The following elements are supported:

   - "select" -  a selection view element   
   - "top.marker" - a position marker view element that is rendered  on top of list item
   - "marker" - a position marker view element

Parameters:

  • views Object

    view elements

Attributes

isComboMode

Boolean readonly

Indicate the current mode the list items selection has to work

Default: false

model

zebra.data.ListModel readonly

List model the component visualizes

model

readonly

List model

scrollManager

zebra.ui.ScrollManager protected readonly

Scroll manager

selectedIndex

Integer readonly

Currently selected list item index

Default: -1

Events

selected

Fire when a list item has been selected:

   list.bind(function (src, prev) {
       ...
   });

Event Parameters:

  • src zebra.ui.BaseList

    a list that triggers the event

  • prev Integer | Object

    a previous selected index, return null if the selected item has been re-selected