# jsTree v.1.0

# ui plugin

## Description

The `UI` plugin handles selecting, deselecting and hovering tree items.

## Configuration

### select_limit

A number. Default is `-1`.

Defines how many nodes can be selected at a given time (`-1` means unlimited).

### select_multiple_modifier

A string. Default is `"ctrl"`.

The special key used to make a click add to the selection and not replace it (`"ctrl"`, `"shift"`, `"alt"`, `"meta"`).
You can also set this to `"on"` making every click add to the selection.

### select_range_modifier

A string. Default is `"shift"`.

The special key used to make a click expand a range from the last selected item (`"ctrl"`, `"shift"`, `"alt"`, `"meta"`).
Note that the last clicked elemtn should be a sibling of the currently clicked element so that a range will be created (same as common file explorers).

### selected_parent_close

A string (or `false`). Default is `"select_parent"`.

What action to take when a selected node's parent is closed (making the selected node invisible). Possible values are `false` - do nothing, `"select_parent"` - select the closed node's parent and `"deselect"` - deselect the node.

### selected_parent_open

A Boolean. Default is `true`.

When set to `true` when programatically selecting a node in the tree all of its closed parents are opened automatically.

### select_prev_on_delete

A boolean. Default is `true`.

If set to `true` when a selected node is deleted, its previous sibling (or parent) is selected.

### disable_selecting_children

A boolean. Default is `false`.

If set to `true` you will not be able to select children of already selected nodes.

### initially_select

An array. Default is `[]`.

Defines which nodes are to be automatically selected when the tree finishes loading - a list of IDs is expected.

## Demos

### Using the UI plugin

- Root node 1
  - Child node 1
  - Child node 2
- Root node 2

## API

### ._get_node ( node , allow_multiple )

Overrides the function from the core module.
if `node` is `undefined` or `null` and `allow_multiple` is `true` all the currently selected nodes are returned
if `node` is `undefined` or `null` and `allow_multiple` is NOT `true` only the last selected node is returned.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

- `boolean` allow_multiple

  Whether to return all selected nodes or only the last selected one if `node` is `null`.

### .save_selected ( )

Saves away the current selection state of the tree (saves it in a variable, so do not expect a restore after a refresh - for that functionality refer to the cookies plugin. Used mostly internally. Triggers an event.

### .reselect ( )

Restores the state of the tree using the variable saved in the above function. Used mostly internally. Triggers an event.

### .refresh ( node )

Overrides the function form the core module.
Enables saving the selection state before the refresh and restoring it afterwards.

### .hover_node ( node )

Sets the specified node as hovered. Triggers an event.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

### .dehover_node ( )

Removes the hover state from the currently hovered node (if there is one). Triggers an event.

### .select_node ( node , check , event )

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

- `bool` check

  Whether to check the specified rules and do appropriate actions (check `select_limit`, deselect other nodes respectively, etc) or to just force selection of the node regardless of `select_limit`.

- `event` event

  Used internally - when a click on a node caused this function to be executed.

### .deselect_node ( node ), .toggle_select ( node )

There functions control the selected state on a node. `deselect_node` triggers an event.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

### .deselect_all ( context )

Deselects all selected nodes. If context is set - only the selected nodes within that context are deselected. Triggers an event.

- `mixed` context

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

### .get_selected ( context )

Returns all selected nodes. If context is set - only the selected nodes within that context are returned.

- `mixed` context

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.

### .is_selected ( node )

Returns whether the specified node is selected or not.

- `mixed` node

  This can be a DOM node, jQuery node or selector pointing to an element within the tree.