vegui. list. class.js

Summary
vegUI element type for VegUIList
extends VegUIContentBox
These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element
the sItem property holds the selected item in the form of an object.
Constructor
Adds a HTML node as a new item to the list with a certain value attached
Wrapper function to add an item that contains an image and text
Wrapper function to add an item that contains on text
Adjusts the scrollbars of the list to the content over flow of the list.
Builds the list
Closes the list if the list is a dropdown list
Deselects the currently selected item(s), or the item submitted to the function.
Drops the item that is located at the submitted index in the childNodes array of the Table child’s HTML node
Sees if an item with a certain value exists
Clears the list of all items
Handles key press on the list element
Checks if the item with a certain value is selected
Expands the list if it is a dropdown list
Selects the first item that has the requested value
Selects the item with the submitted HTML node.
Selects items from item with value1 to item with value2
Sets the most common template properties for the list
Wrapper method to set the style class name attributes of this element
Returns the index of an item in the sItems property
Returns a string representation of the selection in the form of item values separated by a delimiter.
Scrolls the list to make sure a certain item is in point of view of the user

Constants

List Types

VUI_LISTTYPE_NORMALnormal list
VUI_LISTTYPE_DROPDOWNdrop down list
VUI_LISTTYPE_MULTImulti select list

VUI_LIST

vegUI element type for VegUIList

VegUIList

Summary
extends VegUIContentBox
These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element
the sItem property holds the selected item in the form of an object.
Constructor
Adds a HTML node as a new item to the list with a certain value attached
Wrapper function to add an item that contains an image and text
Wrapper function to add an item that contains on text
Adjusts the scrollbars of the list to the content over flow of the list.
Builds the list
Closes the list if the list is a dropdown list
Deselects the currently selected item(s), or the item submitted to the function.
Drops the item that is located at the submitted index in the childNodes array of the Table child’s HTML node
Sees if an item with a certain value exists
Clears the list of all items
Handles key press on the list element
Checks if the item with a certain value is selected
Expands the list if it is a dropdown list
Selects the first item that has the requested value
Selects the item with the submitted HTML node.
Selects items from item with value1 to item with value2
Sets the most common template properties for the list
Wrapper method to set the style class name attributes of this element
Returns the index of an item in the sItems property
Returns a string representation of the selection in the form of item values separated by a delimiter.
Scrolls the list to make sure a certain item is in point of view of the user

Hierarchy

extends VegUIContentBox

Inherits all properties and methods from VegUIContentBox

VegUINode
|
+-- VegUIContentBox
|
+-- VegUIList

Dependencies

filevegui.cbox.class.js
filevegui.scrollbar.class.js

Child Elements

These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element

<inherited>Children of VegUIContentBox
TableVegUINode, List table
BtnOpenVegUIButton, Button to open the dropdown list
SelITemLabelVegUINode, Label that shows what item is selected in a dropdown list

Events

onchangethe VegUINode::onchange event is called whenever an item gets selected

Item Object

the sItem property holds the selected item in the form of an object.  The object’s structure is this:

sItem.nodethe HTML node of the item
sItem.itemValuethe value of the item

Properties

Object Properties

itemsint, number of items in the list
sItemObject, holds the currently selected item
sItemsArray, holds the currently selected items if list is of type VUI_LISTTYPE_MULTI
sValuevariable, holding the value of the currently selected item
hItemobject, holds the currently hovered item
expandedSizeint, height of the list if expanded (dropdown mode only)
listTypeint, List Types
bSelectModebool, if true then list is currently in select mode where multiple items can be selected just be moving the mouse over them
mNormalstring, css class to use for items while not selected and not hovered by mouse
mOverstring, css class to use for items when mouse is hovering over them
mClickstring, css class to use for selected items
mOverSelectedstring, css class to use for hovering over selected items
mHeaderstring, css class to use for header items
blockTextSelectionbool, true by default, prevents text selection in the cells
blockKeyScrollingbool, if true prevents scrolling via arrow keys

Template Properties

T.itemHeightint, row height (pixels)
T.hint, in addition of being the height of the list it also sets the expandedSize property (pixels)
T.rowSpaceint, space between two rows (pixels)
T.listTypeint, listType
T.nullEntrybool, if true the item ‘-’ with value null will be added to the beginning of the list
T.mNormalmNormal
T.mOvermOver
T.mClickmClick
T.mHeadermHeader
T.mOverSelectedmOverSelected

Functions

VegUIList

function VegUIList(refName,
Parent,
Manager)

Constructor

See Parent

VegUINode::VegUINode

add_item

this.add_item = function(node,
value,
dontAdjust,
asHeader,
replace)

Adds a HTML node as a new item to the list with a certain value attached

Parameters

HTMLNode nodethe html node you want to add as item to the list
variable valuethe value you want to attach to the item
<bool dontAdjust>prevents adjust method from being called after the item is added
<bool asHeader>if true the item will be added as header and will not be selectable
<bool replace>if true and the submitted value already exists in the list the item at the current value will be replace by the newly created item

