Skip to content

Commit

Permalink
Fixes merge problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jperkelens committed Apr 20, 2015
2 parents 8508fb2 + 66edb95 commit 4bd751c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ If you want to do more, here's the full node specification
{
text: "Node 1",
icon: "glyphicon glyphicon-stop",
selectedIcon: "glyphicon glyphicon-stop",
color: "#000000",
backColor: "#FFFFFF",
href: "#node-1",
Expand Down Expand Up @@ -159,6 +160,11 @@ For simplicity we directly leverage [Bootstraps Glyphicons support](http://getbo

By providing the base class you retain full control over the icons used. If you want to use your own then just add your class to this icon field.

#### selectedIcon
`String` `Optional`

The icon displayed on a given node when selected, typically to the left of the text.

#### color
`String` `Optional`

Expand Down Expand Up @@ -290,6 +296,11 @@ 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'.

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

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions public/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
collapseIcon: 'glyphicon glyphicon-minus',
emptyIcon: 'glyphicon',
nodeIcon: 'glyphicon glyphicon-stop',
selectedIcon: 'glyphicon glyphicon-stop',

color: undefined, // '#000000',
backColor: undefined, // '#FFFFFF',
Expand Down Expand Up @@ -445,10 +446,19 @@
}

// Add node icon
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
var selected = node.state.selected
if (selected) {
treeItem
.append($(_this.template.icon)
.addClass(node.selectedIcon ? (node.selectedIcon || node.icon) : _this.options.selectedIcon)
);
}
else {
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
}

// Add text
if (_this.options.enableLinks) {
Expand Down
18 changes: 14 additions & 4 deletions src/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
collapseIcon: 'glyphicon glyphicon-minus',
emptyIcon: 'glyphicon',
nodeIcon: 'glyphicon glyphicon-stop',
selectedIcon: 'glyphicon glyphicon-stop',

color: undefined, // '#000000',
backColor: undefined, // '#FFFFFF',
Expand Down Expand Up @@ -445,10 +446,19 @@
}

// Add node icon
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
var selected = node.state.selected
if (selected) {
treeItem
.append($(_this.template.icon)
.addClass(node.selectedIcon ? (node.selectedIcon || node.icon) : _this.options.selectedIcon)
);
}
else {
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
}

// Add text
if (_this.options.enableLinks) {
Expand Down
18 changes: 14 additions & 4 deletions tests/lib/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
collapseIcon: 'glyphicon glyphicon-minus',
emptyIcon: 'glyphicon',
nodeIcon: 'glyphicon glyphicon-stop',
selectedIcon: 'glyphicon glyphicon-stop',

color: undefined, // '#000000',
backColor: undefined, // '#FFFFFF',
Expand Down Expand Up @@ -445,10 +446,19 @@
}

// Add node icon
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
var selected = node.state.selected
if (selected) {
treeItem
.append($(_this.template.icon)
.addClass(node.selectedIcon ? (node.selectedIcon || node.icon) : _this.options.selectedIcon)
);
}
else {
treeItem
.append($(_this.template.icon)
.addClass(node.icon ? node.icon : _this.options.nodeIcon)
);
}

// Add text
if (_this.options.enableLinks) {
Expand Down
9 changes: 8 additions & 1 deletion tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
equal(options.collapseIcon, 'glyphicon glyphicon-minus', 'collapseIcon default ok');
equal(options.emptyIcon, 'glyphicon', 'emptyIcon default ok');
equal(options.nodeIcon, 'glyphicon glyphicon-stop', 'nodeIcon default ok');
equal(options.selectedIcon, 'glyphicon glyphicon-stop', 'selectedIcon default ok');
equal(options.color, undefined, 'color default ok');
equal(options.backColor, undefined, 'backColor default ok');
equal(options.borderColor, undefined, 'borderColor default ok');
Expand Down Expand Up @@ -120,6 +121,7 @@
collapseIcon: 'glyphicon glyphicon-collapse',
emptyIcon: 'glyphicon',
nodeIcon: 'glyphicon glyphicon-node',
selectedIcon: 'glyphicon glyphicon-selected',
color: 'yellow',
backColor: 'purple',
borderColor: 'purple',
Expand Down Expand Up @@ -149,6 +151,7 @@
equal(options.collapseIcon, 'glyphicon glyphicon-collapse', 'collapseIcon set ok');
equal(options.emptyIcon, 'glyphicon', 'emptyIcon set ok');
equal(options.nodeIcon, 'glyphicon glyphicon-node', 'nodeIcon set ok');
equal(options.selectedIcon, 'glyphicon glyphicon-selected', 'selectedIcon set ok');
equal(options.color, 'yellow', 'color set ok');
equal(options.backColor, 'purple', 'backColor set ok');
equal(options.borderColor, 'purple', 'borderColor set ok');
Expand Down Expand Up @@ -454,7 +457,7 @@
});

test('selectNode / unselectNode', function () {
var $tree = init({ data: data });
var $tree = init({ data: data, selectedIcon: 'glyphicon glyphicon-selected' });
var el;
var nodeId = 0;
var node = $tree.treeview('getNode', 0);
Expand All @@ -463,24 +466,28 @@
$tree.treeview('selectNode', nodeId);
el = $('.list-group-item:first');
ok((el.attr('class').split(' ').indexOf('node-selected') !== -1), 'Select node (by id) : Node is selected');
ok((el.find('.icon').attr('class') === 'icon glyphicon glyphicon-selected'), 'Select node (by id) : Node icon is correct');
ok(($('.node-selected').length === 1), 'Select node (by id) : There is only one selected node');

// Unselect node using node id
$tree.treeview('unselectNode', nodeId);
el = $('.list-group-item:first');
ok((el.attr('class').split(' ').indexOf('node-selected') === -1), 'Select node (by id) : Node is no longer selected');
ok((el.find('.icon').attr('class') === 'icon glyphicon glyphicon-stop'), 'Select node (by id) : Node icon is correct');
ok(($('.node-selected').length === 0), 'Select node (by id) : There are no selected nodes');

// Select node using node
$tree.treeview('selectNode', node);
el = $('.list-group-item:first');
ok((el.attr('class').split(' ').indexOf('node-selected') !== -1), 'Select node (by node) : Node is selected');
ok((el.find('.icon').attr('class') === 'icon glyphicon glyphicon-selected'), 'Select node (by node) : Node icon is correct');
ok(($('.node-selected').length === 1), 'Select node (by node) : There is only one selected node');

// Unselect node using node id
$tree.treeview('unselectNode', node);
el = $('.list-group-item:first');
ok((el.attr('class').split(' ').indexOf('node-selected') === -1), 'Select node (by node) : Node is no longer selected');
ok((el.find('.icon').attr('class') === 'icon glyphicon glyphicon-stop'), 'Select node (by node) : Node icon is correct');
ok(($('.node-selected').length === 0), 'Select node (by node) : There are no selected nodes');
});

Expand Down

0 comments on commit 4bd751c

Please sign in to comment.