Commits

Ralph Bean committed 25223a3

Initial commit

Comments (0)

Files changed (27)

+# use glob syntax.
+syntax: glob
+
+*.egg-info
+.coverage
+*.pyc
+*~
+*.swp
+*.rej
+tags
+dist
+build
+.hg*
+tw2core
+tw2devtools
+tw2forms
+tw2jquery
+tw2.jquery.plugins.ui
+virtualenv-*
+*.egg
+recursive-include tw2/jqplugins/dynatree/static *
+recursive-include tw2/jqplugins/dynatree/templates *
+include README.rst
+tw2.jqplugins.dynatree
+=========================
+
+:Author: Ralph Bean <ralph.bean@gmail.com>
+
+.. comment: split here
+
+.. _toscawidgets2 (tw2): http://toscawidgets.org/documentation/tw2.core/
+.. _dynatree: http://code.google.com/p/dynatree/
+
+tw2.jqplugins.dynatree is a `toscawidgets2 (tw2)`_ wrapper for `dynatree`_.
+
+Live Demo
+---------
+Peep the `live demonstration <http://craftsman.rc.rit.edu/module?module=tw2.jqplugins.dynatree>`_.
+
+Links
+-----
+Get the `source from github <http://github.com/ralphbean/tw2.jqplugins.dynatree>`_.
+
+`PyPI page <http://pypi.python.org/pypi/tw2.jqplugins.dynatree>`_
+and `bugs <http://github.com/ralphbean/tw2.jqplugins.dynatree/issues/>`_
+
+Description
+-----------
+
+`toscawidgets2 (tw2)`_ aims to be a practical and useful widgets framework
+that helps people build interactive websites with compelling features, faster
+and easier. Widgets are re-usable web components that can include a template,
+server-side code and JavaScripts/CSS resources. The library aims to be:
+flexible, reliable, documented, performant, and as simple as possible.
+
+`dynatree`_ is a jQuery plugin that allows to dynamically create html
+tree view controls using JavaScript. 
+
+This module, tw2.jqplugins.dynatree, provides `toscawidgets2 (tw2)`_ access
+to `dynatree`_ widgets.

development-deps/develop-tw2-destroy-and-setup.sh

+#!/bin/bash -e
+
+devbase=development-deps
+venv=$devbase/virtualenv-tw2.jquery
+$(
+    rm -rf $venv
+) || echo "Did not destroy $venv"
+
+virtualenv $venv --no-site-packages
+
+source $venv/bin/activate
+
+pushd $devbase
+
+pip install genshi
+pip install mako
+pip install formencode
+
+hg clone http://bitbucket.org/paj/tw2core || \
+        (pushd tw2core && hg pull && popd)
+hg clone http://bitbucket.org/paj/tw2devtools || \
+        (pushd tw2devtools && hg pull && popd)
+hg clone http://bitbucket.org/paj/tw2forms || \
+        (pushd tw2forms && hg pull && popd)
+hg clone http://bitbucket.org/toscawidgets/tw2jquery || \
+        (pushd tw2jquery && hg pull && popd)
+echo "ONE TWO"
+git clone http://github.com/ralphbean/tw2.jqplugins.ui.git || \
+        (pushd tw2.jqplugins.ui && git pull && popd)
+echo "THREE FOUR"
+
+pushd tw2core ;  python setup.py install ; popd
+pushd tw2forms ; python setup.py install ; popd
+pushd tw2devtools ; python setup.py install ; popd
+pushd tw2jquery ; python setup.py install_lib install_egg_info ; popd
+pushd tw2.jqplugins.ui ; python setup.py install_lib install_egg_info ; popd
+
+popd # $devbase

development-deps/develop-tw2-start.sh

+#!/bin/bash
+
+devbase=development-deps
+venv=$devbase/virtualenv-tw2.jquery
+source $venv/bin/activate
+
+python setup.py install_lib install_egg_info && paster tw2.browser
+
+
+
+[egg_info]
+
+[nosetests]
+where = tests
+from setuptools import setup, find_packages
+
+f = open('README.rst')
+long_description = f.read().strip()
+long_description = long_description.split('split here', 1)[1]
+f.close()
+
+# Requirements to install buffet plugins and engines
+_extra_genshi = ["Genshi >= 0.3.5"]
+_extra_mako = ["Mako >= 0.1.1"]
+
+setup(
+    name='tw2.jqplugins.dynatree',
+    version='2.0a0',
+    description='toscawidgets2 wrapper for the dynatree jQuery plugin',
+    long_description=long_description,
+    author='Ralph Bean',
+    author_email='ralph.bean@gmail.com',
+    license='MIT',
+    url='http://github.com/ralphbean/tw2.jqplugins.dynatree',
+    install_requires=[
+        "tw2.core>=2.0b2",
+        "tw2.jqplugins.ui",
+        ],
+    extras_require = {
+        'genshi': _extra_genshi,
+        'mako': _extra_mako,
+    },
+    tests_require = ['BeautifulSoup', 'nose', 'FormEncode', 'WebTest',] + _extra_genshi + _extra_mako,
+    packages=find_packages(exclude=['ez_setup', 'tests']),
+    namespace_packages = ['tw2'],
+    zip_safe=False,
+    include_package_data=True,
+    test_suite = 'nose.collector',
+    entry_points="""
+        [tw2.widgets]
+        # Register your widgets so they can be listed in the WidgetBrowser
+        widgets = tw2.jqplugins.dynatree
+    """,
+    keywords = [
+        'toscawidgets.widgets',
+    ],
+    classifiers = [
+        'Development Status :: 3 - Alpha',
+        'Environment :: Web Environment',
+        'Environment :: Web Environment :: ToscaWidgets',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Topic :: Software Development :: Widget Sets',
+        'Intended Audience :: Developers',
+        'Operating System :: OS Independent',
+        'Programming Language :: Python',
+    ],
+)
+__import__('pkg_resources').declare_namespace(__name__)