Code example

// add item
myList.add_item(document.getElementById('somenode'), 1);

// add item as header
myList.add_item(document.getElementById('somenode'), 0, false, true);

See also

drop_item, add_item_txt, add_item_imgtxt

add_item_imgtxt

this.add_item_imgtxt = function(src,
txt,
value,
dontAdjust,
asHeader,
replace)

Wrapper function to add an item that contains an image and text

Parameters

string srcpath of the image to embed
string txttext that appears beside the image
variable valuevalue to attach to the item
<bool dontAdjust>prevents the call of the adjust method
<bool asHeader>if true item will be added as header
<bool replace>if true and the submitted value already exists in the list the item at the current value will be replace by the newly created item

See also

add_item, add_item_txt

Example

List.add_item_imgtxt('image.gif', 'Some Image', 1);

add_item_txt

this.add_item_txt = function(txt,
value,
dontAdjust,
asHeader,
replace)

Wrapper function to add an item that contains on text

Parameters

string txttext of the item
variable valuevalue to attach to the item
<bool dontAdjust>prevents the call of the adjust method
<bool asHeader>if true item will be added as header
<bool replace>if true and the submitted value already exists in the list the item at the current value will be replace by the newly created item

See also

add_item, add_item_imgtxt

Example

List.add_item_txt('List Entry', 1);

adjust

this.adjust = function()

Adjusts the scrollbars of the list to the content over flow of the list.  This is usually called everytime an item is added to the list at runtime.

build_list

this.build = this.build_list = function(toNode)

Builds the list

private function

You should always use VegUIManager::build_element to build VegUI elements.

Parameters

<HTMLNode toNode>if submitted the created HTML node will be appended to toNode

Returns

nullon failure
int1 on success

See Parent

VegUINode::build_node

close

this.close = function()

Closes the list if the list is a dropdown list

See also

open

Example

List.close();

deselect_item

this.deselect_item = function(value,
noOnChange)

Deselects the currently selected item(s), or the item submitted to the function.

private function

Parameters

<variable value>if submitted the item with this value will be deslected only (multi selection list)
<bool noOnChange>if true onchange() will not be called

See also

select, select_item

drop_item

this.drop_item = function(index)

Drops the item that is located at the submitted index in the childNodes array of the Table child’s HTML node

Parameters

int indexindex of the item’s HTML node in this.Table.Base.childNodes

See also

add_item

Example

// drops the item in the beginning of the list
List.drop_item(0);

// drops the 10th item
List.drop_item(9);

find

this.find = function(value)

Sees if an item with a certain value exists

Parameters

variable valuevalue to search for

Returns

intreturns the index of the HTMLnode of the item in the childNodes Array of the Table child
boolreturns false if no item with the requested value was found

See also

is_selected

Example

// returns the index of the first item that has the item value 1
return List.find(1);

// combined with drop_item
List.drop_item(List.find(1));

flush

this.flush = function()

Clears the list of all items

Example

List.flush();

handle_key_list()

this.handle_key = this.handle_key_list = function()

Handles key press on the list element

private function

Alias

<handle_key>

See also

<VegUICBox::handle_key_cbox>

is_selected

this.is_selected = function(value)

Checks if the item with a certain value is selected

Parameters

variable valuevalue to check for

See also

select, find

Returns

booltrue if value is currently selected, false if not

Example

// returns true if the item with the item value 1 is currently
// selected

return List.is_selected(1);

open

this.open = function()

Expands the list if it is a dropdown list

See also

close

select

this.select = function(value,
noOnChange)

Selects the first item that has the requested value

Parameters

variable valuevalue to search for
bool noOnChangeprevents the VegUINode::onchange event from being triggered

See also

select_item, deselect_item

Example

// selects the item with the item value 1
List.select(1);

select_item

this.select_item = function(node,
noOnChange,
append)

Selects the item with the submitted HTML node.  This is a private function that is called whenever an item is clicked to mark it as selected.  If you want to select an item manually you should use the select method

private function

Use select method to select item by value

Parameters

HTMLNode nodenode of the item to be selected
<bool noOnChange>will prevent the call of VegUINode::onchange
<bool append>if true current selected item will not be deselected and the new selection will be appended (multiselection list only)

select_items

this.select_items = function(value1,
value2)

Selects items from item with value1 to item with value2

Parameters

variable value1value of an item in the list
variable value2value of an item in the list

Returns

intnumber of items selected

See also

select_item, select, is_selected

Example

// Will select all items that are between the item with the
// item value 1 and the item with the item value 20
// items 1 and 20 will be selected as well

List.select_items(1,20);

set_list

this.set = this.set_list = function(w,
h,
x,
y,
ih,
rs,
type,
z,
ne)

Sets the most common template properties for the list

