Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ To automate the process of building the css, Grunt is used. To use grunt, switch

This will build the css and output it to `bootstrap-combined.min.css` file.
You can also use `grunt watch` to watch changes to the less files while you build and test.

#### Usage

Just call .bootstrapTree() on the root element of the tree:

$('.tree').boootstrapTree();

49 changes: 35 additions & 14 deletions js/bootstrap-tree.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
$(document).ready(function() {
$('.tree > ul').attr('role', 'tree').find('ul').attr('role', 'group');
$('.tree').find('li:has(ul)').addClass('parent_li').attr('role', 'treeitem').find(' > span').attr('title', 'Collapse this branch').on('click', function (e) {
var children = $(this).parent('li.parent_li').find(' > ul > li');
if (children.is(':visible')) {
children.hide('fast');
$(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
!function( $ ) {
var bootstrapTree = {
init: function() {
$(this).find('ul').attr('role', 'tree').find('ul').attr('role', 'group');
$(this)
.find('li:has(ul)')
.addClass('parent_li')
.attr('role', 'treeitem')
.find(' > span')
.attr('title', 'Collapse this branch')
.on('click', function(e) {
var children = $(this).parent('li.parent_li').find(' > ul > li');
if (children.is(':visible')) {
children.hide('fast');
$(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
}
else {
children.show('fast');
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
}
e.stopPropagation();
});
}
else {
children.show('fast');
$(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
}
e.stopPropagation();
});
});
};

$.fn.bootstrapTree = function(method) {
if (bootstrapTree[method]) {
return bootstrapTree[ method ].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return bootstrapTree.init.apply(this, arguments);
} else {
$.error('Method with name ' + method + ' does not exists for jQuery.bootstrapTree');
}
};

}(window.jQuery);
2 changes: 1 addition & 1 deletion less/bootstrap-tree.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}
/*Remove connectors after last child*/
&:last-child::before {
height: 30px;
height: 14px;
}
}
/*Remove connectors before root*/
Expand Down