Skip to content

Commit

Permalink
Merge branch 'feature/45-checkable-nodes' into develop
Browse files Browse the repository at this point in the history
* feature/45-checkable-nodes:
  Refactored toggle methods
  Refactored API methods
  Examples updated
  Doc update
  Check / uncheck methods added
  Added events and show methods
  Initial idea prototyped.
  • Loading branch information
jonmiles committed May 3, 2015
2 parents 8219ac2 + 0377011 commit 3665e88
Show file tree
Hide file tree
Showing 11 changed files with 1,103 additions and 398 deletions.
94 changes: 86 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ If you want to do more, here's the full node specification
href: "#node-1",
selectable: true,
state: {
expanded: true,
selected: true
checked: true,
expanded: true,
selected: true
},
tags: ['available'],
nodes: [
Expand Down Expand Up @@ -187,9 +188,13 @@ Whether or not a node is selectable in the tree. False indicates the node should

#### state
`Object` `Optional`

Describes a node's initial state.

#### state.checked
`Boolean` `Default: false`

Whether or not a node is checked, represented by a checkbox style glyphicon.

#### state.expanded
`Boolean` `Default: false`

Expand Down Expand Up @@ -246,6 +251,11 @@ String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal

Sets the border color for the component; set showBorder to false if you don't want a visible border.

#### checkedIcon
String, class names(s). Default: "glyphicon glyphicon-check" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)

Sets the icon to be as a checked checkbox, used in conjunction with showCheckbox.

#### collapseIcon
String, class name(s). Default: "glyphicon glyphicon-minus" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)

Expand Down Expand Up @@ -296,16 +306,16 @@ String, class name(s). Default: "glyphicon glyphicon-stop" as defined by [Boots

Sets the default icon to be used on all nodes, except when overridden on a per node basis in data.

#### selectedIcon
String, class name(s). Default: "glyphicon glyphicon-stop" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)

Sets the default icon to be used on all selected nodes, except when overridden on a per node basis in data.

#### onhoverColor
String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal.asp). Default: '#F5F5F5'.

Sets the default background color activated when the users cursor hovers over a node.

#### selectedIcon
String, class name(s). Default: "glyphicon glyphicon-stop" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)

Sets the default icon to be used on all selected nodes, except when overridden on a per node basis in data.

#### searchResultBackColor
String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal.asp). Default: undefined, inherits.

Expand All @@ -331,11 +341,25 @@ Boolean. Default: true

Whether or not to display a border around nodes.

#### showCheckbox
Boolean. Default: false

Whether or not to display checkboxes on nodes.

#### showIcon
Boolean. Default: true

Whether or not to display a nodes icon.

#### showTags
Boolean. Default: false

Whether or not to display tags to the right of each node. The values of which must be provided in the data structure on a per node basis.

#### uncheckedIcon
String, class names(s). Default: "glyphicon glyphicon-unchecked" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)

Sets the icon to be as an unchecked checkbox, used in conjunction with showCheckbox.


## Methods
Expand Down Expand Up @@ -373,6 +397,26 @@ $('#tree').data('treeview')

The following is a list of all available methods.

#### checkAll(options)

Checks all tree nodes

```javascript
$('#tree').treeview('checkAll', { silent: true });
```

Triggers `nodeChecked` event; pass silent to suppress events.

#### checkNode(node | nodeId, options)

Checks a given tree node, accepts node or nodeId.

```javascript
$('#tree').treeview('checkNode', [ nodeId, { silent: true } ]);
```

Triggers `nodeChecked` event; pass silent to suppress events.

#### clearSearch()

Clear the tree view of any previous search results e.g. remove their highlighted state.
Expand Down Expand Up @@ -523,6 +567,16 @@ $('#tree').treeview('selectNode', [ nodeId, { silent: true } ]);

Triggers `nodeSelected` event; pass silent to suppress events.

#### toggleNodeChecked(node | nodeId, options)

Toggles a nodes checked state; checking if unchecked, unchecking if checked.

```javascript
$('#tree').treeview('toggleNodeChecked', [ nodeId, { silent: true } ]);
```

Triggers either `nodeChecked` or `nodeUnchecked` event; pass silent to suppress events.

#### toggleNodeExpanded(node | nodeId, options)

Toggles a nodes expanded state; collapsing if expanded, expanding if collapsed.
Expand All @@ -543,6 +597,26 @@ $('#tree').treeview('toggleNodeSelected', [ nodeId, { silent: true } ]);

Triggers either `nodeSelected` or `nodeUnselected` event; pass silent to suppress events.

#### uncheckAll(options)

Uncheck all tree nodes.

```javascript
$('#tree').treeview('uncheckAll', { silent: true });
```

Triggers `nodeUnchecked` event; pass silent to suppress events.

#### uncheckNode(node | nodeId, options)

Uncheck a given tree node, accepts node or nodeId.

```javascript
$('#tree').treeview('uncheckNode', [ nodeId, { silent: true } ]);
```

Triggers `nodeUnchecked` event; pass silent to suppress events.

#### unselectNode(node | nodeId, options)

Unselects a given tree node, accepts node or nodeId.
Expand Down Expand Up @@ -581,12 +655,16 @@ $('#tree').on('nodeSelected', function(event, data) {
### List of Events
`nodeChecked (event, node)` - A node is checked.
`nodeCollapsed (event, node)` - A node is collapsed.
`nodeExpanded (event, node)` - A node is expanded.
`nodeSelected (event, node)` - A node is selected.
`nodeUnchecked (event, node)` - A node is unchecked.
`nodeUnselected (event, node)` - A node is unselected.
`searchComplete (event, results)` - After a search completes
Expand Down
2 changes: 1 addition & 1 deletion dist/bootstrap-treeview.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bootstrap-treeview.min.js

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions public/css/bootstrap-treeview.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@
margin-right: 10px;
}

.treeview span.expand-collapse {
width: 1rem;
height: 1rem;
}

.treeview span.icon {
margin-left: 10px;
width: 12px;
margin-right: 5px;
}
Loading

0 comments on commit 3665e88

Please sign in to comment.