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

Commit

Permalink
Merge pull request #34 from Zehir/master
Browse files Browse the repository at this point in the history
Add tagsClass options on node and global
  • Loading branch information
skateman authored Apr 25, 2017
2 parents ee0978a + 4248431 commit 0fc8417
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ Whether or not a node is selected.

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)

#### tagsClass
`Array of Strings` `Optional`

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.

#### dataAttr
`Array of Objects` `Optional`

Expand Down Expand Up @@ -469,6 +474,11 @@ 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.

#### tagsClass
String, class names(s). Default: "badge"

Sets the class of tags

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

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

```javascript
$('#tree').treeview('findNode', ['Parent', 'text']);
$('#tree').treeview('findNodes', ['Parent', 'text']);
```

> 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$.
Expand Down
8 changes: 7 additions & 1 deletion src/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
checkedIcon: 'glyphicon glyphicon-check',
partiallyCheckedIcon: 'glyphicon glyphicon-expand',
uncheckedIcon: 'glyphicon glyphicon-unchecked',
tagsClass: 'badge',

color: undefined,
backColor: undefined,
Expand Down Expand Up @@ -970,6 +971,11 @@
$.each(node.tags, $.proxy(function addTag(id, tag) {
node.$el
.append(this._template.badge.clone()
.addClass(
typeof node.tagsClass[id] === 'string' ?
node.tagsClass[id] :
this._options.tagsClass
)
.append(tag)
);
}, this));
Expand Down Expand Up @@ -1153,7 +1159,7 @@
empty: $('<span class="icon"></span>')
},
image: $('<span class="image"></span>'),
badge: $('<span class="badge"></span>'),
badge: $('<span></span>'),
text: $('<span class="text"></span>')
};

Expand Down

0 comments on commit 0fc8417

Please sign in to comment.