jsTree - Patch for allowing open/closed images using the Type plugin


/ Published in: SVN
Save to your folder(s)

Based on revision 233


Copy this code and paste it in your HTML
  1. Index: jquery.jstree.js
  2. ===================================================================
  3. --- jquery.jstree.js (revision 233)
  4. +++ jquery.jstree.js (working copy)
  5. @@ -3781,17 +3781,33 @@
  6.  
  7. $.each(types, function (i, tp) {
  8. $.each(tp, function (k, v) {
  9. - if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
  10. + if(!/^(max_depth|max_children|icon|icon_open|icon_closed|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
  11. });
  12. - if(!tp.icon) { return true; }
  13. + if(!tp.icon && !tp.icon_open && !tp.icon_closed) { return true; }
  14. if( tp.icon.image || tp.icon.position) {
  15. - if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
  16. + if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' li a > .jstree-icon { '; }
  17. else { icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
  18. if(tp.icon.image) { icons_css += ' background-image:url(' + tp.icon.image + '); '; }
  19. if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
  20. else { icons_css += ' background-position:0 0; '; }
  21. icons_css += '} ';
  22. }
  23. + if( tp.icon_closed && (tp.icon_closed.image || tp.icon_closed.position)) {
  24. + if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' li.jstree-closed a > .jstree-icon { '; }
  25. + else { icons_css += '.jstree-' + _this.get_index() + ' li.jstree-closed[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
  26. + if(tp.icon_closed.image) { icons_css += ' background-image:url(' + tp.icon_closed.image + '); '; }
  27. + if(tp.icon_closed.position){ icons_css += ' background-position:' + tp.icon_closed.position + '; '; }
  28. + else { icons_css += ' background-position:0 0; '; }
  29. + icons_css += '} ';
  30. + }
  31. + if( tp.icon_open && (tp.icon_open.image || tp.icon_open.position)) {
  32. + if(i == "default") { icons_css += '.jstree-' + _this.get_index() + ' li.jstree-open a > .jstree-icon { '; }
  33. + else { icons_css += '.jstree-' + _this.get_index() + ' li.jstree-open[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
  34. + if(tp.icon_open.image) { icons_css += ' background-image:url(' + tp.icon_open.image + '); '; }
  35. + if(tp.icon_open.position){ icons_css += ' background-position:' + tp.icon_open.position + '; '; }
  36. + else { icons_css += ' background-position:0 0; '; }
  37. + icons_css += '} ';
  38. + }
  39. });
  40. if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
  41. }, this))
  42. @@ -4523,4 +4539,4 @@
  43. })(jQuery);
  44. //*/
  45.  
  46. -})();
  47. \ No newline at end of file
  48. +})();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.