Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 0fc8417

Browse files
authored
Merge pull request #34 from Zehir/master
Add tagsClass options on node and global
2 parents ee0978a + 4248431 commit 0fc8417

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ Whether or not a node is selected.
238238

239239
Used in conjunction with global showTags option to add additional information to the right of each node; using [Bootstrap Badges](http://getbootstrap.com/components/#badges)
240240

241+
#### tagsClass
242+
`Array of Strings` `Optional`
243+
244+
Used in conjunction with tags option to set class of node tags. The class are defined in the same order of tags. You can set null to use the default value. If class array is smaller than tags array the default value is used.
245+
241246
#### dataAttr
242247
`Array of Objects` `Optional`
243248

@@ -469,6 +474,11 @@ Boolean. Default: false
469474

470475
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.
471476

477+
#### tagsClass
478+
String, class names(s). Default: "badge"
479+
480+
Sets the class of tags
481+
472482
#### uncheckedIcon
473483
String, class names(s). Default: "glyphicon glyphicon-unchecked" as defined by [Bootstrap Glyphicons](http://getbootstrap.com/components/#glyphicons)
474484

@@ -679,7 +689,7 @@ Triggers `nodeExpanded` event; pass silent to suppress events.
679689
Returns an array of matching node objects.
680690

681691
```javascript
682-
$('#tree').treeview('findNode', ['Parent', 'text']);
692+
$('#tree').treeview('findNodes', ['Parent', 'text']);
683693
```
684694

685695
> Use regular expressions for pattern matching NOT string equals, if you need to match an exact string use start and end string anchors e.g. ^pattern$.

src/js/bootstrap-treeview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
checkedIcon: 'glyphicon glyphicon-check',
4343
partiallyCheckedIcon: 'glyphicon glyphicon-expand',
4444
uncheckedIcon: 'glyphicon glyphicon-unchecked',
45+
tagsClass: 'badge',
4546

4647
color: undefined,
4748
backColor: undefined,
@@ -970,6 +971,11 @@
970971
$.each(node.tags, $.proxy(function addTag(id, tag) {
971972
node.$el
972973
.append(this._template.badge.clone()
974+
.addClass(
975+
typeof node.tagsClass[id] === 'string' ?
976+
node.tagsClass[id] :
977+
this._options.tagsClass
978+
)
973979
.append(tag)
974980
);
975981
}, this));
@@ -1153,7 +1159,7 @@
11531159
empty: $('<span class="icon"></span>')
11541160
},
11551161
image: $('<span class="image"></span>'),
1156-
badge: $('<span class="badge"></span>'),
1162+
badge: $('<span></span>'),
11571163
text: $('<span class="text"></span>')
11581164
};
11591165

0 commit comments

Comments
 (0)