Return to Snippet

Revision: 36639
at November 24, 2010 08:43 by smchristensen


Initial Code
Index: jquery.jstree.js
===================================================================
--- jquery.jstree.js	(revision 233)
+++ jquery.jstree.js	(working copy)
@@ -3781,17 +3781,33 @@
 
 						$.each(types, function (i, tp) {
 							$.each(tp, function (k, v) { 
-								if(!/^(max_depth|max_children|icon|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
+								if(!/^(max_depth|max_children|icon|icon_open|icon_closed|valid_children)$/.test(k)) { _this.data.types.attach_to.push(k); }
 							});
-							if(!tp.icon) { return true; }
+							if(!tp.icon && !tp.icon_open && !tp.icon_closed) { return true; }
 							if( tp.icon.image || tp.icon.position) {
-								if(i == "default")	{ icons_css += '.jstree-' + _this.get_index() + ' a > .jstree-icon { '; }
+								if(i == "default")	{ icons_css += '.jstree-' + _this.get_index() + ' li a > .jstree-icon { '; }
 								else				{ icons_css += '.jstree-' + _this.get_index() + ' li[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
 								if(tp.icon.image)	{ icons_css += ' background-image:url(' + tp.icon.image + '); '; }
 								if(tp.icon.position){ icons_css += ' background-position:' + tp.icon.position + '; '; }
 								else				{ icons_css += ' background-position:0 0; '; }
 								icons_css += '} ';
 							}
+							if( tp.icon_closed && (tp.icon_closed.image || tp.icon_closed.position)) {
+								if(i == "default")	{ icons_css += '.jstree-' + _this.get_index() + ' li.jstree-closed a > .jstree-icon { '; }
+								else				{ icons_css += '.jstree-' + _this.get_index() + ' li.jstree-closed[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
+								if(tp.icon_closed.image)	{ icons_css += ' background-image:url(' + tp.icon_closed.image + '); '; }
+								if(tp.icon_closed.position){ icons_css += ' background-position:' + tp.icon_closed.position + '; '; }
+								else				{ icons_css += ' background-position:0 0; '; }
+								icons_css += '} ';
+							}
+							if( tp.icon_open && (tp.icon_open.image || tp.icon_open.position)) {
+								if(i == "default")	{ icons_css += '.jstree-' + _this.get_index() + ' li.jstree-open a > .jstree-icon { '; }
+								else				{ icons_css += '.jstree-' + _this.get_index() + ' li.jstree-open[' + attr + '="' + i + '"] > a > .jstree-icon { '; }
+								if(tp.icon_open.image)	{ icons_css += ' background-image:url(' + tp.icon_open.image + '); '; }
+								if(tp.icon_open.position){ icons_css += ' background-position:' + tp.icon_open.position + '; '; }
+								else				{ icons_css += ' background-position:0 0; '; }
+								icons_css += '} ';
+							}
 						});
 						if(icons_css !== "") { $.vakata.css.add_sheet({ 'str' : icons_css, title : "jstree-types" }); }
 					}, this))
@@ -4523,4 +4539,4 @@
 })(jQuery);
 //*/
 
-})();
\ No newline at end of file
+})();

Initial URL


Initial Description
Based on revision 233

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

Initial Tags


Initial Language
SVN