(function ($) { if(typeof Sarissa == "undefined") throw "jsTree xml_flat: Sarissa is not included."; $.extend($.tree.datastores, { "xml_flat" : function () { return { get : function(obj, t, opts) { var str = ""; if(!obj || $(obj).size() == 0) { obj = t.container.children("ul").children("li"); } else obj = $(obj); if(obj.size() > 1) { var _this = this; var str = ''; obj.each(function () { opts.callback = true; str += _this.get(this, t, opts); }); str += ''; return str; } if(!opts) var opts = {}; if(!opts.outer_attrib) opts.outer_attrib = [ "id", "rel", "class" ]; if(!opts.inner_attrib) opts.inner_attrib = [ ]; if(!opts.callback) str += ''; str += ' 0) str += ' ' + opts.outer_attrib[i] + '="' + val.toString() + '" '; delete val; } str += '>'; str += ''; if(t.settings.languages.length) { for(var i in t.settings.languages) { if(!t.settings.languages.hasOwnProperty(i)) continue; str += this.process_inner(obj.children("a." + t.settings.languages[i]), t, opts, t.settings.languages[i]); } } else { str += this.process_inner(obj.children("a"), t, opts); } str += ''; str += ''; if(obj.children("ul").size() > 0) { var _this = this; opts.callback = true; obj.children("ul").children("li").each(function () { str += _this.get(this, t, opts); }); opts.callback = false; } if(!opts.callback) str += ''; return str; }, process_inner : function(obj, t, opts, lang) { var str = ' 0) str += ' ' + opts.inner_attrib[j] + '="' + val.toString() + '" '; delete val; } } } str += '>'; return str; }, parse : function(data, t, opts, callback) { var processor = new XSLTProcessor(); processor.importStylesheet($.tree.datastores.xml_flat.xsl); var result = $((new XMLSerializer()).serializeToString(processor.transformToDocument(data))); if(result.is("ul")) result = result.html(); else result = result.find("ul").html(); if(callback) callback.call(null,result); // Disabled because of Chrome issues // if(callback) callback.call(null,(new XMLSerializer()).serializeToString(processor.transformToDocument(data)).replace(/^]*>/i,"").replace(/<\/ul>$/i,"")); }, load : function(data, t, opts, callback) { if(opts.static) { callback.call(null, (new DOMParser()).parseFromString(opts.static,'text/xml')); } else { $.ajax({ 'type' : opts.method, 'url' : opts.url, 'data' : data, 'dataType' : "xml", 'success' : function (d, textStatus) { callback.call(null, d); }, 'error' : function (xhttp, textStatus, errorThrown) { callback.call(null, false); t.error(errorThrown + " " + textStatus); } }); } } } } }); $.tree.datastores.xml_flat.xsl = (new DOMParser()).parseFromString('
  • last open closed leaf background-image:url(); 
  • ','text/xml'); })(jQuery);