').addClass ('ov_tree_item_button_container').insertBefore (this.nameElement);
}
OnNameClick (onNameClick)
{
this.nameElement.css ('cursor', 'pointer');
this.nameElement.click (onNameClick);
}
AddButton (button)
{
button.AddDomElements (this.buttonsDiv);
}
};
OV.TreeViewGroupItem = class extends OV.TreeViewItem
{
constructor (name, iconPath)
{
super (name);
this.iconPath = iconPath;
this.showChildren = false;
this.childrenDiv = null;
this.openButtonIcon = 'arrow_down';
this.closeButtonIcon = 'arrow_up';
OV.CreateSvgIcon (this.iconPath, 'ov_tree_item_icon').insertBefore (this.nameElement);
let buttonContainer = $('
').addClass ('ov_tree_item_button_container').insertBefore (this.nameElement);
this.openCloseButton = OV.AddSvgIcon (buttonContainer, this.openButtonIcon, 'ov_tree_item_button');
}
ShowChildren (show, onComplete)
{
this.showChildren = show;
if (this.childrenDiv === null) {
return;
}
if (show) {
OV.SetSvgIconImage (this.openCloseButton, this.openButtonIcon);
this.childrenDiv.slideDown (400, onComplete);
} else {
OV.SetSvgIconImage (this.openCloseButton, this.closeButtonIcon);
this.childrenDiv.slideUp (400, onComplete);
}
}
CreateChildrenDiv ()
{
if (this.childrenDiv === null) {
this.childrenDiv = $('
').addClass ('ov_tree_view_children').insertAfter (this.mainElement);
this.mainElement.addClass ('clickable');
this.ShowChildren (this.showChildren, null);
this.mainElement.click ((ev) => {
this.showChildren = !this.showChildren;
this.ShowChildren (this.showChildren, null);
});
}
return this.childrenDiv;
}
AddChild (child)
{
this.CreateChildrenDiv ();
child.SetParent (this);
child.AddDomElements (this.childrenDiv);
}
};
OV.TreeView = class
{
constructor (parentDiv)
{
this.mainDiv = $('
').addClass ('ov_tree_view').appendTo (parentDiv);
}
AddItem (item)
{
item.AddDomElements (this.mainDiv);
}
Clear ()
{
this.mainDiv.empty ();
}
};