/** * jquery.tree * ----------- * Simple Tree control * @version 1.0 * @class * @author Niko Berger * @license MIT License GPL */ ;(function( $, window, undefined ){ "use strict"; var TREE_INIT_FUNCTIONS = {}, // remember initialization functions TREE_MAP = {}; // remember all trees /** * @param element {Node} the cotnainer node that should be converted to a tree * @param options {object} the configuraton object * @constructor */ function Tree (element, options) { // create the options this.options = $.extend({}, { /** * automatically prepend icons */ autoIcon: false, /** * open all levels */ open: false, /** * remember which part of the tree was open in a cookie (non-null = name of the cookie) */ remember: null, /** * field used for id (only required for remembering which node was "open") */ id: null, /** * field used as name, this can also be a function that renders the object */ name: "name", /** * field used for title */ title: null, /** * field to recurse into */ children: "children", /** * set to true to allow multiple elements to be selected */ multiple: false, /** * style when a node is active (null: disables activation) */ active: "ui-state-active", hover: "ui-state-hover", /** * the object used to fill/collect data */ data: null, /** * true to execute the loaddata automatically */ load: true, /** * callback function for data fetching */ loadData: null, /** * callback function when a node is selected */ select: null, /** * callback function when a node is double clicked */ dblclick: null, /** * callback function when a node is drag/dropped. if null drag/dropping is disabled */ drop: null, /** * optional "root" target which will be visible when dragging starts */ rootTarget: 'Root' }, options); this.element = element; if(this.options.load && this.options.loadData) { this.options.loadData(); } this._init(); } /** * init the portlet - load the config * @private */ Tree.prototype._init = function() { // fill everything this._repaint(); }; Tree.prototype._paint = function(basenode, data) { // return if empty if(!data || !data.length || data.length == 0) return; var that = this, config = this.options, $this = $(this.element); var root = $('