add ListBox.js
This commit is contained in:
parent
c59aba76f7
commit
9dce749fe0
36
lib/phast/client/scripts/controls/ListBox.js
Normal file
36
lib/phast/client/scripts/controls/ListBox.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
function ListBox(parentElement)
|
||||||
|
{
|
||||||
|
this.ParentElement = parentElement;
|
||||||
|
this.SetSelectedItem = function(li)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < this.ParentElement.children.length; i++)
|
||||||
|
{
|
||||||
|
if (this.ParentElement.children[i] == li)
|
||||||
|
{
|
||||||
|
System.ClassList.Add(this.ParentElement.children[i], "uwt-selected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.ClassList.Remove(this.ParentElement.children[i], "uwt-selected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var i = 0; i < this.ParentElement.children.length; i++)
|
||||||
|
{
|
||||||
|
this.ParentElement.children[i].NativeObject = this;
|
||||||
|
this.ParentElement.children[i].addEventListener("click", function()
|
||||||
|
{
|
||||||
|
this.NativeObject.SetSelectedItem(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("load", function()
|
||||||
|
{
|
||||||
|
var items = document.getElementsByClassName("uwt-listbox");
|
||||||
|
for (var i = 0; i < items.length; i++)
|
||||||
|
{
|
||||||
|
items[i].NativeObject = new ListBox(items[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user