tree.js 917 B

12345678910111213141516
  1. $(function() {
  2. $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
  3. $('.tree li.parent_li > span').on('click', function(e) {
  4. var children = $(this).parent('li.parent_li').find(' > ul > li');
  5. if(children.is(":visible")) {
  6. children.hide('fast');
  7. $(this).attr('title', 'Expand this branch').parent(".parent_li").find(' > i').addClass('iconTree-plus-sign').removeClass('iconTree-minus-sign');
  8. $(this).attr('title', 'Expand this branch').find(' > i').addClass('iconTree-folder-open').removeClass('iconTree-user');
  9. } else {
  10. children.show('fast');
  11. $(this).attr('title', 'Collapse this branch').parent(".parent_li").find(' > i').addClass('iconTree-minus-sign').removeClass('iconTree-plus-sign');
  12. $(this).attr('title', 'Collapse this branch').find(' > i').addClass('iconTree-user').removeClass('iconTree-folder-open');
  13. }
  14. e.stopPropagation();
  15. });
  16. });