Skip to content

Commit

Permalink
Update to search result options
Browse files Browse the repository at this point in the history
- Changed default searchResultColor
- Tests for searchResultColor + searchResultBackColor options
- New hightlightSearchResults option
  • Loading branch information
jonmiles committed Mar 22, 2015
1 parent 7cb9944 commit 67a97fa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ String, class name(s). Default: "glyphicon glyphicon-plus" as defined by [Boots

Sets the icon to be used on an expandable tree node.

### highlightSearchResults
Boolean. Default: true

Whether or not to highlight search results.

### highlightSelected
Boolean. Default: true

Expand All @@ -258,16 +263,26 @@ String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal

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

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

Sets the background color of the selected node.

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

Sets the foreground color of the selected node.

### selectedBackColor
String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal.asp). Default: '#FFFFFF'.
String, [any legal color value](http://www.w3schools.com/cssref/css_colors_legal.asp). Default: '#428bca'.

Sets the background color of the selected node.

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

Sets the foreground color of the selected node.

### showBorder
Boolean. Default: true

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

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions public/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
onhoverColor: '#F5F5F5',
selectedColor: '#FFFFFF',
selectedBackColor: '#428bca',
searchResultColor: '#E5E313',
searchResultColor: '#D9534F',
searchResultBackColor: undefined, //'#FFFFFF',

enableLinks: false,
highlightSelected: true,
highlightSearchResults: true,
showBorder: true,
showTags: false,
multiSelect: false,
Expand Down Expand Up @@ -462,7 +463,7 @@
var color = node.color;
var backColor = node.backColor;

if (this.options.highlightSelected && (node.states.selected)) {
if (this.options.highlightSelected && node.states.selected) {
if (this.options.selectedColor) {
color = this.options.selectedColor;
}
Expand All @@ -471,7 +472,7 @@
}
}

if (node.searchResult) {
if (this.options.highlightSearchResults && node.searchResult) {
if (this.options.searchResultColor) {
color = this.options.searchResultColor;
}
Expand Down
7 changes: 4 additions & 3 deletions src/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
onhoverColor: '#F5F5F5',
selectedColor: '#FFFFFF',
selectedBackColor: '#428bca',
searchResultColor: '#E5E313',
searchResultColor: '#D9534F',
searchResultBackColor: undefined, //'#FFFFFF',

enableLinks: false,
highlightSelected: true,
highlightSearchResults: true,
showBorder: true,
showTags: false,
multiSelect: false,
Expand Down Expand Up @@ -462,7 +463,7 @@
var color = node.color;
var backColor = node.backColor;

if (this.options.highlightSelected && (node.states.selected)) {
if (this.options.highlightSelected && node.states.selected) {
if (this.options.selectedColor) {
color = this.options.selectedColor;
}
Expand All @@ -471,7 +472,7 @@
}
}

if (node.searchResult) {
if (this.options.highlightSearchResults && node.searchResult) {
if (this.options.searchResultColor) {
color = this.options.searchResultColor;
}
Expand Down
7 changes: 4 additions & 3 deletions tests/lib/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
onhoverColor: '#F5F5F5',
selectedColor: '#FFFFFF',
selectedBackColor: '#428bca',
searchResultColor: '#E5E313',
searchResultColor: '#D9534F',
searchResultBackColor: undefined, //'#FFFFFF',

enableLinks: false,
highlightSelected: true,
highlightSearchResults: true,
showBorder: true,
showTags: false,
multiSelect: false,
Expand Down Expand Up @@ -462,7 +463,7 @@
var color = node.color;
var backColor = node.backColor;

if (this.options.highlightSelected && (node.states.selected)) {
if (this.options.highlightSelected && node.states.selected) {
if (this.options.selectedColor) {
color = this.options.selectedColor;
}
Expand All @@ -471,7 +472,7 @@
}
}

if (node.searchResult) {
if (this.options.highlightSearchResults && node.searchResult) {
if (this.options.searchResultColor) {
color = this.options.searchResultColor;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@
equal(options.onhoverColor, '#F5F5F5', 'onhoverColor default ok');
equal(options.selectedColor, '#FFFFFF', 'selectedColor default ok');
equal(options.selectedBackColor, '#428bca', 'selectedBackColor default ok');
equal(options.searchResultColor, '#D9534F', 'searchResultColor default ok');
equal(options.searchResultBackColor, undefined, 'searchResultBackColor default ok');
equal(options.enableLinks, false, 'enableLinks default ok');
equal(options.highlightSelected, true, 'highlightSelected default ok');
equal(options.highlightSearchResults, true, 'highlightSearchResults default ok');
equal(options.showBorder, true, 'showBorder default ok');
equal(options.showTags, false, 'showTags default ok');
equal(options.multiSelect, false, 'multiSelect default ok');
Expand All @@ -121,8 +124,11 @@
onhoverColor: 'orange',
selectedColor: 'yellow',
selectedBackColor: 'darkorange',
searchResultColor: 'yellow',
searchResultBackColor: 'darkorange',
enableLinks: true,
highlightSelected: false,
highlightSearchResults: true,
showBorder: false,
showTags: true,
multiSelect: true,
Expand All @@ -145,8 +151,11 @@
equal(options.onhoverColor, 'orange', 'onhoverColor set ok');
equal(options.selectedColor, 'yellow', 'selectedColor set ok');
equal(options.selectedBackColor, 'darkorange', 'selectedBackColor set ok');
equal(options.searchResultColor, 'yellow', 'searchResultColor set ok');
equal(options.searchResultBackColor, 'darkorange', 'searchResultBackColor set ok');
equal(options.enableLinks, true, 'enableLinks set ok');
equal(options.highlightSelected, false, 'highlightSelected set ok');
equal(options.highlightSearchResults, true, 'highlightSearchResults set ok');
equal(options.showBorder, false, 'showBorder set ok');
equal(options.showTags, true, 'showTags set ok');
equal(options.multiSelect, true, 'multiSelect set ok');
Expand Down

0 comments on commit 67a97fa

Please sign in to comment.