Tree
Extends:
Constructor Summary
Public Constructor | ||
public |
constructor(tree: Tree~TreeData, options: object, styles: object) Create Tree |
Member Summary
Public Members | ||
public get |
dragOpacity: number opacity setting for dragged item |
|
public set |
|
|
public |
element: HTMLElement Main div holding tree |
|
public get |
expandOnClick: boolean expand and collapse node on click without drag except (will select before expanding if select=true) |
|
public set |
|
|
public get |
holdTime: number number of milliseconds to press and hold name before editing starts (set to 0 to disable) |
|
public set |
|
|
public get |
indentation: number indentation for tree |
|
public set |
|
|
public get |
move: boolean whether tree may be rearranged |
|
public set |
|
|
public get |
prefixClassName: string className's prefix (e.g., "yy-tree"-content) |
|
public set |
|
|
public get |
select: boolean click to select node (if false then nodes are not selected and tree.selection is always null) |
|
public set |
|
|
public get |
selection: * Selected data |
|
public set |
|
Method Summary
Public Methods | ||
public |
collapse(leaf: HTMLElement) Collapses a leaf |
|
public |
Collapses all leaves |
|
public |
edit(leaf: HTMLElement) edit the name entry using the created element |
|
public |
editData(data: object) edit the name entry using the data |
|
public |
expand(leaf: HTMLElement) Expands a leaf |
|
public |
Expands all leaves |
|
public |
findInTree(leaf: *, callback: function): * call the callback function on each node; returns the node if callback === true |
|
public |
getLeaf(leaf: object, root: HTMLElement) Find a leaf based using its data |
|
public |
nameChange(leaf: HTMLElement, name: string) change the name of a leaf |
|
public |
toggleExpand(leaf: HTMLElement) Toggles a leaf |
|
public |
update() call this after tree's data has been updated outside of this library |
Public Constructors
public constructor(tree: Tree~TreeData, options: object, styles: object) source
Create Tree
Params:
Name | Type | Attribute | Description |
tree | Tree~TreeData | data for tree (see readme for description) |
|
options | object |
|
|
options.element | HTMLElement | string |
|
if a string then document.querySelector(element); if empty, it creates an element |
options.parent | HTMLElement | string |
|
appends the element to this parent (if string then document.querySelector(parent)) |
options.move | boolean |
|
drag tree to rearrange |
options.select | boolean |
|
click to select node (if false then nodes are not selected and tree.selection is always null) |
options.indentation | number |
|
number of pixels to indent for each level |
options.threshold | number |
|
number of pixels to move to start a drag |
options.holdTime | number |
|
number of milliseconds to press and hold name before editing starts (set to 0 to disable) |
options.expandOnClick | boolean |
|
expand and collapse node on click without drag except (will select before expanding if select=true) |
options.dragOpacity | number |
|
opacity setting for dragged item |
options.prefixClassName | string |
|
first part of className for all DOM objects (e.g., yy-tree, yy-tree-indicator) |
options.addStyles | boolean |
|
attaches a style sheet with default and overridden styles; set to false to use your own stylesheet |
styles | object |
|
|
styles.nameStyles | string[] |
|
use these to override individual styles for the name (will be included in the attached stylesheet) |
styles.contentStyles | string[] |
|
use these to override individual styles for the content (will be included in the attached stylesheet) |
styles.indicatorStyles | string[] |
|
use these to override individual styles for the move-line indicator (will be included in the attached stylesheet) |
styles.selectedStyles | string[] |
|
use these to override individual styles for the selected item (will be included in the attached stylesheet) |
Public Members
public set dragOpacity source
public get expandOnClick: boolean source
expand and collapse node on click without drag except (will select before expanding if select=true)
public set expandOnClick source
public get holdTime: number source
number of milliseconds to press and hold name before editing starts (set to 0 to disable)
public set holdTime source
public set indentation source
public set move source
public set prefixClassName source
public get select: boolean source
click to select node (if false then nodes are not selected and tree.selection is always null)
public set select source
public set selection source
Public Methods
public collapse(leaf: HTMLElement) source
Collapses a leaf
Params:
Name | Type | Attribute | Description |
leaf | HTMLElement |
public edit(leaf: HTMLElement) source
edit the name entry using the created element
Params:
Name | Type | Attribute | Description |
leaf | HTMLElement |
public editData(data: object) source
edit the name entry using the data
Params:
Name | Type | Attribute | Description |
data | object | element of leaf |
public expand(leaf: HTMLElement) source
Expands a leaf
Params:
Name | Type | Attribute | Description |
leaf | HTMLElement |
public findInTree(leaf: *, callback: function): * source
call the callback function on each node; returns the node if callback === true
Params:
Name | Type | Attribute | Description |
leaf | * | data |
|
callback | function |
Return:
* |
public getLeaf(leaf: object, root: HTMLElement) source
Find a leaf based using its data
Params:
Name | Type | Attribute | Description |
leaf | object | ||
root | HTMLElement |
|
public nameChange(leaf: HTMLElement, name: string) source
change the name of a leaf
Params:
Name | Type | Attribute | Description |
leaf | HTMLElement | ||
name | string |
public toggleExpand(leaf: HTMLElement) source
Toggles a leaf
Params:
Name | Type | Attribute | Description |
leaf | HTMLElement |