/* File: jstree.json.js This plugin makes it possible for jstree to use JSON data sources. */ /* Group: jstree json plugin */ (function ($) { $.jstree.plugin("json", { __construct : function () { this.get_container() .bind("__after_close.jstree", $.proxy(function (e, data) { var t = $(data.rslt.obj); if(this.get_settings(true).json.progressive_unload) { t.data('jstree').children = this.get_json(t)[0].children; t.children("ul").remove(); } }, this)); }, defaults : { data : false, ajax : false, progressive_render : false, // get_json, data on each node progressive_unload : false }, _fn : { parse_json : function (node) { var s = this.get_settings(true).json; if($.isArray(node.children)) { if(s.progressive_render) { if(!node.data) { node.data = {}; } if(!node.data.jstree) { node.data.jstree = {}; } node.data.jstree.children = node.children; node.children = true; } } return this.__call_old(true, node); }, _append_json_data : function (dom, data) { dom = this.get_node(dom); if(dom === -1) { dom = this.get_container(); } data = this.parse_json(data); if(!data || !dom.length) { return false; } if(!dom.children('ul').length) { dom.append('