geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [18/96] [abbrv] [partial] incubator-geode git commit: GEODE-12: rename pulse to gemfire-pulse and make build pass
Date Thu, 21 Jan 2016 22:54:59 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/446f451a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.tablednd.js
----------------------------------------------------------------------
diff --git a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.tablednd.js b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.tablednd.js
new file mode 100644
index 0000000..8e86f2f
--- /dev/null
+++ b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.tablednd.js
@@ -0,0 +1,383 @@
+/**
+ * TableDnD plug-in for JQuery, allows you to drag and drop table rows
+ * You can set up various options to control how the system will work
+ * Copyright (c) Denis Howlett <denish@isocra.com>
+ * Licensed like jQuery, see http://docs.jquery.com/License.
+ *
+ * Configuration options:
+ * 
+ * onDragStyle
+ *     This is the style that is assigned to the row during drag. There are limitations to the styles that can be
+ *     associated with a row (such as you can't assign a border--well you can, but it won't be
+ *     displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
+ *     a map (as used in the jQuery css(...) function).
+ * onDropStyle
+ *     This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
+ *     to what you can do. Also this replaces the original style, so again consider using onDragClass which
+ *     is simply added and then removed on drop.
+ * onDragClass
+ *     This class is added for the duration of the drag and then removed when the row is dropped. It is more
+ *     flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
+ *     is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
+ *     stylesheet.
+ * onDrop
+ *     Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
+ *     and the row that was dropped. You can work out the new order of the rows by using
+ *     table.rows.
+ * onDragStart
+ *     Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
+ *     table and the row which the user has started to drag.
+ * onAllowDrop
+ *     Pass a function that will be called as a row is over another row. If the function returns true, allow 
+ *     dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
+ *     the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
+ * scrollAmount
+ *     This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
+ *     window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
+ *     FF3 beta
+ * dragHandle
+ *     This is the name of a class that you assign to one or more cells in each row that is draggable. If you
+ *     specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
+ *     will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
+ *     the whole row is draggable.
+ * 
+ * Other ways to control behaviour:
+ *
+ * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
+ * that you don't want to be draggable.
+ *
+ * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
+ * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
+ * an ID as must all the rows.
+ *
+ * Other methods:
+ *
+ * $("...").tableDnDUpdate() 
+ * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
+ * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
+ * The table maintains the original configuration (so you don't have to specify it again).
+ *
+ * $("...").tableDnDSerialize()
+ * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
+ * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
+ *
+ * Known problems:
+ * - Auto-scoll has some problems with IE7  (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
+ * 
+ * Version 0.2: 2008-02-20 First public version
+ * Version 0.3: 2008-02-07 Added onDragStart option
+ *                         Made the scroll amount configurable (default is 5 as before)
+ * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
+ *                         Added onAllowDrop to control dropping
+ *                         Fixed a bug which meant that you couldn't set the scroll amount in both directions
+ *                         Added serialize method
+ * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
+ *                         draggable
+ *                         Improved the serialize method to use a default (and settable) regular expression.
+ *                         Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
+ */
+jQuery.tableDnD = {
+    /** Keep hold of the current table being dragged */
+    currentTable : null,
+    /** Keep hold of the current drag object if any */
+    dragObject: null,
+    /** The current mouse offset */
+    mouseOffset: null,
+    /** Remember the old value of Y so that we don't do too much processing */
+    oldY: 0,
+
+    /** Actually build the structure */
+    build: function(options) {
+        // Set up the defaults if any
+
+        this.each(function() {
+            // This is bound to each matching table, set up the defaults and override with user options
+            this.tableDnDConfig = jQuery.extend({
+                onDragStyle: null,
+                onDropStyle: null,
+				// Add in the default class for whileDragging
+				onDragClass: "tDnD_whileDrag",
+                onDrop: null,
+                onDragStart: null,
+                scrollAmount: 5,
+				serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
+				serializeParamName: null, // If you want to specify another parameter name instead of the table ID
+                dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
+            }, options || {});
+            // Now make the rows draggable
+            jQuery.tableDnD.makeDraggable(this);
+        });
+
+        // Now we need to capture the mouse up and mouse move event
+        // We can use bind so that we don't interfere with other event handlers
+        jQuery(document)
+            .bind('mousemove', jQuery.tableDnD.mousemove)
+            .bind('mouseup', jQuery.tableDnD.mouseup);
+
+        // Don't break the chain
+        return this;
+    },
+
+    /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
+    makeDraggable: function(table) {
+        var config = table.tableDnDConfig;
+		if (table.tableDnDConfig.dragHandle) {
+			// We only need to add the event to the specified cells
+			var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
+			cells.each(function() {
+				// The cell is bound to "this"
+                jQuery(this).mousedown(function(ev) {
+                    jQuery.tableDnD.dragObject = this.parentNode;
+                    jQuery.tableDnD.currentTable = table;
+                    jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
+                    if (config.onDragStart) {
+                        // Call the onDrop method if there is one
+                        config.onDragStart(table, this);
+                    }
+                    return false;
+                });
+			})
+		} else {
+			// For backwards compatibility, we add the event to the whole row
+	        var rows = jQuery("tr", table); // get all the rows as a wrapped set
+	        rows.each(function() {
+				// Iterate through each row, the row is bound to "this"
+				var row = jQuery(this);
+				if (! row.hasClass("nodrag")) {
+	                row.mousedown(function(ev) {
+	                    if (ev.target.tagName == "TD") {
+	                        jQuery.tableDnD.dragObject = this;
+	                        jQuery.tableDnD.currentTable = table;
+	                        jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
+	                        if (config.onDragStart) {
+	                            // Call the onDrop method if there is one
+	                            config.onDragStart(table, this);
+	                        }
+	                        return false;
+	                    }
+	                }).css("cursor", "move"); // Store the tableDnD object
+				}
+			});
+		}
+	},
+
+	updateTables: function() {
+		this.each(function() {
+			// this is now bound to each matching table
+			if (this.tableDnDConfig) {
+				jQuery.tableDnD.makeDraggable(this);
+			}
+		})
+	},
+
+    /** Get the mouse coordinates from the event (allowing for browser differences) */
+    mouseCoords: function(ev){
+        if(ev.pageX || ev.pageY){
+            return {x:ev.pageX, y:ev.pageY};
+        }
+        return {
+            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
+            y:ev.clientY + document.body.scrollTop  - document.body.clientTop
+        };
+    },
+
+    /** Given a target element and a mouse event, get the mouse offset from that element.
+        To do this we need the element's position and the mouse position */
+    getMouseOffset: function(target, ev) {
+        ev = ev || window.event;
+
+        var docPos    = this.getPosition(target);
+        var mousePos  = this.mouseCoords(ev);
+        return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
+    },
+
+    /** Get the position of an element by going up the DOM tree and adding up all the offsets */
+    getPosition: function(e){
+        var left = 0;
+        var top  = 0;
+        /** Safari fix -- thanks to Luis Chato for this! */
+        if (e.offsetHeight == 0) {
+            /** Safari 2 doesn't correctly grab the offsetTop of a table row
+            this is detailed here:
+            http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
+            the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
+            note that firefox will return a text node as a first child, so designing a more thorough
+            solution may need to take that into account, for now this seems to work in firefox, safari, ie */
+            e = e.firstChild; // a table cell
+        }
+		if (e && e.offsetParent) {
+        	while (e.offsetParent){
+            	left += e.offsetLeft;
+            	top  += e.offsetTop;
+            	e     = e.offsetParent;
+        	}
+
+        	left += e.offsetLeft;
+        	top  += e.offsetTop;
+        }
+
+        return {x:left, y:top};
+    },
+
+    mousemove: function(ev) {
+        if (jQuery.tableDnD.dragObject == null) {
+            return;
+        }
+
+        var dragObj = jQuery(jQuery.tableDnD.dragObject);
+        var config = jQuery.tableDnD.currentTable.tableDnDConfig;
+        var mousePos = jQuery.tableDnD.mouseCoords(ev);
+        var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
+        //auto scroll the window
+	    var yOffset = window.pageYOffset;
+	 	if (document.all) {
+	        // Windows version
+	        //yOffset=document.body.scrollTop;
+	        if (typeof document.compatMode != 'undefined' &&
+	             document.compatMode != 'BackCompat') {
+	           yOffset = document.documentElement.scrollTop;
+	        }
+	        else if (typeof document.body != 'undefined') {
+	           yOffset=document.body.scrollTop;
+	        }
+
+	    }
+		    
+		if (mousePos.y-yOffset < config.scrollAmount) {
+	    	window.scrollBy(0, -config.scrollAmount);
+	    } else {
+            var windowHeight = window.innerHeight ? window.innerHeight
+                    : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
+            if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
+                window.scrollBy(0, config.scrollAmount);
+            }
+        }
+
+
+        if (y != jQuery.tableDnD.oldY) {
+            // work out if we're going up or down...
+            var movingDown = y > jQuery.tableDnD.oldY;
+            // update the old value
+            jQuery.tableDnD.oldY = y;
+            // update the style to show we're dragging
+			if (config.onDragClass) {
+				dragObj.addClass(config.onDragClass);
+			} else {
+	            dragObj.css(config.onDragStyle);
+			}
+            // If we're over a row then move the dragged row to there so that the user sees the
+            // effect dynamically
+            var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
+            if (currentRow) {
+                // TODO worry about what happens when there are multiple TBODIES
+                if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
+                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
+                } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
+                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
+                }
+            }
+        }
+
+        return false;
+    },
+
+    /** We're only worried about the y position really, because we can only move rows up and down */
+    findDropTargetRow: function(draggedRow, y) {
+        var rows = jQuery.tableDnD.currentTable.rows;
+        for (var i=0; i<rows.length; i++) {
+            var row = rows[i];
+            var rowY    = this.getPosition(row).y;
+            var rowHeight = parseInt(row.offsetHeight)/2;
+            if (row.offsetHeight == 0) {
+                rowY = this.getPosition(row.firstChild).y;
+                rowHeight = parseInt(row.firstChild.offsetHeight)/2;
+            }
+            // Because we always have to insert before, we need to offset the height a bit
+            if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
+                // that's the row we're over
+				// If it's the same as the current row, ignore it
+				if (row == draggedRow) {return null;}
+                var config = jQuery.tableDnD.currentTable.tableDnDConfig;
+                if (config.onAllowDrop) {
+                    if (config.onAllowDrop(draggedRow, row)) {
+                        return row;
+                    } else {
+                        return null;
+                    }
+                } else {
+					// If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
+                    var nodrop = jQuery(row).hasClass("nodrop");
+                    if (! nodrop) {
+                        return row;
+                    } else {
+                        return null;
+                    }
+                }
+                return row;
+            }
+        }
+        return null;
+    },
+
+    mouseup: function(e) {
+        if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
+            var droppedRow = jQuery.tableDnD.dragObject;
+            var config = jQuery.tableDnD.currentTable.tableDnDConfig;
+            // If we have a dragObject, then we need to release it,
+            // The row will already have been moved to the right place so we just reset stuff
+			if (config.onDragClass) {
+	            jQuery(droppedRow).removeClass(config.onDragClass);
+			} else {
+	            jQuery(droppedRow).css(config.onDropStyle);
+			}
+            jQuery.tableDnD.dragObject   = null;
+            if (config.onDrop) {
+                // Call the onDrop method if there is one
+                config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
+            }
+            jQuery.tableDnD.currentTable = null; // let go of the table too
+        }
+    },
+
+    serialize: function() {
+        if (jQuery.tableDnD.currentTable) {
+            return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
+        } else {
+            return "Error: No Table id set, you need to set an id on your table and every row";
+        }
+    },
+
+	serializeTable: function(table) {
+        var result = "";
+        var tableId = table.id;
+        var rows = table.rows;
+        for (var i=0; i<rows.length; i++) {
+            if (result.length > 0) result += "&";
+            var rowId = rows[i].id;
+            if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
+                rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
+            }
+
+            result += tableId + '[]=' + rowId;
+        }
+        return result;
+	},
+
+	serializeTables: function() {
+        var result = "";
+        this.each(function() {
+			// this is now bound to each matching table
+			result += jQuery.tableDnD.serializeTable(this);
+		});
+        return result;
+    }
+
+}
+
+jQuery.fn.extend(
+	{
+		tableDnD : jQuery.tableDnD.build,
+		tableDnDUpdate : jQuery.tableDnD.updateTables,
+		tableDnDSerialize: jQuery.tableDnD.serializeTables
+	}
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/446f451a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.timeago.js
----------------------------------------------------------------------
diff --git a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.timeago.js b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.timeago.js
new file mode 100644
index 0000000..4d58026
--- /dev/null
+++ b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.timeago.js
@@ -0,0 +1,193 @@
+/**
+ * Timeago is a jQuery plugin that makes it easy to support automatically
+ * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
+ *
+ * @name timeago
+ * @version 1.3.0
+ * @requires jQuery v1.2.3+
+ * @author Ryan McGeary
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
+ *
+ * For usage and examples, visit:
+ * http://timeago.yarp.com/
+ *
+ * Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
+ */
+
+(function (factory) {
+  if (typeof define === 'function' && define.amd) {
+    // AMD. Register as an anonymous module.
+    define(['jquery'], factory);
+  } else {
+    // Browser globals
+    factory(jQuery);
+  }
+}(function ($) {
+  $.timeago = function(timestamp) {
+    if (timestamp instanceof Date) {
+      return inWords(timestamp);
+    } else if (typeof timestamp === "string") {
+      return inWords($.timeago.parse(timestamp));
+    } else if (typeof timestamp === "number") {
+      return inWords(new Date(timestamp));
+    } else {
+      return inWords($.timeago.datetime(timestamp));
+    }
+  };
+  var $t = $.timeago;
+
+  $.extend($.timeago, {
+    settings: {
+      refreshMillis: 60000,
+      allowFuture: false,
+      localeTitle: false,
+      cutoff: 0,
+      strings: {
+        prefixAgo: null,
+        prefixFromNow: null,
+        suffixAgo: "ago",
+        suffixFromNow: "from now",
+        seconds: "less than a minute",
+        minute: "about a minute",
+        minutes: "%d minutes",
+        hour: "about an hour",
+        hours: "about %d hours",
+        day: "a day",
+        days: "%d days",
+        month: "about a month",
+        months: "%d months",
+        year: "about a year",
+        years: "%d years",
+        wordSeparator: " ",
+        numbers: []
+      }
+    },
+    inWords: function(distanceMillis) {
+      var $l = this.settings.strings;
+      var prefix = $l.prefixAgo;
+      var suffix = $l.suffixAgo;
+      if (this.settings.allowFuture) {
+        if (distanceMillis < 0) {
+          prefix = $l.prefixFromNow;
+          suffix = $l.suffixFromNow;
+        }
+      }
+
+      var seconds = Math.abs(distanceMillis) / 1000;
+      var minutes = seconds / 60;
+      var hours = minutes / 60;
+      var days = hours / 24;
+      var years = days / 365;
+
+      function substitute(stringOrFunction, number) {
+        var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
+        var value = ($l.numbers && $l.numbers[number]) || number;
+        return string.replace(/%d/i, value);
+      }
+
+      var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
+        seconds < 90 && substitute($l.minute, 1) ||
+        minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
+        minutes < 90 && substitute($l.hour, 1) ||
+        hours < 24 && substitute($l.hours, Math.round(hours)) ||
+        hours < 42 && substitute($l.day, 1) ||
+        days < 30 && substitute($l.days, Math.round(days)) ||
+        days < 45 && substitute($l.month, 1) ||
+        days < 365 && substitute($l.months, Math.round(days / 30)) ||
+        years < 1.5 && substitute($l.year, 1) ||
+        substitute($l.years, Math.round(years));
+
+      var separator = $l.wordSeparator || "";
+      if ($l.wordSeparator === undefined) { separator = " "; }
+      return $.trim([prefix, words, suffix].join(separator));
+    },
+    parse: function(iso8601) {
+      var s = $.trim(iso8601);
+      s = s.replace(/\.\d+/,""); // remove milliseconds
+      s = s.replace(/-/,"/").replace(/-/,"/");
+      s = s.replace(/T/," ").replace(/Z/," UTC");
+      s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
+      return new Date(s);
+    },
+    datetime: function(elem) {
+      var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
+      return $t.parse(iso8601);
+    },
+    isTime: function(elem) {
+      // jQuery's `is()` doesn't play well with HTML5 in IE
+      return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
+    }
+  });
+
+  // functions that can be called via $(el).timeago('action')
+  // init is default when no action is given
+  // functions are called with context of a single element
+  var functions = {
+    init: function(){
+      var refresh_el = $.proxy(refresh, this);
+      refresh_el();
+      var $s = $t.settings;
+      if ($s.refreshMillis > 0) {
+        setInterval(refresh_el, $s.refreshMillis);
+      }
+    },
+    update: function(time){
+      $(this).data('timeago', { datetime: $t.parse(time) });
+      refresh.apply(this);
+    },
+    updateFromDOM: function(){
+      $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
+      refresh.apply(this);
+    }
+  };
+
+  $.fn.timeago = function(action, options) {
+    var fn = action ? functions[action] : functions.init;
+    if(!fn){
+      throw new Error("Unknown function name '"+ action +"' for timeago");
+    }
+    // each over objects here and call the requested function
+    this.each(function(){
+      fn.call(this, options);
+    });
+    return this;
+  };
+
+  function refresh() {
+    var data = prepareData(this);
+    var $s = $t.settings;
+
+    if (!isNaN(data.datetime)) {
+      if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {
+        $(this).text(inWords(data.datetime));
+      }
+    }
+    return this;
+  }
+
+  function prepareData(element) {
+    element = $(element);
+    if (!element.data("timeago")) {
+      element.data("timeago", { datetime: $t.datetime(element) });
+      var text = $.trim(element.text());
+      if ($t.settings.localeTitle) {
+        element.attr("title", element.data('timeago').datetime.toLocaleString());
+      } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
+        element.attr("title", text);
+      }
+    }
+    return element.data("timeago");
+  }
+
+  function inWords(date) {
+    return $t.inWords(distance(date));
+  }
+
+  function distance(date) {
+    return (new Date().getTime() - date.getTime());
+  }
+
+  // fix for IE6 suckage
+  document.createElement("abbr");
+  document.createElement("time");
+}));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/446f451a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.ztree.core-3.5.js
----------------------------------------------------------------------
diff --git a/gemfire-pulse/src/main/webapp/scripts/lib/jquery.ztree.core-3.5.js b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.ztree.core-3.5.js
new file mode 100644
index 0000000..493d173
--- /dev/null
+++ b/gemfire-pulse/src/main/webapp/scripts/lib/jquery.ztree.core-3.5.js
@@ -0,0 +1,1650 @@
+/*
+ * JQuery zTree core 3.5.02
+ * http://zTree.me/
+ *
+ * Copyright (c) 2010 Hunter.z
+ *
+ * Licensed same as jquery - MIT License
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * email: hunter.z@263.net
+ * Date: 2013-01-28
+ */
+(function($){
+	var settings = {}, roots = {}, caches = {},
+	//default consts of core
+	_consts = {
+		event: {
+			NODECREATED: "ztree_nodeCreated",
+			CLICK: "ztree_click",
+			EXPAND: "ztree_expand",
+			COLLAPSE: "ztree_collapse",
+			ASYNC_SUCCESS: "ztree_async_success",
+			ASYNC_ERROR: "ztree_async_error"
+		},
+		id: {
+			A: "_a",
+			ICON: "_ico",
+			SPAN: "_span",
+			SWITCH: "_switch",
+			UL: "_ul"
+		},
+		line: {
+			ROOT: "root",
+			ROOTS: "roots",
+			CENTER: "center",
+			BOTTOM: "bottom",
+			NOLINE: "noline",
+			LINE: "line"
+		},
+		folder: {
+			OPEN: "open",
+			CLOSE: "close",
+			DOCU: "docu"
+		},
+		node: {
+			CURSELECTED: ""
+		}
+	},
+	//default setting of core
+	_setting = {
+		treeId: "",
+		treeObj: null,
+		view: {
+			addDiyDom: null,
+			autoCancelSelected: true,
+			dblClickExpand: true,
+			expandSpeed: "fast",
+			fontCss: {},
+			nameIsHTML: false,
+			selectedMulti: true,
+			showIcon: true,
+			showLine: true,
+			showTitle: true
+		},
+		data: {
+			key: {
+				children: "children",
+				name: "name",
+				title: "",
+				url: "url"
+			},
+			simpleData: {
+				enable: false,
+				idKey: "id",
+				pIdKey: "pId",
+				rootPId: null
+			},
+			keep: {
+				parent: false,
+				leaf: false
+			}
+		},
+		async: {
+			enable: false,
+			contentType: "application/x-www-form-urlencoded",
+			type: "post",
+			dataType: "text",
+			url: "",
+			autoParam: [],
+			otherParam: [],
+			dataFilter: null
+		},
+		callback: {
+			beforeAsync:null,
+			beforeClick:null,
+			beforeDblClick:null,
+			beforeRightClick:null,
+			beforeMouseDown:null,
+			beforeMouseUp:null,
+			beforeExpand:null,
+			beforeCollapse:null,
+			beforeRemove:null,
+
+			onAsyncError:null,
+			onAsyncSuccess:null,
+			onNodeCreated:null,
+			onClick:null,
+			onDblClick:null,
+			onRightClick:null,
+			onMouseDown:null,
+			onMouseUp:null,
+			onExpand:null,
+			onCollapse:null,
+			onRemove:null
+		}
+	},
+	//default root of core
+	//zTree use root to save full data
+	_initRoot = function (setting) {
+		var r = data.getRoot(setting);
+		if (!r) {
+			r = {};
+			data.setRoot(setting, r);
+		}
+		r[setting.data.key.children] = [];
+		r.expandTriggerFlag = false;
+		r.curSelectedList = [];
+		r.noSelection = true;
+		r.createdNodes = [];
+		r.zId = 0;
+		r._ver = (new Date()).getTime();
+	},
+	//default cache of core
+	_initCache = function(setting) {
+		var c = data.getCache(setting);
+		if (!c) {
+			c = {};
+			data.setCache(setting, c);
+		}
+		c.nodes = [];
+		c.doms = [];
+	},
+	//default bindEvent of core
+	_bindEvent = function(setting) {
+		var o = setting.treeObj,
+		c = consts.event;
+		o.bind(c.NODECREATED, function (event, treeId, node) {
+			tools.apply(setting.callback.onNodeCreated, [event, treeId, node]);
+		});
+
+		o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) {
+			tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]);
+		});
+
+		o.bind(c.EXPAND, function (event, treeId, node) {
+			tools.apply(setting.callback.onExpand, [event, treeId, node]);
+		});
+
+		o.bind(c.COLLAPSE, function (event, treeId, node) {
+			tools.apply(setting.callback.onCollapse, [event, treeId, node]);
+		});
+
+		o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) {
+			tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]);
+		});
+
+		o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) {
+			tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]);
+		});
+	},
+	_unbindEvent = function(setting) {
+		var o = setting.treeObj,
+		c = consts.event;
+		o.unbind(c.NODECREATED)
+		.unbind(c.CLICK)
+		.unbind(c.EXPAND)
+		.unbind(c.COLLAPSE)
+		.unbind(c.ASYNC_SUCCESS)
+		.unbind(c.ASYNC_ERROR);
+	},	
+	//default event proxy of core
+	_eventProxy = function(event) {
+		var target = event.target,
+		setting = data.getSetting(event.data.treeId),
+		tId = "", node = null,
+		nodeEventType = "", treeEventType = "",
+		nodeEventCallback = null, treeEventCallback = null,
+		tmp = null;
+
+		if (tools.eqs(event.type, "mousedown")) {
+			treeEventType = "mousedown";
+		} else if (tools.eqs(event.type, "mouseup")) {
+			treeEventType = "mouseup";
+		} else if (tools.eqs(event.type, "contextmenu")) {
+			treeEventType = "contextmenu";
+		} else if (tools.eqs(event.type, "click")) {
+			if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) {
+				tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id;
+				nodeEventType = "switchNode";
+			} else {
+				tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+				if (tmp) {
+					tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
+					nodeEventType = "clickNode";
+				}
+			}
+		} else if (tools.eqs(event.type, "dblclick")) {
+			treeEventType = "dblclick";
+			tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+			if (tmp) {
+				tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
+				nodeEventType = "switchNode";
+			}
+		}
+		if (treeEventType.length > 0 && tId.length == 0) {
+			tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
+			if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;}
+		}
+		// event to node
+		if (tId.length>0) {
+			node = data.getNodeCache(setting, tId);
+			switch (nodeEventType) {
+				case "switchNode" :
+					if (!node.isParent) {
+						nodeEventType = "";
+					} else if (tools.eqs(event.type, "click") 
+						|| (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) {
+						nodeEventCallback = handler.onSwitchNode;
+					} else {
+						nodeEventType = "";
+					}
+					break;
+				case "clickNode" :
+					nodeEventCallback = handler.onClickNode;
+					break;
+			}
+		}
+		// event to zTree
+		switch (treeEventType) {
+			case "mousedown" :
+				treeEventCallback = handler.onZTreeMousedown;
+				break;
+			case "mouseup" :
+				treeEventCallback = handler.onZTreeMouseup;
+				break;
+			case "dblclick" :
+				treeEventCallback = handler.onZTreeDblclick;
+				break;
+			case "contextmenu" :
+				treeEventCallback = handler.onZTreeContextmenu;
+				break;
+		}
+		var proxyResult = {
+			stop: false,
+			node: node,
+			nodeEventType: nodeEventType,
+			nodeEventCallback: nodeEventCallback,
+			treeEventType: treeEventType,
+			treeEventCallback: treeEventCallback
+		};
+		return proxyResult
+	},
+	//default init node of core
+	_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
+		if (!n) return;
+		var r = data.getRoot(setting),
+		childKey = setting.data.key.children;
+		n.level = level;
+		n.tId = setting.treeId + "_" + (++r.zId);
+		n.parentTId = parentNode ? parentNode.tId : null;
+		if (n[childKey] && n[childKey].length > 0) {
+			if (typeof n.open == "string") n.open = tools.eqs(n.open, "true");
+			n.open = !!n.open;
+			n.isParent = true;
+			n.zAsync = true;
+		} else {
+			n.open = false;
+			if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true");
+			n.isParent = !!n.isParent;
+			n.zAsync = !n.isParent;
+		}
+		n.isFirstNode = isFirstNode;
+		n.isLastNode = isLastNode;
+		n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);};
+		n.getPreNode = function() {return data.getPreNode(setting, n);};
+		n.getNextNode = function() {return data.getNextNode(setting, n);};
+		n.isAjaxing = false;
+		data.fixPIdKeyValue(setting, n);
+	},
+	_init = {
+		bind: [_bindEvent],
+		unbind: [_unbindEvent],
+		caches: [_initCache],
+		nodes: [_initNode],
+		proxys: [_eventProxy],
+		roots: [_initRoot],
+		beforeA: [],
+		afterA: [],
+		innerBeforeA: [],
+		innerAfterA: [],
+		zTreeTools: []
+	},
+	//method of operate data
+	data = {
+		addNodeCache: function(setting, node) {
+			data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node;
+		},
+		getNodeCacheId: function(tId) {
+			return tId.substring(tId.lastIndexOf("_")+1);
+		},
+		addAfterA: function(afterA) {
+			_init.afterA.push(afterA);
+		},
+		addBeforeA: function(beforeA) {
+			_init.beforeA.push(beforeA);
+		},
+		addInnerAfterA: function(innerAfterA) {
+			_init.innerAfterA.push(innerAfterA);
+		},
+		addInnerBeforeA: function(innerBeforeA) {
+			_init.innerBeforeA.push(innerBeforeA);
+		},
+		addInitBind: function(bindEvent) {
+			_init.bind.push(bindEvent);
+		},
+		addInitUnBind: function(unbindEvent) {
+			_init.unbind.push(unbindEvent);
+		},
+		addInitCache: function(initCache) {
+			_init.caches.push(initCache);
+		},
+		addInitNode: function(initNode) {
+			_init.nodes.push(initNode);
+		},
+		addInitProxy: function(initProxy) {
+			_init.proxys.push(initProxy);
+		},
+		addInitRoot: function(initRoot) {
+			_init.roots.push(initRoot);
+		},
+		addNodesData: function(setting, parentNode, nodes) {
+			var childKey = setting.data.key.children;
+			if (!parentNode[childKey]) parentNode[childKey] = [];
+			if (parentNode[childKey].length > 0) {
+				parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false;
+				view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]);
+			}
+			parentNode.isParent = true;
+			parentNode[childKey] = parentNode[childKey].concat(nodes);
+		},
+		addSelectedNode: function(setting, node) {
+			var root = data.getRoot(setting);
+			if (!data.isSelectedNode(setting, node)) {
+				root.curSelectedList.push(node);
+			}
+		},
+		addCreatedNode: function(setting, node) {
+			if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
+				var root = data.getRoot(setting);
+				root.createdNodes.push(node);
+			}
+		},
+		addZTreeTools: function(zTreeTools) {
+			_init.zTreeTools.push(zTreeTools);
+		},
+		exSetting: function(s) {
+			$.extend(true, _setting, s);
+		},
+		fixPIdKeyValue: function(setting, node) {
+			if (setting.data.simpleData.enable) {
+				node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId;
+			}
+		},
+		getAfterA: function(setting, node, array) {
+			for (var i=0, j=_init.afterA.length; i<j; i++) {
+				_init.afterA[i].apply(this, arguments);
+			}
+		},
+		getBeforeA: function(setting, node, array) {
+			for (var i=0, j=_init.beforeA.length; i<j; i++) {
+				_init.beforeA[i].apply(this, arguments);
+			}
+		},
+		getInnerAfterA: function(setting, node, array) {
+			for (var i=0, j=_init.innerAfterA.length; i<j; i++) {
+				_init.innerAfterA[i].apply(this, arguments);
+			}
+		},
+		getInnerBeforeA: function(setting, node, array) {
+			for (var i=0, j=_init.innerBeforeA.length; i<j; i++) {
+				_init.innerBeforeA[i].apply(this, arguments);
+			}
+		},
+		getCache: function(setting) {
+			return caches[setting.treeId];
+		},
+		getNextNode: function(setting, node) {
+			if (!node) return null;
+			var childKey = setting.data.key.children,
+			p = node.parentTId ? node.getParentNode() : data.getRoot(setting);
+			for (var i=0, l=p[childKey].length-1; i<=l; i++) {
+				if (p[childKey][i] === node) {
+					return (i==l ? null : p[childKey][i+1]);
+				}
+			}
+			return null;
+		},
+		getNodeByParam: function(setting, nodes, key, value) {
+			if (!nodes || !key) return null;
+			var childKey = setting.data.key.children;
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				if (nodes[i][key] == value) {
+					return nodes[i];
+				}
+				var tmp = data.getNodeByParam(setting, nodes[i][childKey], key, value);
+				if (tmp) return tmp;
+			}
+			return null;
+		},
+		getNodeCache: function(setting, tId) {
+			if (!tId) return null;
+			var n = caches[setting.treeId].nodes[data.getNodeCacheId(tId)];
+			return n ? n : null;
+		},
+		getNodeName: function(setting, node) {
+			var nameKey = setting.data.key.name;
+			return "" + node[nameKey];
+		},
+		getNodeTitle: function(setting, node) {
+			var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title;
+			return "" + node[t];
+		},
+		getNodes: function(setting) {
+			return data.getRoot(setting)[setting.data.key.children];
+		},
+		getNodesByParam: function(setting, nodes, key, value) {
+			if (!nodes || !key) return [];
+			var childKey = setting.data.key.children,
+			result = [];
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				if (nodes[i][key] == value) {
+					result.push(nodes[i]);
+				}
+				result = result.concat(data.getNodesByParam(setting, nodes[i][childKey], key, value));
+			}
+			return result;
+		},
+		getNodesByParamFuzzy: function(setting, nodes, key, value) {
+			if (!nodes || !key) return [];
+			var childKey = setting.data.key.children,
+			result = [];
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				if (typeof nodes[i][key] == "string" && nodes[i][key].indexOf(value)>-1) {
+					result.push(nodes[i]);
+				}
+				result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value));
+			}
+			return result;
+		},
+		getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) {
+			if (!nodes) return (isSingle ? null : []);
+			var childKey = setting.data.key.children,
+			result = isSingle ? null : [];
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				if (tools.apply(filter, [nodes[i], invokeParam], false)) {
+					if (isSingle) {return nodes[i];}
+					result.push(nodes[i]);
+				}
+				var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam);
+				if (isSingle && !!tmpResult) {return tmpResult;}
+				result = isSingle ? tmpResult : result.concat(tmpResult);
+			}
+			return result;
+		},
+		getPreNode: function(setting, node) {
+			if (!node) return null;
+			var childKey = setting.data.key.children,
+			p = node.parentTId ? node.getParentNode() : data.getRoot(setting);
+			for (var i=0, l=p[childKey].length; i<l; i++) {
+				if (p[childKey][i] === node) {
+					return (i==0 ? null : p[childKey][i-1]);
+				}
+			}
+			return null;
+		},
+		getRoot: function(setting) {
+			return setting ? roots[setting.treeId] : null;
+		},
+		getSetting: function(treeId) {
+			return settings[treeId];
+		},
+		getSettings: function() {
+			return settings;
+		},
+		getZTreeTools: function(treeId) {
+			var r = this.getRoot(this.getSetting(treeId));
+			return r ? r.treeTools : null;
+		},
+		initCache: function(setting) {
+			for (var i=0, j=_init.caches.length; i<j; i++) {
+				_init.caches[i].apply(this, arguments);
+			}
+		},
+		initNode: function(setting, level, node, parentNode, preNode, nextNode) {
+			for (var i=0, j=_init.nodes.length; i<j; i++) {
+				_init.nodes[i].apply(this, arguments);
+			}
+		},
+		initRoot: function(setting) {
+			for (var i=0, j=_init.roots.length; i<j; i++) {
+				_init.roots[i].apply(this, arguments);
+			}
+		},
+		isSelectedNode: function(setting, node) {
+			var root = data.getRoot(setting);
+			for (var i=0, j=root.curSelectedList.length; i<j; i++) {
+				if(node === root.curSelectedList[i]) return true;
+			}
+			return false;
+		},
+		removeNodeCache: function(setting, node) {
+			var childKey = setting.data.key.children;
+			if (node[childKey]) {
+				for (var i=0, l=node[childKey].length; i<l; i++) {
+					arguments.callee(setting, node[childKey][i]);
+				}
+			}
+			data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = null;
+		},
+		removeSelectedNode: function(setting, node) {
+			var root = data.getRoot(setting);
+			for (var i=0, j=root.curSelectedList.length; i<j; i++) {
+				if(node === root.curSelectedList[i] || !data.getNodeCache(setting, root.curSelectedList[i].tId)) {
+					root.curSelectedList.splice(i, 1);
+					i--;j--;
+				}
+			}
+		},
+		setCache: function(setting, cache) {
+			caches[setting.treeId] = cache;
+		},
+		setRoot: function(setting, root) {
+			roots[setting.treeId] = root;
+		},
+		setZTreeTools: function(setting, zTreeTools) {
+			for (var i=0, j=_init.zTreeTools.length; i<j; i++) {
+				_init.zTreeTools[i].apply(this, arguments);
+			}
+		},
+		transformToArrayFormat: function (setting, nodes) {
+			if (!nodes) return [];
+			var childKey = setting.data.key.children,
+			r = [];
+			if (tools.isArray(nodes)) {
+				for (var i=0, l=nodes.length; i<l; i++) {
+					r.push(nodes[i]);
+					if (nodes[i][childKey])
+						r = r.concat(data.transformToArrayFormat(setting, nodes[i][childKey]));
+				}
+			} else {
+				r.push(nodes);
+				if (nodes[childKey])
+					r = r.concat(data.transformToArrayFormat(setting, nodes[childKey]));
+			}
+			return r;
+		},
+		transformTozTreeFormat: function(setting, sNodes) {
+			var i,l,
+			key = setting.data.simpleData.idKey,
+			parentKey = setting.data.simpleData.pIdKey,
+			childKey = setting.data.key.children;
+			if (!key || key=="" || !sNodes) return [];
+
+			if (tools.isArray(sNodes)) {
+				var r = [];
+				var tmpMap = [];
+				for (i=0, l=sNodes.length; i<l; i++) {
+					tmpMap[sNodes[i][key]] = sNodes[i];
+				}
+				for (i=0, l=sNodes.length; i<l; i++) {
+					if (tmpMap[sNodes[i][parentKey]] && sNodes[i][key] != sNodes[i][parentKey]) {
+						if (!tmpMap[sNodes[i][parentKey]][childKey])
+							tmpMap[sNodes[i][parentKey]][childKey] = [];
+						tmpMap[sNodes[i][parentKey]][childKey].push(sNodes[i]);
+					} else {
+						r.push(sNodes[i]);
+					}
+				}
+				return r;
+			}else {
+				return [sNodes];
+			}
+		}
+	},
+	//method of event proxy
+	event = {
+		bindEvent: function(setting) {
+			for (var i=0, j=_init.bind.length; i<j; i++) {
+				_init.bind[i].apply(this, arguments);
+			}
+		},
+		unbindEvent: function(setting) {
+			for (var i=0, j=_init.unbind.length; i<j; i++) {
+				_init.unbind[i].apply(this, arguments);
+			}
+		},
+		bindTree: function(setting) {
+			var eventParam = {
+				treeId: setting.treeId
+			},
+			o = setting.treeObj;
+			// for can't select text
+			o.bind('selectstart', function(e){
+					var n = e.srcElement.nodeName.toLowerCase();
+					return (n === "input" || n === "textarea" );
+				}
+			).css({
+				"-moz-user-select":"-moz-none"
+			});
+			o.bind('click', eventParam, event.proxy);
+			o.bind('dblclick', eventParam, event.proxy);
+			o.bind('mouseover', eventParam, event.proxy);
+			o.bind('mouseout', eventParam, event.proxy);
+			o.bind('mousedown', eventParam, event.proxy);
+			o.bind('mouseup', eventParam, event.proxy);
+			o.bind('contextmenu', eventParam, event.proxy);
+		},
+		unbindTree: function(setting) {
+			var o = setting.treeObj;
+			o.unbind('click', event.proxy)
+			.unbind('dblclick', event.proxy)
+			.unbind('mouseover', event.proxy)
+			.unbind('mouseout', event.proxy)
+			.unbind('mousedown', event.proxy)
+			.unbind('mouseup', event.proxy)
+			.unbind('contextmenu', event.proxy);
+		},
+		doProxy: function(e) {
+			var results = [];
+			for (var i=0, j=_init.proxys.length; i<j; i++) {
+				var proxyResult = _init.proxys[i].apply(this, arguments);
+				results.push(proxyResult);
+				if (proxyResult.stop) {
+					break;
+				}
+			}
+			return results;
+		},
+		proxy: function(e) {
+			var setting = data.getSetting(e.data.treeId);
+			if (!tools.uCanDo(setting, e)) return true;
+			var results = event.doProxy(e),
+			r = true, x = false;
+			for (var i=0, l=results.length; i<l; i++) {
+				var proxyResult = results[i];
+				if (proxyResult.nodeEventCallback) {
+					x = true;
+					r = proxyResult.nodeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r;
+				}
+				if (proxyResult.treeEventCallback) {
+					x = true;
+					r = proxyResult.treeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r;
+				}
+			}
+			return r;
+		}
+	},
+	//method of event handler
+	handler = {
+		onSwitchNode: function (event, node) {
+			var setting = data.getSetting(event.data.treeId);
+			if (node.open) {
+				if (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false) return true;
+				data.getRoot(setting).expandTriggerFlag = true;
+				view.switchNode(setting, node);
+			} else {
+				if (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false) return true;
+				data.getRoot(setting).expandTriggerFlag = true;
+				view.switchNode(setting, node);
+			}
+			return true;
+		},
+		onClickNode: function (event, node) {
+			var setting = data.getSetting(event.data.treeId),
+			clickFlag = ( (setting.view.autoCancelSelected && event.ctrlKey) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && event.ctrlKey && setting.view.selectedMulti) ? 2 : 1;
+			if (tools.apply(setting.callback.beforeClick, [setting.treeId, node, clickFlag], true) == false) return true;
+			if (clickFlag === 0) {
+				view.cancelPreSelectedNode(setting, node);
+			} else {
+				view.selectNode(setting, node, clickFlag === 2);
+			}
+			setting.treeObj.trigger(consts.event.CLICK, [event, setting.treeId, node, clickFlag]);
+			return true;
+		},
+		onZTreeMousedown: function(event, node) {
+			var setting = data.getSetting(event.data.treeId);
+			if (tools.apply(setting.callback.beforeMouseDown, [setting.treeId, node], true)) {
+				tools.apply(setting.callback.onMouseDown, [event, setting.treeId, node]);
+			}
+			return true;
+		},
+		onZTreeMouseup: function(event, node) {
+			var setting = data.getSetting(event.data.treeId);
+			if (tools.apply(setting.callback.beforeMouseUp, [setting.treeId, node], true)) {
+				tools.apply(setting.callback.onMouseUp, [event, setting.treeId, node]);
+			}
+			return true;
+		},
+		onZTreeDblclick: function(event, node) {
+			var setting = data.getSetting(event.data.treeId);
+			if (tools.apply(setting.callback.beforeDblClick, [setting.treeId, node], true)) {
+				tools.apply(setting.callback.onDblClick, [event, setting.treeId, node]);
+			}
+			return true;
+		},
+		onZTreeContextmenu: function(event, node) {
+			var setting = data.getSetting(event.data.treeId);
+			if (tools.apply(setting.callback.beforeRightClick, [setting.treeId, node], true)) {
+				tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]);
+			}
+			return (typeof setting.callback.onRightClick) != "function";
+		}
+	},
+	//method of tools for zTree
+	tools = {
+		apply: function(fun, param, defaultValue) {
+			if ((typeof fun) == "function") {
+				return fun.apply(zt, param?param:[]);
+			}
+			return defaultValue;
+		},
+		canAsync: function(setting, node) {
+			var childKey = setting.data.key.children;
+			return (setting.async.enable && node && node.isParent && !(node.zAsync || (node[childKey] && node[childKey].length > 0)));
+		},
+		clone: function (obj){
+			if (obj === null) return null;
+			var o = obj.constructor === Array ? [] : {};
+			for(var i in obj){
+				o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]);
+			}
+			return o;
+		},
+		eqs: function(str1, str2) {
+			return str1.toLowerCase() === str2.toLowerCase();
+		},
+		isArray: function(arr) {
+			return Object.prototype.toString.apply(arr) === "[object Array]";
+		},
+		getMDom: function (setting, curDom, targetExpr) {
+			if (!curDom) return null;
+			while (curDom && curDom.id !== setting.treeId) {
+				for (var i=0, l=targetExpr.length; curDom.tagName && i<l; i++) {
+					if (tools.eqs(curDom.tagName, targetExpr[i].tagName) && curDom.getAttribute(targetExpr[i].attrName) !== null) {
+						return curDom;
+					}
+				}
+				curDom = curDom.parentNode;
+			}
+			return null;
+		},
+		uCanDo: function(setting, e) {
+			return true;
+		}
+	},
+	//method of operate ztree dom
+	view = {
+		addNodes: function(setting, parentNode, newNodes, isSilent) {
+			if (setting.data.keep.leaf && parentNode && !parentNode.isParent) {
+				return;
+			}
+			if (!tools.isArray(newNodes)) {
+				newNodes = [newNodes];
+			}
+			if (setting.data.simpleData.enable) {
+				newNodes = data.transformTozTreeFormat(setting, newNodes);
+			}
+			if (parentNode) {
+				var target_switchObj = $("#" + parentNode.tId + consts.id.SWITCH),
+				target_icoObj = $("#" + parentNode.tId + consts.id.ICON),
+				target_ulObj = $("#" + parentNode.tId + consts.id.UL);
+
+				if (!parentNode.open) {
+					view.replaceSwitchClass(parentNode, target_switchObj, consts.folder.CLOSE);
+					view.replaceIcoClass(parentNode, target_icoObj, consts.folder.CLOSE);
+					parentNode.open = false;
+					target_ulObj.css({
+						"display": "none"
+					});
+				}
+
+				data.addNodesData(setting, parentNode, newNodes);
+				view.createNodes(setting, parentNode.level + 1, newNodes, parentNode);
+				if (!isSilent) {
+					view.expandCollapseParentNode(setting, parentNode, true);
+				}
+			} else {
+				data.addNodesData(setting, data.getRoot(setting), newNodes);
+				view.createNodes(setting, 0, newNodes, null);
+			}
+		},
+		appendNodes: function(setting, level, nodes, parentNode, initFlag, openFlag) {
+			if (!nodes) return [];
+			var html = [],
+			childKey = setting.data.key.children;
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				var node = nodes[i];
+				if (initFlag) {
+					var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
+					tmpPChild = tmpPNode[childKey],
+					isFirstNode = ((tmpPChild.length == nodes.length) && (i == 0)),
+					isLastNode = (i == (nodes.length - 1));
+					data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag);
+					data.addNodeCache(setting, node);
+				}
+
+				var childHtml = [];
+				if (node[childKey] && node[childKey].length > 0) {
+					//make child html first, because checkType
+					childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open);
+				}
+				if (openFlag) {
+					
+					view.makeDOMNodeMainBefore(html, setting, node);
+					view.makeDOMNodeLine(html, setting, node);
+					data.getBeforeA(setting, node, html);
+					view.makeDOMNodeNameBefore(html, setting, node);
+					data.getInnerBeforeA(setting, node, html);
+					view.makeDOMNodeIcon(html, setting, node);
+					data.getInnerAfterA(setting, node, html);
+					view.makeDOMNodeNameAfter(html, setting, node);
+					data.getAfterA(setting, node, html);
+					if (node.isParent && node.open) {
+						view.makeUlHtml(setting, node, html, childHtml.join(''));
+					}
+					view.makeDOMNodeMainAfter(html, setting, node);
+					data.addCreatedNode(setting, node);
+				}
+			}
+			return html;
+		},
+		appendParentULDom: function(setting, node) {
+			var html = [],
+			nObj = $("#" + node.tId),
+			ulObj = $("#" + node.tId + consts.id.UL),
+			childKey = setting.data.key.children,
+			childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true);
+			view.makeUlHtml(setting, node, html, childHtml.join(''));
+			if (!nObj.get(0) && !!node.parentTId) {
+				view.appendParentULDom(setting, node.getParentNode());
+				nObj = $("#" + node.tId);
+			}
+			if (ulObj.get(0)) {
+				ulObj.remove();
+			}
+			nObj.append(html.join(''));
+		},
+		asyncNode: function(setting, node, isSilent, callback) {
+			var i, l;
+			if (node && !node.isParent) {
+				tools.apply(callback);
+				return false;
+			} else if (node && node.isAjaxing) {
+				return false;
+			} else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) {
+				tools.apply(callback);
+				return false;
+			}
+			if (node) {
+				node.isAjaxing = true;
+				var icoObj = $("#" + node.tId + consts.id.ICON);
+				icoObj.attr({"style":"", "class":"bttn ico_loading"});
+			}
+
+			var tmpParam = {};
+			for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) {
+				var pKey = setting.async.autoParam[i].split("="), spKey = pKey;
+				if (pKey.length>1) {
+					spKey = pKey[1];
+					pKey = pKey[0];
+				}
+				tmpParam[spKey] = node[pKey];
+			}
+			if (tools.isArray(setting.async.otherParam)) {
+				for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) {
+					tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1];
+				}
+			} else {
+				for (var p in setting.async.otherParam) {
+					tmpParam[p] = setting.async.otherParam[p];
+				}
+			}
+
+			var _tmpV = data.getRoot(setting)._ver;
+			$.ajax({
+				contentType: setting.async.contentType,
+				type: setting.async.type,
+				url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url),
+				data: tmpParam,
+				dataType: setting.async.dataType,
+				success: function(msg) {
+					if (_tmpV != data.getRoot(setting)._ver) {
+						return;
+					}
+					var newNodes = [];
+					try {
+						if (!msg || msg.length == 0) {
+							newNodes = [];
+						} else if (typeof msg == "string") {
+							newNodes = eval("(" + msg + ")");
+						} else {
+							newNodes = msg;
+						}
+					} catch(err) {
+						newNodes = msg;
+					}
+
+					if (node) {
+						node.isAjaxing = null;
+						node.zAsync = true;
+					}
+					view.setNodeLineIcos(setting, node);
+					if (newNodes && newNodes !== "") {
+						newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes);
+						view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
+					} else {
+						view.addNodes(setting, node, [], !!isSilent);
+					}
+					setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]);
+					tools.apply(callback);
+				},
+				error: function(XMLHttpRequest, textStatus, errorThrown) {
+					if (_tmpV != data.getRoot(setting)._ver) {
+						return;
+					}
+					if (node) node.isAjaxing = null;
+					view.setNodeLineIcos(setting, node);
+					setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]);
+				}
+			});
+			return true;
+		},
+		cancelPreSelectedNode: function (setting, node) {
+			var list = data.getRoot(setting).curSelectedList;
+			for (var i=0, j=list.length-1; j>=i; j--) {
+				if (!node || node === list[j]) {
+					$("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED);
+					if (node) {
+						data.removeSelectedNode(setting, node);
+						break;
+					}
+				}
+			}
+			if (!node) data.getRoot(setting).curSelectedList = [];
+		},
+		createNodeCallback: function(setting) {
+			if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
+				var root = data.getRoot(setting);
+				while (root.createdNodes.length>0) {
+					var node = root.createdNodes.shift();
+					tools.apply(setting.view.addDiyDom, [setting.treeId, node]);
+					if (!!setting.callback.onNodeCreated) {
+						setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]);
+					}
+				}
+			}
+		},
+		createNodes: function(setting, level, nodes, parentNode) {
+			if (!nodes || nodes.length == 0) return;
+			var root = data.getRoot(setting),
+			childKey = setting.data.key.children,
+			openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0);
+			root.createdNodes = [];
+			var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag);
+			if (!parentNode) {
+				setting.treeObj.append(zTreeHtml.join(''));
+			} else {
+				var ulObj = $("#" + parentNode.tId + consts.id.UL);
+				if (ulObj.get(0)) {
+					ulObj.append(zTreeHtml.join(''));
+				}
+			}
+			view.createNodeCallback(setting);
+		},
+		destroy: function(setting) {
+			if (!setting) return;
+			data.initCache(setting);
+			data.initRoot(setting);
+			event.unbindTree(setting);
+			event.unbindEvent(setting);
+			setting.treeObj.empty();
+		},
+		expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) {
+			var root = data.getRoot(setting),
+			childKey = setting.data.key.children;
+			if (!node) {
+				tools.apply(callback, []);
+				return;
+			}
+			if (root.expandTriggerFlag) {
+				var _callback = callback;
+				callback = function(){
+					if (_callback) _callback();
+					if (node.open) {
+						setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]);
+					} else {
+						setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]);
+					}
+				};
+				root.expandTriggerFlag = false;
+			}
+			if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) {
+				view.appendParentULDom(setting, node);
+				view.createNodeCallback(setting);
+			}
+			if (node.open == expandFlag) {
+				tools.apply(callback, []);
+				return;
+			}
+			var ulObj = $("#" + node.tId + consts.id.UL),
+			switchObj = $("#" + node.tId + consts.id.SWITCH),
+			icoObj = $("#" + node.tId + consts.id.ICON);
+
+			if (node.isParent) {
+				node.open = !node.open;
+				if (node.iconOpen && node.iconClose) {
+					icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
+				}
+
+				if (node.open) {
+					view.replaceSwitchClass(node, switchObj, consts.folder.OPEN);
+					view.replaceIcoClass(node, icoObj, consts.folder.OPEN);
+					if (animateFlag == false || setting.view.expandSpeed == "") {
+						ulObj.show();
+						tools.apply(callback, []);
+					} else {
+						if (node[childKey] && node[childKey].length > 0) {
+							ulObj.slideDown(setting.view.expandSpeed, callback);
+						} else {
+							ulObj.show();
+							tools.apply(callback, []);
+						}
+					}
+				} else {
+					view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE);
+					view.replaceIcoClass(node, icoObj, consts.folder.CLOSE);
+					if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) {
+						ulObj.hide();
+						tools.apply(callback, []);
+					} else {
+						ulObj.slideUp(setting.view.expandSpeed, callback);
+					}
+				}
+			} else {
+				tools.apply(callback, []);
+			}
+		},
+		expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) {
+			if (!node) return;
+			if (!node.parentTId) {
+				view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback);
+				return;
+			} else {
+				view.expandCollapseNode(setting, node, expandFlag, animateFlag);
+			}
+			if (node.parentTId) {
+				view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback);
+			}
+		},
+		expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) {
+			var root = data.getRoot(setting),
+			childKey = setting.data.key.children,
+			treeNodes = (node) ? node[childKey]: root[childKey],
+			selfAnimateSign = (node) ? false : animateFlag,
+			expandTriggerFlag = data.getRoot(setting).expandTriggerFlag;
+			data.getRoot(setting).expandTriggerFlag = false;
+			if (treeNodes) {
+				for (var i = 0, l = treeNodes.length; i < l; i++) {
+					if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign);
+				}
+			}
+			data.getRoot(setting).expandTriggerFlag = expandTriggerFlag;
+			view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback );
+		},
+		makeDOMNodeIcon: function(html, setting, node) {
+			var nameStr = data.getNodeName(setting, node),
+			name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
+			html.push("<span id='", node.tId, consts.id.ICON,
+				"' title='' treeNode", consts.id.ICON," class='", view.makeNodeIcoClass(setting, node),
+				"' style='", view.makeNodeIcoStyle(setting, node), "'></span><span id='", node.tId, consts.id.SPAN,
+				"'>",name,"</span>");
+		},
+		makeDOMNodeLine: function(html, setting, node) {
+			html.push("<span id='", node.tId, consts.id.SWITCH,	"' title='' class='", view.makeNodeLineClass(setting, node), "' treeNode", consts.id.SWITCH,"></span>");
+		},
+		makeDOMNodeMainAfter: function(html, setting, node) {
+			if(node.isPartition){
+				html.push("<span class='iconRegionPartition'></span><br class='clrBoth' />");
+				html.push("</li>");
+			}else{
+				html.push("<span class='iconRegionReplicate'></span><br class='clrBoth' />");
+				html.push("</li>");
+			}
+		},
+		makeDOMNodeMainBefore: function(html, setting, node) {
+			html.push("<li id='", node.tId, "' class='level", node.level,"' tabindex='0' hidefocus='true' treenode>");
+		},
+		makeDOMNodeNameAfter: function(html, setting, node) {
+			html.push("</a>");
+		},
+		makeDOMNodeNameBefore: function(html, setting, node) {
+			var title = data.getNodeTitle(setting, node),
+			url = view.makeNodeUrl(setting, node),
+			fontcss = view.makeNodeFontCss(setting, node),
+			fontStyle = [];
+			for (var f in fontcss) {
+				fontStyle.push(f, ":", fontcss[f], ";");
+			}
+			html.push("<a id='", node.tId, consts.id.A, "' class='level", node.level,"' treeNode", consts.id.A," onclick=\"", (node.click || ''),
+				"\" ", ((url != null && url.length > 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''),
+				"'");
+			if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"&#39;").replace(/</g,'&lt;').replace(/>/g,'&gt;'),"'");}
+			html.push(">");
+		},
+		makeNodeFontCss: function(setting, node) {
+			var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss);
+			return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {};
+		},
+		makeNodeIcoClass: function(setting, node) {
+			var icoCss = ["ico"];
+			if (!node.isAjaxing) {
+				icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0];
+				if (node.isParent) {
+					icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
+				} else {
+					icoCss.push(consts.folder.DOCU);
+				}
+			}
+			return "bttn " + icoCss.join('_');
+		},
+		makeNodeIcoStyle: function(setting, node) {
+			var icoStyle = [];
+			if (!node.isAjaxing) {
+				var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon;
+				if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;");
+				if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) {
+					icoStyle.push("width:0px;height:0px;");
+				}
+			}
+			return icoStyle.join('');
+		},
+		makeNodeLineClass: function(setting, node) {
+			var lineClass = [];
+			if (setting.view.showLine) {
+				if (node.level == 0 && node.isFirstNode && node.isLastNode) {
+					lineClass.push(consts.line.ROOT);
+				} else if (node.level == 0 && node.isFirstNode) {
+					lineClass.push(consts.line.ROOTS);
+				} else if (node.isLastNode) {
+					lineClass.push(consts.line.BOTTOM);
+				} else {
+					lineClass.push(consts.line.CENTER);
+				}
+			} else {
+				lineClass.push(consts.line.NOLINE);
+			}
+			if (node.isParent) {
+				lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
+			} else {
+				lineClass.push(consts.folder.DOCU);
+			}
+			return view.makeNodeLineClassEx(node) + lineClass.join('_');
+		},
+		makeNodeLineClassEx: function(node) {
+			return "bttn level" + node.level + " switch ";
+		},
+		makeNodeTarget: function(node) {
+			return (node.target || "_blank");
+		},
+		makeNodeUrl: function(setting, node) {
+			var urlKey = setting.data.key.url;
+			return node[urlKey] ? node[urlKey] : null;
+		},
+		makeUlHtml: function(setting, node, html, content) {
+			html.push("<ul id='", node.tId, consts.id.UL, "' class='level", node.level, " ", view.makeUlLineClass(setting, node), "' style='display:", (node.open ? "block": "none"),"'>");
+			html.push(content);
+			html.push("</ul>");
+		},
+		makeUlLineClass: function(setting, node) {
+			return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : "");
+		},
+		removeChildNodes: function(setting, node) {
+			if (!node) return;
+			var childKey = setting.data.key.children,
+			nodes = node[childKey];
+			if (!nodes) return;
+
+			for (var i = 0, l = nodes.length; i < l; i++) {
+				data.removeNodeCache(setting, nodes[i]);
+			}
+			data.removeSelectedNode(setting);
+			delete node[childKey];
+
+			if (!setting.data.keep.parent) {
+				node.isParent = false;
+				node.open = false;
+				var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH),
+				tmp_icoObj = $("#" + node.tId + consts.id.ICON);
+				view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU);
+				view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU);
+				$("#" + node.tId + consts.id.UL).remove();
+			} else {
+				$("#" + node.tId + consts.id.UL).empty();
+			}
+		},
+		setFirstNode: function(setting, parentNode) {
+			var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
+			if ( childLength > 0) {
+				parentNode[childKey][0].isFirstNode = true;
+			}
+		},
+		setLastNode: function(setting, parentNode) {
+			var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
+			if ( childLength > 0) {
+				parentNode[childKey][childLength - 1].isLastNode = true;
+			}
+		},
+		removeNode: function(setting, node) {
+			var root = data.getRoot(setting),
+			childKey = setting.data.key.children,
+			parentNode = (node.parentTId) ? node.getParentNode() : root;
+
+			node.isFirstNode = false;
+			node.isLastNode = false;
+			node.getPreNode = function() {return null;};
+			node.getNextNode = function() {return null;};
+
+			if (!data.getNodeCache(setting, node.tId)) {
+				return;
+			}
+                        
+			$("#" + node.tId).remove();
+			data.removeNodeCache(setting, node);
+			data.removeSelectedNode(setting, node);
+
+			for (var i = 0, l = parentNode[childKey].length; i < l; i++) {
+				if (parentNode[childKey][i].tId == node.tId) {
+					parentNode[childKey].splice(i, 1);
+					break;
+				}
+			}
+			view.setFirstNode(setting, parentNode);
+			view.setLastNode(setting, parentNode);
+                                                
+			var tmp_ulObj,tmp_switchObj,tmp_icoObj,
+			childLength = parentNode[childKey].length;
+
+			//repair nodes old parent
+			if (!setting.data.keep.parent && childLength == 0) {
+				//old parentNode has no child nodes
+				parentNode.isParent = false;
+				parentNode.open = false;
+				tmp_ulObj = $("#" + parentNode.tId + consts.id.UL);
+				tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH);
+				tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON);
+				view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU);
+				view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU);
+				tmp_ulObj.css("display", "none");
+
+			} else if (setting.view.showLine && childLength > 0) {
+				//old parentNode has child nodes
+				var newLast = parentNode[childKey][childLength - 1];
+				tmp_ulObj = $("#" + newLast.tId + consts.id.UL);
+				tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH);
+				tmp_icoObj = $("#" + newLast.tId + consts.id.ICON);
+				if (parentNode == root) {
+					if (parentNode[childKey].length == 1) {
+						//node was root, and ztree has only one root after move node
+						view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT);
+					} else {
+						var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH);
+						view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS);
+						view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
+					}
+				} else {
+					view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
+				}
+				tmp_ulObj.removeClass(consts.line.LINE);
+			}
+		},
+		replaceIcoClass: function(node, obj, newName) {
+			if (!obj || node.isAjaxing) return;
+			var tmpName = obj.attr("class");
+			if (tmpName == undefined) return;
+			var tmpList = tmpName.split("_");
+			switch (newName) {
+				case consts.folder.OPEN:
+				case consts.folder.CLOSE:
+				case consts.folder.DOCU:
+					tmpList[tmpList.length-1] = newName;
+					break;
+			}
+			obj.attr("class", tmpList.join("_"));
+		},
+		replaceSwitchClass: function(node, obj, newName) {
+			if (!obj) return;
+			var tmpName = obj.attr("class");
+			if (tmpName == undefined) return;
+			var tmpList = tmpName.split("_");
+			switch (newName) {
+				case consts.line.ROOT:
+				case consts.line.ROOTS:
+				case consts.line.CENTER:
+				case consts.line.BOTTOM:
+				case consts.line.NOLINE:
+					tmpList[0] = view.makeNodeLineClassEx(node) + newName;
+					break;
+				case consts.folder.OPEN:
+				case consts.folder.CLOSE:
+				case consts.folder.DOCU:
+					tmpList[1] = newName;
+					break;
+			}
+			obj.attr("class", tmpList.join("_"));
+			if (newName !== consts.folder.DOCU) {
+				obj.removeAttr("disabled");
+			} else {
+				obj.attr("disabled", "disabled");
+			}
+		},
+		selectNode: function(setting, node, addFlag) {
+			if (!addFlag) {
+				view.cancelPreSelectedNode(setting);
+			}
+			$("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED);
+			data.addSelectedNode(setting, node);
+		},
+		setNodeFontCss: function(setting, treeNode) {
+			var aObj = $("#" + treeNode.tId + consts.id.A),
+			fontCss = view.makeNodeFontCss(setting, treeNode);
+			if (fontCss) {
+				aObj.css(fontCss);
+			}
+		},
+		setNodeLineIcos: function(setting, node) {
+			if (!node) return;
+			var switchObj = $("#" + node.tId + consts.id.SWITCH),
+			ulObj = $("#" + node.tId + consts.id.UL),
+			icoObj = $("#" + node.tId + consts.id.ICON),
+			ulLine = view.makeUlLineClass(setting, node);
+			if (ulLine.length==0) {
+				ulObj.removeClass(consts.line.LINE);
+			} else {
+				ulObj.addClass(ulLine);
+			}
+			switchObj.attr("class", view.makeNodeLineClass(setting, node));
+			if (node.isParent) {
+				switchObj.removeAttr("disabled");
+			} else {
+				switchObj.attr("disabled", "disabled");
+			}
+			icoObj.removeAttr("style");
+			icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
+			icoObj.attr("class", view.makeNodeIcoClass(setting, node));
+		},
+		setNodeName: function(setting, node) {
+			var title = data.getNodeTitle(setting, node),
+			nObj = $("#" + node.tId + consts.id.SPAN);
+			nObj.empty();
+			if (setting.view.nameIsHTML) {
+				nObj.html(data.getNodeName(setting, node));
+			} else {
+				nObj.text(data.getNodeName(setting, node));
+			}
+			if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) {
+				var aObj = $("#" + node.tId + consts.id.A);
+				aObj.attr("title", !title ? "" : title);
+			}
+		},
+		setNodeTarget: function(node) {
+			var aObj = $("#" + node.tId + consts.id.A);
+			aObj.attr("target", view.makeNodeTarget(node));
+		},
+		setNodeUrl: function(setting, node) {
+			var aObj = $("#" + node.tId + consts.id.A),
+			url = view.makeNodeUrl(setting, node);
+			if (url == null || url.length == 0) {
+				aObj.removeAttr("href");
+			} else {
+				aObj.attr("href", url);
+			}
+		},
+		switchNode: function(setting, node) {
+			if (node.open || !tools.canAsync(setting, node)) {
+				view.expandCollapseNode(setting, node, !node.open);
+			} else if (setting.async.enable) {
+				if (!view.asyncNode(setting, node)) {
+					view.expandCollapseNode(setting, node, !node.open);
+					return;
+				}
+			} else if (node) {
+				view.expandCollapseNode(setting, node, !node.open);
+			}
+		}
+	};
+	// zTree defind
+	$.fn.zTree = {
+		consts : _consts,
+		_z : {
+			tools: tools,
+			view: view,
+			event: event,
+			data: data
+		},
+		getZTreeObj: function(treeId) {
+			var o = data.getZTreeTools(treeId);
+			return o ? o : null;
+		},
+		destroy: function(treeId) {
+			if (!!treeId && treeId.length > 0) {
+				view.destroy(data.getSetting(treeId));
+			} else {
+				for(var s in settings) {
+					view.destroy(settings[s]);
+				}
+			}
+		},
+		init: function(obj, zSetting, zNodes) {
+			var setting = tools.clone(_setting);
+			$.extend(true, setting, zSetting);
+			setting.treeId = obj.attr("id");
+			setting.treeObj = obj;
+			setting.treeObj.empty();
+			settings[setting.treeId] = setting;
+			//For some older browser,(e.g., ie6)
+			if(typeof document.body.style.maxHeight === "undefined") {
+				setting.view.expandSpeed = "";
+			}
+			data.initRoot(setting);
+			var root = data.getRoot(setting),
+			childKey = setting.data.key.children;
+			zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : [];
+			if (setting.data.simpleData.enable) {
+				root[childKey] = data.transformTozTreeFormat(setting, zNodes);
+			} else {
+				root[childKey] = zNodes;
+			}
+
+			data.initCache(setting);
+			event.unbindTree(setting);
+			event.bindTree(setting);
+			event.unbindEvent(setting);
+			event.bindEvent(setting);
+			
+			var zTreeTools = {
+				setting : setting,
+				addNodes : function(parentNode, newNodes, isSilent) {
+					if (!newNodes) return null;
+					if (!parentNode) parentNode = null;
+					if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null;
+					var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]);
+					function addCallback() {
+						view.addNodes(setting, parentNode, xNewNodes, (isSilent==true));
+					}
+
+					if (tools.canAsync(setting, parentNode)) {
+						view.asyncNode(setting, parentNode, isSilent, addCallback);
+					} else {
+						addCallback();
+					}
+					return xNewNodes;
+				},
+				cancelSelectedNode : function(node) {
+					view.cancelPreSelectedNode(this.setting, node);
+				},
+				destroy : function() {
+					view.destroy(this.setting);
+				},
+				expandAll : function(expandFlag) {
+					expandFlag = !!expandFlag;
+					view.expandCollapseSonNode(this.setting, null, expandFlag, true);
+					return expandFlag;
+				},
+				expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) {
+					if (!node || !node.isParent) return null;
+					if (expandFlag !== true && expandFlag !== false) {
+						expandFlag = !node.open;
+					}
+					callbackFlag = !!callbackFlag;
+
+					if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) {
+						return null;
+					} else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) {
+						return null;
+					}
+					if (expandFlag && node.parentTId) {
+						view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false);
+					}
+					if (expandFlag === node.open && !sonSign) {
+						return null;
+					}
+					
+					data.getRoot(setting).expandTriggerFlag = callbackFlag;
+					if (sonSign) {
+						view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() {
+							if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}}
+						});
+					} else {
+						node.open = !expandFlag;
+						view.switchNode(this.setting, node);
+						if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}}
+					}
+					return expandFlag;
+				},
+				getNodes : function() {
+					return data.getNodes(this.setting);
+				},
+				getNodeByParam : function(key, value, parentNode) {
+					if (!key) return null;
+					return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
+				},
+				getNodeByTId : function(tId) {
+					return data.getNodeCache(this.setting, tId);
+				},
+				getNodesByParam : function(key, value, parentNode) {
+					if (!key) return null;
+					return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
+				},
+				getNodesByParamFuzzy : function(key, value, parentNode) {
+					if (!key) return null;
+					return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
+				},
+				getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) {
+					isSingle = !!isSingle;
+					if (!filter || (typeof filter != "function")) return (isSingle ? null : []);
+					return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam);
+				},
+				getNodeIndex : function(node) {
+					if (!node) return null;
+					var childKey = setting.data.key.children,
+					parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting);
+					for (var i=0, l = parentNode[childKey].length; i < l; i++) {
+						if (parentNode[childKey][i] == node) return i;
+					}
+					return -1;
+				},
+				getSelectedNodes : function() {
+					var r = [], list = data.getRoot(this.setting).curSelectedList;
+					for (var i=0, l=list.length; i<l; i++) {
+						r.push(list[i]);
+					}
+					return r;
+				},
+				isSelectedNode : function(node) {
+					return data.isSelectedNode(this.setting, node);
+				},
+				reAsyncChildNodes : function(parentNode, reloadType, isSilent) {
+					if (!this.setting.async.enable) return;
+					var isRoot = !parentNode;
+					if (isRoot) {
+						parentNode = data.getRoot(this.setting);
+					}
+					if (reloadType=="refresh") {
+						var childKey = this.setting.data.key.children;
+						for (var i = 0, l = parentNode[childKey] ? parentNode[childKey].length : 0; i < l; i++) {
+							data.removeNodeCache(setting, parentNode[childKey][i]);
+						}
+						data.removeSelectedNode(setting);
+						parentNode[childKey] = [];
+						if (isRoot) {
+							this.setting.treeObj.empty();
+						} else {
+							var ulObj = $("#" + parentNode.tId + consts.id.UL);
+							ulObj.empty();
+						}
+					}
+					view.asyncNode(this.setting, isRoot? null:parentNode, !!isSilent);
+				},
+				refresh : function() {
+					this.setting.treeObj.empty();
+					var root = data.getRoot(this.setting),
+					nodes = root[this.setting.data.key.children]
+					data.initRoot(this.setting);
+					root[this.setting.data.key.children] = nodes
+					data.initCache(this.setting);
+					view.createNodes(this.setting, 0, root[this.setting.data.key.children]);
+				},
+				removeChildNodes : function(node) {
+					if (!node) return null;
+					var childKey = setting.data.key.children,
+					nodes = node[childKey];
+					view.removeChildNodes(setting, node);
+					return nodes ? nodes : null;
+				},
+				removeNode : function(node, callbackFlag) {
+					if (!node) return;
+					callbackFlag = !!callbackFlag;
+					if (callbackFlag && tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return;
+					view.removeNode(setting, node);
+					if (callbackFlag) {
+						this.setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]);
+					}
+				},
+				selectNode : function(node, addFlag) {
+					if (!node) return;
+					if (tools.uCanDo(this.setting)) {
+						addFlag = setting.view.selectedMulti && addFlag;
+						if (node.parentTId) {
+							view.expandCollapseParentNode(this.setting, node.getParentNode(), true, false, function() {
+								try{$("#" + node.tId).focus().blur();}catch(e){}
+							});
+						} else {
+							try{$("#" + node.tId).focus().blur();}catch(e){}
+						}
+						view.selectNode(this.setting, node, addFlag);
+					}
+				},
+				transformTozTreeNodes : function(simpleNodes) {
+					return data.transformTozTreeFormat(this.setting, simpleNodes);
+				},
+				transformToArray : function(nodes) {
+					return data.transformToArrayFormat(this.setting, nodes);
+				},
+				updateNode : function(node, checkTypeFlag) {
+					if (!node) return;
+					var nObj = $("#" + node.tId);
+					if (nObj.get(0) && tools.uCanDo(this.setting)) {
+						view.setNodeName(this.setting, node);
+						view.setNodeTarget(node);
+						view.setNodeUrl(this.setting, node);
+						view.setNodeLineIcos(this.setting, node);
+						view.setNodeFontCss(this.setting, node);
+					}
+				}
+			}
+			root.treeTools = zTreeTools;
+			data.setZTreeTools(setting, zTreeTools);
+
+			if (root[childKey] && root[childKey].length > 0) {
+				view.createNodes(setting, 0, root[childKey]);
+			} else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
+				view.asyncNode(setting);
+			}
+			return zTreeTools;
+		}
+	};
+
+	var zt = $.fn.zTree,
+	consts = zt.consts;
+})(jQuery);
\ No newline at end of file


Mime
View raw message