Alias

set()

Parameters

int wwidth (pixels)
int hheight (pixels)
int xx position (pixels)
int yy position (pixels)
int ihitem height (pixels)
int rsrow space, the space between two rows (pixels)
int typelist type List Types
int zz index
bool neenable or disable null entry

See Parent

VegUINode::set_node

Example

// set list up as a normal list with a row space of 0 and
// fixed item height of 16 pixels

List.set_list(150,200,5,5,16,0,VUI_LISTTYPE_NORMAL);

// set list up with non fixed item height

List.set_list(150,200,5,5,0,0,VUI_LISTTYPE_NORMAL);

// set list up as multi select list

List.set_list(150,200,5,5,16,0,VUI_LISTTYPE_MULTI);

// set list up as dropdown list

List.set_list(150,200,5,5,16,0,VUI_LISTTYPE_DROPDOWN);

set_style_list

this.set_style_list = this.set_style = function(over,
normal,
select,
header,
overSelect)

Wrapper method to set the style class name attributes of this element

Alias

set_style

Parameters

string overcss class to use on a row when the mouse is hovering over it
string normalcss class to use on a row when in normal state
string selectcss class to use on a row when selected
string headercss class to use on header rows
string overSelectcss class to use on a row when the mouse is hovering over it and the row is selected

sitem_idx

this.sitem_idx = function(value)

Returns the index of an item in the sItems property

Parameters

variable valuevalue of the item to search for

Returns

int-1 if no item was found
intindex of the item in the sItems array if it was found

to_string

this.to_string = function(sep)

Returns a string representation of the selection in the form of item values separated by a delimiter.  This is useful for processing multi selections.

Parameters

<string sep>seperator string between each item, ‘,’ default

Returns

stringstring representation of selections

Example

// if list holds these items:
// Item 1 (value = 1)
// Item 2 (value = 2)
// Item 3 (value = 3)
// then this will return '1,2,3';

return List.to_string(',');

warp

this.warp = function(value)

Scrolls the list to make sure a certain item is in point of view of the user

Parameters

int valuevalue of the item to warp to

Example

// warp the list to item with item value 1

List.warp(1);
vegUI element type for VegUIList
Object, holds the currently selected item
function VegUIList(refName,
Parent,
Manager)
Constructor
this.add_item = function(node,
value,
dontAdjust,
asHeader,
replace)
Adds a HTML node as a new item to the list with a certain value attached
this.add_item_imgtxt = function(src,
txt,
value,
dontAdjust,
asHeader,
replace)
Wrapper function to add an item that contains an image and text
this.add_item_txt = function(txt,
value,
dontAdjust,
asHeader,
replace)
Wrapper function to add an item that contains on text
this.adjust = function()
Adjusts the scrollbars of the list to the content over flow of the list.
this.build = this.build_list = function(toNode)
Builds the list
this.close = function()
Closes the list if the list is a dropdown list
this.deselect_item = function(value,
noOnChange)
Deselects the currently selected item(s), or the item submitted to the function.
this.drop_item = function(index)
Drops the item that is located at the submitted index in the childNodes array of the Table child’s HTML node
this.find = function(value)
Sees if an item with a certain value exists
this.flush = function()
Clears the list of all items
this.handle_key = this.handle_key_list = function()
Handles key press on the list element
this.is_selected = function(value)
Checks if the item with a certain value is selected
this.open = function()
Expands the list if it is a dropdown list
this.select = function(value,
noOnChange)
Selects the first item that has the requested value
this.select_item = function(node,
noOnChange,
append)
Selects the item with the submitted HTML node.
this.select_items = function(value1,
value2)
Selects items from item with value1 to item with value2
this.set = this.set_list = function(w,
h,
x,
y,
ih,
rs,
type,
z,
ne)
Sets the most common template properties for the list
this.set_style_list = this.set_style = function(over,
normal,
select,
header,
overSelect)
Wrapper method to set the style class name attributes of this element
this.sitem_idx = function(value)
Returns the index of an item in the sItems property
this.to_string = function(sep)
Returns a string representation of the selection in the form of item values separated by a delimiter.
this.warp = function(value)
Scrolls the list to make sure a certain item is in point of view of the user
A scrollable frame to display content in.
The most basic VegUI Element.
varies from element to element
multi select list
int, height of the list if expanded (dropdown mode only)
int, List Types
string, css class to use for items while not selected and not hovered by mouse
string, css class to use for items when mouse is hovering over them
string, css class to use for selected items
string, css class to use for header items
string, css class to use for hovering over selected items
function VegUINode(refName,
Parent,
Manager)
this.build_element = function(VegUIObj,
toNode)
builds a VegUIElement.
this.build = this.build_node = function(toNode,
takeNode)
build a HTML node from the template properties of this element.
this.set = this.set_node = function(nodeType,
w,
h,
x,
y,
pos,
z)
Template Function