tw2/jqplugins/__init__.py

+__import__('pkg_resources').declare_namespace(__name__)

tw2/jqplugins/dynatree/__init__.py

+""" TW2 widget wrapper the jquery ui dynatree
+
+Get the source from http://github.com/ralphbean/tw2.jqplugins.dynatree
+"""
+
+from widgets import *

tw2/jqplugins/dynatree/base.py

+
+import tw2.core as twc
+import tw2.jquery.base as twjq_c
+import defaults
+
+dynatree_css = twjq_c.jQueryPluginCSSLink(
+    name=defaults._dynatree_name_,
+    version = defaults._dynatree_version_,
+    modname = 'tw2.jqplugins.dynatree',
+    subdir = 'skin-vista',
+)
+dynatree_js = twjq_c.jQueryPluginJSLink(
+    name=defaults._dynatree_name_,
+    version=defaults._dynatree_version_,
+    variant='min',
+    modname='tw2.jqplugins.dynatree',
+    subdir = '',
+)
+dynatree_utils_js = twc.JSLink(
+    modname='tw2.jqplugins.dynatree',
+    filename='static/js/dynatree-utils.js',
+)
+
+__all__ = ['dynatree_js', 'dynatree_css', 'dynatree_utils_js']

tw2/jqplugins/dynatree/defaults.py

+_dynatree_version_    = '1.1.1'
+_dynatree_name_       = 'dynatree'

tw2/jqplugins/dynatree/samples.py

+"""
+Here you can create samples of your widgets by providing default parameters,
+inserting them in a container widget, mixing them with other widgets, etc...
+These samples will appear in the WidgetBrowser
+
+See http://toscawidgets.org/documentation/WidgetBrowser for more information
+"""
+
+import tw2.core as twc
+from tw2.core.resources import encoder
+
+from widgets import DynaTreeWidget
+
+class DemoDynaTree(DynaTreeWidget):
+    options = {
+        'onActivate': twc.JSSymbol(
+            src="""function(node) {
+            alert("You activated " + node.data.title);
+        }"""),
+        'children': [
+            {'title': "Item 1"},
+            {'title': "Folder 2",
+             'isFolder': True,
+             'key': "folder2",
+             'children': [
+                 {'title': "Sub-item 2.1"},
+                 {'title': "Sub-item 2.2"}
+             ]
+            },
+            {'title': "Item 3"}
+        ]
+    }

tw2/jqplugins/dynatree/static/jquery/plugins/dynatree/1.1.1/GPL-LICENSE.txt

+        GNU GENERAL PUBLIC LICENSE
+           Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+        GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+          NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.

tw2/jqplugins/dynatree/static/jquery/plugins/dynatree/1.1.1/MIT-License.txt

+Copyright (c) 2008-2011  Martin Wendt (http://wwWendt.de)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tw2/jqplugins/dynatree/static/jquery/plugins/dynatree/1.1.1/jquery.dynatree.js

+/*************************************************************************
+	jquery.dynatree.js
+	Dynamic tree view control, with support for lazy loading of branches.
+
+	Copyright (c) 2008-2011, Martin Wendt (http://wwWendt.de)
+	Dual licensed under the MIT or GPL Version 2 licenses.
+	http://code.google.com/p/dynatree/wiki/LicenseInfo
+
+	A current version and some documentation is available at
+		http://dynatree.googlecode.com/
+
+	$Version: 1.1.1$
+	$Revision: 481, 2011-03-02 07:25:35$
+
+	@depends: jquery.js
+	@depends: jquery.ui.core.js
+	@depends: jquery.cookie.js
+*************************************************************************/
+
+// Note: We currently allow eval() to parse the 'data' attribtes, when initializing from HTML.
+/*jslint laxbreak: true, browser: true, evil: true, indent: 0, white: false, onevar: false */
+
+/*************************************************************************
+ *	Debug functions
+ */
+
+var _canLog = true;
+
+function _log(mode, msg) {
+	/**
+	 * Usage: logMsg("%o was toggled", this);
+	 */
+	if( !_canLog ){
+		return;
+	}
+	// Remove first argument
+	var args = Array.prototype.slice.apply(arguments, [1]);
+	// Prepend timestamp
+	var dt = new Date();
+	var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
+	args[0] = tag + " - " + args[0];
+
+	try {
+		switch( mode ) {
+		case "info":
+			window.console.info.apply(window.console, args);
+			break;
+		case "warn":
+			window.console.warn.apply(window.console, args);
+			break;
+		default:
+			window.console.log.apply(window.console, args);
+			break;
+		}
+	} catch(e) {
+		if( !window.console ){
+			_canLog = false; // Permanently disable, when logging is not supported by the browser
+		}
+	}
+}
+
+function logMsg(msg) {
+	Array.prototype.unshift.apply(arguments, ["debug"]);
+	_log.apply(this, arguments);
+}
+
+
+// Forward declaration
+var getDynaTreePersistData = null;
+
+
+
+/*************************************************************************
+ *	Constants
+ */
+var DTNodeStatus_Error   = -1;
+var DTNodeStatus_Loading = 1;
+var DTNodeStatus_Ok      = 0;
+
+
+// Start of local namespace
+(function($) {
+
+/*************************************************************************
+ *	Common tool functions.
+ */
+
+var Class = {
+	create: function() {
+		return function() {
+			this.initialize.apply(this, arguments);
+		};
+	}
+};
+
+// Tool function to get dtnode from the event target:
+function getDtNodeFromElement(el) {
+	var iMax = 5;
+	while( el && iMax-- ) {
+		if(el.dtnode) { return el.dtnode; }
+		el = el.parentNode;
+	}
+	return null;
+}
+
+function noop() {
+}
+
+/*************************************************************************
+ *	Class DynaTreeNode
+ */
+var DynaTreeNode = Class.create();
+
+DynaTreeNode.prototype = {
+	initialize: function(parent, tree, data) {
+		/**
+		 * @constructor
+		 */
+		this.parent = parent;
+		this.tree = tree;
+		if ( typeof data === "string" ){
+			data = { title: data };
+		}
+		if( data.key === undefined ){
+			data.key = "_" + tree._nodeCount++;
+		}
+		this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
+		this.li = null; // not yet created
+		this.span = null; // not yet created
+		this.ul = null; // not yet created
+		this.childList = null; // no subnodes yet
+		this.isLoading = false; // Lazy content is being loaded
+		this.hasSubSel = false;
+		this.bExpanded = false;
+		this.bSelected = false;
+
+	},
+
+	toString: function() {
+		return "DynaTreeNode<" + this.data.key + ">: '" + this.data.title + "'";
+	},
+
+	toDict: function(recursive, callback) {
+		var dict = $.extend({}, this.data);
+		dict.activate = ( this.tree.activeNode === this );
+		dict.focus = ( this.tree.focusNode === this );
+		dict.expand = this.bExpanded;
+		dict.select = this.bSelected;
+		if( callback ){
+			callback(dict);
+		}
+		if( recursive && this.childList ) {
+			dict.children = [];
+			for(var i=0, l=this.childList.length; i<l; i++ ){
+				dict.children.push(this.childList[i].toDict(true, callback));
+			}
+		} else {
+			delete dict.children;
+		}
+		return dict;
+	},
+
+	fromDict: function(dict) {
+		/**
+		 * Update node data. If dict contains 'children', then also replace
+		 * the hole sub tree.
+		 */
+		var children = dict.children;
+		if(children === undefined){
+			this.data = $.extend(this.data, dict);
+			this.render();
+			return;
+		}
+		dict = $.extend({}, dict);
+		dict.children = undefined;
+		this.data = $.extend(this.data, dict);
+		this.removeChildren();
+		this.addChild(children);
+	},
+
+	_getInnerHtml: function() {
+		var tree = this.tree,
+			opts = tree.options,
+			cache = tree.cache,
+			level = this.getLevel(),
+			data = this.data,
+			res = "";
+		// connector (expanded, expandable or simple)
+		if( level < opts.minExpandLevel ) {
+			if(level > 1){
+				res += cache.tagConnector;
+			}
+			// .. else (i.e. for root level) skip expander/connector altogether
+		} else if( this.hasChildren() !== false ) {
+			res += cache.tagExpander;
+		} else {
+			res += cache.tagConnector;
+		}
+		// Checkbox mode
+		if( opts.checkbox && data.hideCheckbox !== true && !data.isStatusNode ) {
+			res += cache.tagCheckbox;
+		}
+		// folder or doctype icon
+		if ( data.icon ) {
+			res += "<img src='" + opts.imagePath + data.icon + "' alt='' />";
+		} else if ( data.icon === false ) {
+			// icon == false means 'no icon'
+			noop(); // keep JSLint happy
+		} else {
+			// icon == null means 'default icon'
+			res += cache.tagNodeIcon;
+		}
+		// node title
+		var nodeTitle = "";
+		if ( opts.onCustomRender ){
+			nodeTitle = opts.onCustomRender.call(tree, this) || "";
+		}
+		if(!nodeTitle){
+			var tooltip = data.tooltip ? " title='" + data.tooltip + "'" : "";
+			if( opts.noLink || data.noLink ) {
+				nodeTitle = "<span style='display: inline-block;' class='" + opts.classNames.title + "'" + tooltip + ">" + data.title + "</span>";
+			}else{
+				nodeTitle = "<a href='#' class='" + opts.classNames.title + "'" + tooltip + ">" + data.title + "</a>";
+			}
+		}
+		res += nodeTitle;
+		return res;
+	},
+
+
+	_fixOrder: function() {
+		/**
+		 * Make sure, that <li> order matches childList order.
+		 */
+		var cl = this.childList;
+		if( !cl || !this.ul ){
+			return;
+		}
+		var childLI = this.ul.firstChild;
+		for(var i=0, l=cl.length-1; i<l; i++) {
+			var childNode1 = cl[i];
+			var childNode2 = childLI.dtnode;
+			if( childNode1 !== childNode2 ) {
+				this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
+				this.ul.insertBefore(childNode1.li, childNode2.li);
+			} else {
+				childLI = childLI.nextSibling;
+			}
+		}
+	},
+
+
+	render: function(useEffects, includeInvisible) {
+		/**
+		 * Create <li><span>..</span> .. </li> tags for this node.
+		 *
+		 * <li id='KEY' dtnode=NODE> // This div contains the node's span and list of child div's.
+		 *   <span class='title'>S S S A</span> // Span contains graphic spans and title <a> tag
+		 *   <ul> // only present, when node has children
+		 *       <li id='KEY' dtnode=NODE>child1</li>
+		 *       <li id='KEY' dtnode=NODE>child2</li>
+		 *   </ul>
+		 * </li>
+		 */
+//		this.tree.logDebug("%s.render(%s)", this, useEffects);
+		// ---
+		var tree = this.tree,
+			parent = this.parent,
+			data = this.data,
+			opts = tree.options,
+			cn = opts.classNames,
+			isLastSib = this.isLastSibling();
+
+		if( !parent && !this.ul ) {
+			// Root node has only a <ul>
+			this.li = this.span = null;
+			this.ul = document.createElement("ul");
+			if( opts.minExpandLevel > 1 ){
+				this.ul.className = cn.container + " " + cn.noConnector;
+			}else{
+				this.ul.className = cn.container;
+			}
+		} else if( parent ) {
+			// Create <li><span /> </li>
+			if( ! this.li ) {
+				this.li = document.createElement("li");
+				this.li.dtnode = this;
+				if( data.key && opts.generateIds ){
+					this.li.id = opts.idPrefix + data.key;
+				}
+				this.span = document.createElement("span");
+				this.span.className = cn.title;
+				this.li.appendChild(this.span);
+
+				if( !parent.ul ) {
+					// This is the parent's first child: create UL tag
+					// (Hidden, because it will be
+					parent.ul = document.createElement("ul");
+					parent.ul.style.display = "none";
+					parent.li.appendChild(parent.ul);
+//					if( opts.minExpandLevel > this.getLevel() ){
+//						parent.ul.className = cn.noConnector;
+//					}
+				}
+				parent.ul.appendChild(this.li);
+			}
+			// set node connector images, links and text
+			this.span.innerHTML = this._getInnerHtml();
+			// Set classes for current status
+			var cnList = [];
+			cnList.push(cn.node);
+			if( data.isFolder ){
+				cnList.push(cn.folder);
+			}
+			if( this.bExpanded ){
+				cnList.push(cn.expanded);
+			}
+			if( this.hasChildren() !== false ){
+				cnList.push(cn.hasChildren);
+			}
+			if( data.isLazy && this.childList === null ){
+				cnList.push(cn.lazy);
+			}
+			if( isLastSib ){
+				cnList.push(cn.lastsib);
+			}
+			if( this.bSelected ){
+				cnList.push(cn.selected);
+			}
+			if( this.hasSubSel ){
+				cnList.push(cn.partsel);
+			}
+			if( tree.activeNode === this ){
+				cnList.push(cn.active);
+			}
+			if( data.addClass ){
+				cnList.push(data.addClass);
+			}
+			// IE6 doesn't correctly evaluate multiple class names,
+			// so we create combined class names that can be used in the CSS
+			cnList.push(cn.combinedExpanderPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isLazy && this.childList === null ? "d" : "")
+					+ (isLastSib ? "l" : "")
+					);
+			cnList.push(cn.combinedIconPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isFolder ? "f" : "")
+					);
+			this.span.className = cnList.join(" ");
+
+			// TODO: we should not set this in the <span> tag also, if we set it here:
+			this.li.className = isLastSib ? cn.lastsib : "";
+
+			// Hide children, if node is collapsed
+//			this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			// Allow tweaking, binding, ...
+			if(opts.onRender){
+				opts.onRender.call(tree, this, this.span);
+			}
+		}
+		// Visit child nodes
+		if( (this.bExpanded || includeInvisible === true) && this.childList ) {
+			for(var i=0, l=this.childList.length; i<l; i++) {
+				this.childList[i].render(false, includeInvisible);
+			}
+			// Make sure the tag order matches the child array
+			this._fixOrder();
+		}
+		// Hide children, if node is collapsed
+		if( this.ul ) {
+			var isHidden = (this.ul.style.display === "none");
+			var isExpanded = !!this.bExpanded;
+//			logMsg("isHidden:%s", isHidden);
+			if( useEffects && opts.fx && (isHidden === isExpanded) ) {
+				var duration = opts.fx.duration || 200;
+				$(this.ul).animate(opts.fx, duration);
+			} else {
+				this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			}
+		}
+	},
+	/** Return '/id1/id2/id3'. */
+	getKeyPath: function(excludeSelf) {
+		var path = [];
+		this.visitParents(function(node){
+			if(node.parent){
+				path.unshift(node.data.key);
+			}
+		}, !excludeSelf);
+		return "/" + path.join(this.tree.options.keyPathSeparator);
+	},
+
+	getParent: function() {
+		return this.parent;
+	},
+
+	getChildren: function() {
+		return this.childList;
+	},
+
+	/** Check if node has children (returns undefined, if not sure). */
+	hasChildren: function() {
+		if(this.data.isLazy){
+			if(this.childList === null || this.childList === undefined){
+				// Not yet loaded
+				return undefined;
+			}else if(this.childList.length === 0){
+				// Loaded, but response was empty
+				return false;
+			}else if(this.childList.length === 1 && this.childList[0].isStatusNode()){
+				// Currently loading or load error
+				return undefined;
+			}
+			return true;
+		}
+		return !!this.childList;
+	},
+
+	isFirstSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[0] === this;
+	},
+
+	isLastSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[p.childList.length-1] === this;
+	},
+
+	getPrevSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=1, l=ac.length; i<l; i++){ // start with 1, so prev(first) = null
+			if( ac[i] === this ){
+				return ac[i-1];
+			}
+		}
+		return null;
+	},
+
+	getNextSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=0, l=ac.length-1; i<l; i++){ // up to length-2, so next(last) = null
+			if( ac[i] === this ){
+				return ac[i+1];
+			}
+		}
+		return null;
+	},
+
+	isStatusNode: function() {
+		return (this.data.isStatusNode === true);
+	},
+
+	isChildOf: function(otherNode) {
+		return (this.parent && this.parent === otherNode);
+	},
+
+	isDescendantOf: function(otherNode) {
+		if(!otherNode){
+			return false;
+		}
+		var p = this.parent;
+		while( p ) {
+			if( p === otherNode ){
+				return true;
+			}
+			p = p.parent;
+		}
+		return false;
+	},
+
+	countChildren: function() {
+		var cl = this.childList;
+		if( !cl ){
+			return 0;
+		}
+		var n = cl.length;
+		for(var i=0, l=n; i<l; i++){
+			var child = cl[i];
+			n += child.countChildren();
+		}
+		return n;
+	},
+
+	/**Sort child list by title.
+	 * cmd: optional compare function.
+	 * deep: optional: pass true to sort all descendant nodes.
+	 */
+	sortChildren: function(cmp, deep) {
+		var cl = this.childList;
+		if( !cl ){
+			return;
+		}
+		cmp = cmp || function(a, b) {
+			return a.data.title === b.data.title ? 0 : a.data.title > b.data.title ? 1 : -1;
+			};
+		cl.sort(cmp);
+		if( deep ){
+			for(var i=0, l=cl.length; i<l; i++){
+				if( cl[i].childList ){
+					cl[i].sortChildren(cmp, "$norender$");
+				}
+			}
+		}
+		if( deep !== "$norender$" ){
+			this.render();
+		}
+	},
+
+	_setStatusNode: function(data) {
+		// Create, modify or remove the status child node (pass 'null', to remove it).
+		var firstChild = ( this.childList ? this.childList[0] : null );
+		if( !data ) {
+			if ( firstChild && firstChild.isStatusNode()) {
+				try{
+					// I've seen exceptions here with loadKeyPath...
+					if(this.ul){
+						this.ul.removeChild(firstChild.li);
+					}
+				}catch(e){}
+				if( this.childList.length === 1 ){
+					this.childList = [];
+				}else{
+					this.childList.shift();
+				}
+			}
+		} else if ( firstChild ) {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild.data = data;
+			firstChild.render();
+		} else {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild = this.addChild(data);
+		}
+	},
+
+	setLazyNodeStatus: function(lts, opts) {
+		var tooltip = (opts && opts.tooltip) ? opts.tooltip : null;
+		var info = (opts && opts.info) ? " (" + opts.info + ")" : "";
+		switch( lts ) {
+			case DTNodeStatus_Ok:
+				this._setStatusNode(null);
+				$(this.span).removeClass(this.tree.options.classNames.nodeLoading);
+				this.isLoading = false;
+//				this.render();
+				if( this.tree.options.autoFocus ) {
+					if( this === this.tree.tnRoot && this.childList && this.childList.length > 0) {
+						// special case: using ajaxInit
+						this.childList[0].focus();
+					} else {
+						this.focus();
+					}
+				}
+				break;
+			case DTNodeStatus_Loading:
+				this.isLoading = true;
+				$(this.span).addClass(this.tree.options.classNames.nodeLoading);
+				// The root is hidden, so we set a temporary status child
+				if(!this.parent){
+					this._setStatusNode({
+						title: this.tree.options.strings.loading + info,
+						tooltip: tooltip,
+						addClass: this.tree.options.classNames.nodeWait
+					});
+				}
+				break;
+			case DTNodeStatus_Error:
+				this.isLoading = false;
+//				$(this.span).addClass(this.tree.options.classNames.nodeError);
+				this._setStatusNode({
+					title: this.tree.options.strings.loadError + info,
+					tooltip: tooltip,
+					addClass: this.tree.options.classNames.nodeError
+				});
+				break;
+			default:
+				throw "Bad LazyNodeStatus: '" + lts + "'.";
+		}
+	},
+
+	_parentList: function(includeRoot, includeSelf) {
+		var l = [];
+		var dtn = includeSelf ? this : this.parent;
+		while( dtn ) {
+			if( includeRoot || dtn.parent ){
+				l.unshift(dtn);
+			}
+			dtn = dtn.parent;
+		}
+		return l;
+	},
+	getLevel: function() {
+		/**
+		 * Return node depth. 0: System root node, 1: visible top-level node.
+		 */
+		var level = 0;
+		var dtn = this.parent;
+		while( dtn ) {
+			level++;
+			dtn = dtn.parent;
+		}
+		return level;
+	},
+
+	_getTypeForOuterNodeEvent: function(event) {
+		/** Return the inner node span (title, checkbox or expander) if
+		 *  event.target points to the outer span.
+		 *  This function should fix issue #93:
+		 *  FF2 ignores empty spans, when generating events (returning the parent instead).
+		 */
+		var cns = this.tree.options.classNames;
+		var target = event.target;
+		// Only process clicks on an outer node span (probably due to a FF2 event handling bug)
+		if( target.className.indexOf(cns.node) < 0 ) {
+			return null;
+		}
+		// Event coordinates, relative to outer node span:
+		var eventX = event.pageX - target.offsetLeft;
+		var eventY = event.pageY - target.offsetTop;
+
+		for(var i=0, l=target.childNodes.length; i<l; i++) {
+			var cn = target.childNodes[i];
+			var x = cn.offsetLeft - target.offsetLeft;
+			var y = cn.offsetTop - target.offsetTop;
+			var nx = cn.clientWidth, ny = cn.clientHeight;
+//	        alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
+			if( eventX >= x && eventX <= (x+nx) && eventY >= y && eventY <= (y+ny) ) {
+//	            alert("HIT "+ cn.className);
+				if( cn.className==cns.title ){
+					return "title";
+				}else if( cn.className==cns.expander ){
+					return "expander";
+				}else if( cn.className==cns.checkbox ){
+					return "checkbox";
+				}else if( cn.className==cns.nodeIcon ){
+					return "icon";
+				}
+			}
+		}
+		return "prefix";
+	},
+
+	getEventTargetType: function(event) {
+		// Return the part of a node, that a click event occured on.
+		// Note: there is no check, if the event was fired on TIHS node.
+		var tcn = event && event.target ? event.target.className : "";
+		var cns = this.tree.options.classNames;
+
+		if( tcn === cns.title ){
+			return "title";
+		}else if( tcn === cns.expander ){
+			return "expander";
+		}else if( tcn === cns.checkbox ){
+			return "checkbox";
+		}else if( tcn === cns.nodeIcon ){
+			return "icon";
+		}else if( tcn === cns.empty || tcn === cns.vline || tcn === cns.connector ){
+			return "prefix";
+		}else if( tcn.indexOf(cns.node) >= 0 ){
+			// FIX issue #93
+			return this._getTypeForOuterNodeEvent(event);
+		}
+		return null;
+	},
+
+	isVisible: function() {
+		// Return true, if all parents are expanded.
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			if( ! parents[i].bExpanded ){ return false; }
+		}
+		return true;
+	},
+
+	makeVisible: function() {
+		// Make sure, all parents are expanded
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			parents[i]._expand(true);
+		}
+	},
+
+	focus: function() {
+		// TODO: check, if we already have focus
+//		this.tree.logDebug("dtnode.focus(): %o", this);
+		this.makeVisible();
+		try {
+			$(this.span).find(">a").focus();
+		} catch(e) { }
+	},
+
+	isFocused: function() {
+		return (this.tree.tnFocused === this);
+	},
+
+	_activate: function(flag, fireEvents) {
+		// (De)Activate - but not focus - this node.
+		this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.tree, flag, this) === false ){
+			return; // Callback returned false
+		}
+		if( flag ) {
+			// Activate
+			if( this.tree.activeNode ) {
+				if( this.tree.activeNode === this ){
+					return;
+				}
+				this.tree.activeNode.deactivate();
+			}
+			if( opts.activeVisible ){
+				this.makeVisible();
+			}
+			this.tree.activeNode = this;
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
+			}
+			this.tree.persistence.activeKey = this.data.key;
+			$(this.span).addClass(opts.classNames.active);
+			if ( fireEvents && opts.onActivate ){
+				opts.onActivate.call(this.tree, this);
+			}
+		} else {
+			// Deactivate
+			if( this.tree.activeNode === this ) {
+				if ( opts.onQueryActivate && opts.onQueryActivate.call(this.tree, false, this) === false ){
+					return; // Callback returned false
+				}
+				$(this.span).removeClass(opts.classNames.active);
+				if( opts.persist ) {
+					// Note: we don't pass null, but ''. So the cookie is not deleted.
+					// If we pass null, we also have to pass a COPY of opts, because $cookie will override opts.expires (issue 84)
+					$.cookie(opts.cookieId+"-active", "", opts.cookie);
+				}
+				this.tree.persistence.activeKey = null;
+				this.tree.activeNode = null;
+				if ( fireEvents && opts.onDeactivate ){
+					opts.onDeactivate.call(this.tree, this);
+				}
+			}
+		}
+	},
+
+	activate: function() {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.activate(): %o", this);
+		this._activate(true, true);
+	},
+
+	activateSilently: function() {
+		this._activate(true, false);
+	},
+
+	deactivate: function() {
+//		this.tree.logDebug("dtnode.deactivate(): %o", this);
+		this._activate(false, true);
+	},
+
+	isActive: function() {
+		return (this.tree.activeNode === this);
+	},
+
+	_userActivate: function() {
+		// Handle user click / [space] / [enter], according to clickFolderMode.
+		var activate = true;
+		var expand = false;
+		if ( this.data.isFolder ) {
+			switch( this.tree.options.clickFolderMode ) {
+			case 2:
+				activate = false;
+				expand = true;
+				break;
+			case 3:
+				activate = expand = true;
+				break;
+			}
+		}
+		if( this.parent === null ) {
+			expand = false;
+		}
+		if( expand ) {
+			this.toggleExpand();
+			this.focus();
+		}
+		if( activate ) {
+			this.activate();
+		}
+	},
+
+	_setSubSel: function(hasSubSel) {
+		if( hasSubSel ) {
+			this.hasSubSel = true;
+			$(this.span).addClass(this.tree.options.classNames.partsel);
+		} else {
+			this.hasSubSel = false;
+			$(this.span).removeClass(this.tree.options.classNames.partsel);
+		}
+	},
+
+	_fixSelectionState: function() {
+		// fix selection status, for multi-hier mode
+//		this.tree.logDebug("_fixSelectionState(%o) - %o", this.bSelected, this);
+		var p, i, l;
+		if( this.bSelected ) {
+			// Select all children
+			this.visit(function(node){
+				node.parent._setSubSel(true);
+				node._select(true, false, false);
+			});
+			// Select parents, if all children are selected
+			p = this.parent;
+			while( p ) {
+				p._setSubSel(true);
+				var allChildsSelected = true;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					var n = p.childList[i];
+					if( !n.bSelected && !n.data.isStatusNode ) {
+						allChildsSelected = false;
+						break;
+					}
+				}
+				if( allChildsSelected ){
+					p._select(true, false, false);
+				}
+				p = p.parent;
+			}
+		} else {
+			// Deselect all children
+			this._setSubSel(false);
+			this.visit(function(node){
+				node._setSubSel(false);
+				node._select(false, false, false);
+			});
+			// Deselect parents, and recalc hasSubSel
+			p = this.parent;
+			while( p ) {
+				p._select(false, false, false);
+				var isPartSel = false;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					if( p.childList[i].bSelected || p.childList[i].hasSubSel ) {
+						isPartSel = true;
+						break;
+					}
+				}
+				p._setSubSel(isPartSel);
+				p = p.parent;
+			}
+		}
+	},
+
+	_select: function(sel, fireEvents, deep) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode._select(%o) - %o", sel, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		//
+		if( this.bSelected === sel ) {
+//			this.tree.logDebug("dtnode._select(%o) IGNORED - %o", sel, this);
+			return;
+		}
+		// Allow event listener to abort selection
+		if ( fireEvents && opts.onQuerySelect && opts.onQuerySelect.call(this.tree, sel, this) === false ){
+			return; // Callback returned false
+		}
+		// Force single-selection
+		if( opts.selectMode==1 && sel ) {
+			this.tree.visit(function(node){
+				if( node.bSelected ) {
+					// Deselect; assuming that in selectMode:1 there's max. one other selected node
+					node._select(false, false, false);
+					return false;
+				}
+			});
+		}
+
+		this.bSelected = sel;
+//        this.tree._changeNodeList("select", this, sel);
+
+		if( sel ) {
+			if( opts.persist ){
+				this.tree.persistence.addSelect(this.data.key);
+			}
+			$(this.span).addClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, true, this);
+			}
+		} else {
+			if( opts.persist ){
+				this.tree.persistence.clearSelect(this.data.key);
+			}
+			$(this.span).removeClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, false, this);
+			}
+		}
+	},
+
+	select: function(sel) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.select(%o) - %o", sel, this);
+		if( this.data.unselectable ){
+			return this.bSelected;
+		}
+		return this._select(sel!==false, true, true);
+	},
+
+	toggleSelect: function() {
+//		this.tree.logDebug("dtnode.toggleSelect() - %o", this);
+		return this.select(!this.bSelected);
+	},
+
+	isSelected: function() {
+		return this.bSelected;
+	},
+
+	_loadContent: function() {
+		try {
+			var opts = this.tree.options;
+			this.tree.logDebug("_loadContent: start - %o", this);
+			this.setLazyNodeStatus(DTNodeStatus_Loading);
+			if( true === opts.onLazyRead.call(this.tree, this) ) {
+				// If function returns 'true', we assume that the loading is done:
+				this.setLazyNodeStatus(DTNodeStatus_Ok);
+				// Otherwise (i.e. if the loading was started as an asynchronous process)
+				// the onLazyRead(dtnode) handler is expected to call dtnode.setLazyNodeStatus(DTNodeStatus_Ok/_Error) when done.
+				this.tree.logDebug("_loadContent: succeeded - %o", this);
+			}
+		} catch(e) {
+			this.tree.logWarning("_loadContent: failed - %o", e);
+			this.setLazyNodeStatus(DTNodeStatus_Error, {tooltip: ""+e});
+		}
+	},
+
+	_expand: function(bExpand, forceSync) {
+		if( this.bExpanded === bExpand ) {
+			this.tree.logDebug("dtnode._expand(%o) IGNORED - %o", bExpand, this);
+			return;
+		}
+		this.tree.logDebug("dtnode._expand(%o) - %o", bExpand, this);
+		var opts = this.tree.options;
+		if( !bExpand && this.getLevel() < opts.minExpandLevel ) {
+			this.tree.logDebug("dtnode._expand(%o) prevented collapse - %o", bExpand, this);
+			return;
+		}
+		if ( opts.onQueryExpand && opts.onQueryExpand.call(this.tree, bExpand, this) === false ){
+			return; // Callback returned false
+		}
+		this.bExpanded = bExpand;
+
+		// Persist expand state
+		if( opts.persist ) {
+			if( bExpand ){
+				this.tree.persistence.addExpand(this.data.key);
+			}else{
+				this.tree.persistence.clearExpand(this.data.key);
+			}
+		}
+		// Do not apply animations in init phase, or before lazy-loading
+		var allowEffects = !(this.data.isLazy && this.childList === null)
+			&& !this.isLoading
+			&& !forceSync;
+		this.render(allowEffects);
+
+		// Auto-collapse mode: collapse all siblings
+		if( this.bExpanded && this.parent && opts.autoCollapse ) {
+			var parents = this._parentList(false, true);
+			for(var i=0, l=parents.length; i<l; i++){
+				parents[i].collapseSiblings();
+			}
+		}
+		// If the currently active node is now hidden, deactivate it
+		if( opts.activeVisible && this.tree.activeNode && ! this.tree.activeNode.isVisible() ) {
+			this.tree.activeNode.deactivate();
+		}
+		// Expanding a lazy node: set 'loading...' and call callback
+		if( bExpand && this.data.isLazy && this.childList === null && !this.isLoading ) {
+			this._loadContent();
+			return;
+		}
+		if ( opts.onExpand ){
+			opts.onExpand.call(this.tree, bExpand, this);
+		}
+	},
+
+	expand: function(flag) {
+		flag = (flag !== false);
+		if( !this.childList && !this.data.isLazy && flag ){
+			return; // Prevent expanding empty nodes
+		} else if( this.parent === null && !flag ){
+			return; // Prevent collapsing the root
+		}
+		this._expand(flag);
+	},
+
+	scheduleAction: function(mode, ms) {
+		/** Schedule activity for delayed execution (cancel any pending request).
+		 *  scheduleAction('cancel') will cancel the request.
+		 */
+		if( this.tree.timer ) {
+			clearTimeout(this.tree.timer);
+			this.tree.logDebug("clearTimeout(%o)", this.tree.timer);
+		}
+		var self = this; // required for closures
+		switch (mode) {
+		case "cancel":
+			// Simply made sure that timer was cleared
+			break;
+		case "expand":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger expand");
+				self.expand(true);
+			}, ms);
+			break;
+		case "activate":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger activate");
+				self.activate();
+			}, ms);
+			break;
+		default:
+			throw "Invalid mode " + mode;
+		}
+		this.tree.logDebug("setTimeout(%s, %s): %s", mode, ms, this.tree.timer);
+	},
+
+	toggleExpand: function() {
+		this.expand(!this.bExpanded);
+	},
+
+	collapseSiblings: function() {
+		if( this.parent === null ){
+			return;
+		}
+		var ac = this.parent.childList;
+		for (var i=0, l=ac.length; i<l; i++) {
+			if ( ac[i] !== this && ac[i].bExpanded ){
+				ac[i]._expand(false);
+			}
+		}
+	},
+
+	_onClick: function(event) {
+//		this.tree.logDebug("dtnode.onClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+		var targetType = this.getEventTargetType(event);
+		if( targetType === "expander" ) {
+			// Clicking the expander icon always expands/collapses
+			this.toggleExpand();
+			this.focus(); // issue 95
+		} else if( targetType === "checkbox" ) {
+			// Clicking the checkbox always (de)selects
+			this.toggleSelect();
+			this.focus(); // issue 95
+		} else {
+			this._userActivate();
+			var aTag = this.span.getElementsByTagName("a");
+			if(aTag[0]){
+				// issue 154
+				// TODO: check if still required on IE 9:
+				// Chrome and Safari don't focus the a-tag on click,
+				// but calling focus() seem to have problems on IE:
+				// http://code.google.com/p/dynatree/issues/detail?id=154
+				if(!$.browser.msie){
+					aTag[0].focus();
+				}
+			}else{
+				// 'noLink' option was set
+				return true;
+			}
+		}
+		// Make sure that clicks stop, otherwise <a href='#'> jumps to the top
+		event.preventDefault();
+	},
+
+	_onDblClick: function(event) {
+//		this.tree.logDebug("dtnode.onDblClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+	},
+
+	_onKeydown: function(event) {
+//		this.tree.logDebug("dtnode.onKeydown(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+		var handled = true,
+			sib;
+//		alert("keyDown" + event.which);
+
+		switch( event.which ) {
+			// charCodes:
+//			case 43: // '+'
+			case 107: // '+'
+			case 187: // '+' @ Chrome, Safari
+				if( !this.bExpanded ){ this.toggleExpand(); }
+				break;
+//			case 45: // '-'
+			case 109: // '-'
+			case 189: // '+' @ Chrome, Safari
+				if( this.bExpanded ){ this.toggleExpand(); }
+				break;
+			//~ case 42: // '*'
+				//~ break;
+			//~ case 47: // '/'
+				//~ break;
+			// case 13: // <enter>
+				// <enter> on a focused <a> tag seems to generate a click-event.
+				// this._userActivate();
+				// break;
+			case 32: // <space>
+				this._userActivate();
+				break;
+			case 8: // <backspace>
+				if( this.parent ){
+					this.parent.focus();
+				}
+				break;
+			case 37: // <left>
+				if( this.bExpanded ) {
+					this.toggleExpand();
+					this.focus();
+//				} else if( this.parent && (this.tree.options.rootVisible || this.parent.parent) ) {
+				} else if( this.parent && this.parent.parent ) {
+					this.parent.focus();
+				}
+				break;
+			case 39: // <right>
+				if( !this.bExpanded && (this.childList || this.data.isLazy) ) {
+					this.toggleExpand();
+					this.focus();
+				} else if( this.childList ) {
+					this.childList[0].focus();
+				}
+				break;
+			case 38: // <up>
+				sib = this.getPrevSibling();
+				while( sib && sib.bExpanded && sib.childList ){
+					sib = sib.childList[sib.childList.length-1];
+				}
+//				if( !sib && this.parent && (this.tree.options.rootVisible || this.parent.parent) )
+				if( !sib && this.parent && this.parent.parent ){
+					sib = this.parent;
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			case 40: // <down>
+				if( this.bExpanded && this.childList ) {
+					sib = this.childList[0];
+				} else {
+					var parents = this._parentList(false, true);
+					for(var i=parents.length-1; i>=0; i--) {
+						sib = parents[i].getNextSibling();
+						if( sib ){ break; }
+					}
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			default:
+				handled = false;
+		}
+		// Return false, if handled, to prevent default processing
+//		return !handled;
+		if(handled){
+			event.preventDefault();
+		}
+	},
+
+	_onKeypress: function(event) {
+		// onKeypress is only hooked to allow user callbacks.
+		// We don't process it, because IE and Safari don't fire keypress for cursor keys.
+//		this.tree.logDebug("dtnode.onKeypress(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+	},
+
+	_onFocus: function(event) {
+		// Handles blur and focus events.
+//		this.tree.logDebug("dtnode.onFocus(%o): %o", event, this);
+		var opts = this.tree.options;
+		if ( event.type == "blur" || event.type == "focusout" ) {
+			if ( opts.onBlur ){
+				opts.onBlur.call(this.tree, this);
+			}
+			if( this.tree.tnFocused ){
+				$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);