]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/Tree.js.uncompressed.js
2 'url:dijit/templates/TreeNode.html':"<div class=\"dijitTreeNode\" role=\"presentation\"\n\t><div data-dojo-attach-point=\"rowNode\" class=\"dijitTreeRow\" role=\"presentation\" data-dojo-attach-event=\"onmouseenter:_onMouseEnter, onmouseleave:_onMouseLeave, onclick:_onClick, ondblclick:_onDblClick\"\n\t\t><img src=\"${_blankGif}\" alt=\"\" data-dojo-attach-point=\"expandoNode\" class=\"dijitTreeExpando\" role=\"presentation\"\n\t\t/><span data-dojo-attach-point=\"expandoNodeText\" class=\"dijitExpandoText\" role=\"presentation\"\n\t\t></span\n\t\t><span data-dojo-attach-point=\"contentNode\"\n\t\t\tclass=\"dijitTreeContent\" role=\"presentation\">\n\t\t\t<img src=\"${_blankGif}\" alt=\"\" data-dojo-attach-point=\"iconNode\" class=\"dijitIcon dijitTreeIcon\" role=\"presentation\"\n\t\t\t/><span data-dojo-attach-point=\"labelNode\" class=\"dijitTreeLabel\" role=\"treeitem\" tabindex=\"-1\" aria-selected=\"false\" data-dojo-attach-event=\"onfocus:_onLabelFocus\"></span>\n\t\t</span\n\t></div>\n\t<div data-dojo-attach-point=\"containerNode\" class=\"dijitTreeContainer\" role=\"presentation\" style=\"display: none;\"></div>\n</div>\n",
3 'url:dijit/templates/Tree.html':"<div class=\"dijitTree dijitTreeContainer\" role=\"tree\"\n\tdata-dojo-attach-event=\"onkeypress:_onKeyPress\">\n\t<div class=\"dijitInline dijitTreeIndent\" style=\"position: absolute; top: -9999px\" data-dojo-attach-point=\"indentDetector\"></div>\n</div>\n"}});
5 "dojo/_base/array", // array.filter array.forEach array.map
6 "dojo/_base/connect", // connect.isCopyKey()
7 "dojo/cookie", // cookie
8 "dojo/_base/declare", // declare
9 "dojo/_base/Deferred", // Deferred
10 "dojo/DeferredList", // DeferredList
11 "dojo/dom", // dom.isDescendant
12 "dojo/dom-class", // domClass.add domClass.remove domClass.replace domClass.toggle
13 "dojo/dom-geometry", // domGeometry.setMarginBox domGeometry.position
14 "dojo/dom-style",// domStyle.set
15 "dojo/_base/event", // event.stop
16 "dojo/fx", // fxUtils.wipeIn fxUtils.wipeOut
17 "dojo/_base/kernel", // kernel.deprecated
18 "dojo/keys", // arrows etc.
19 "dojo/_base/lang", // lang.getObject lang.mixin lang.hitch
22 "./registry", // registry.getEnclosingWidget(), manager.defaultDuration
23 "./_base/manager", // manager.getEnclosingWidget(), manager.defaultDuration
29 "dojo/text!./templates/TreeNode.html",
30 "dojo/text!./templates/Tree.html",
31 "./tree/TreeStoreModel",
32 "./tree/ForestStoreModel",
34 ], function(array
, connect
, cookie
, declare
, Deferred
, DeferredList
,
35 dom
, domClass
, domGeometry
, domStyle
, event
, fxUtils
, kernel
, keys
, lang
, topic
,
36 focus
, registry
, manager
, _Widget
, _TemplatedMixin
, _Container
, _Contained
, _CssStateMixin
,
37 treeNodeTemplate
, treeTemplate
, TreeStoreModel
, ForestStoreModel
, _dndSelector
){
40 var _Widget = dijit._Widget;
41 var _TemplatedMixin = dijit._TemplatedMixin;
42 var _CssStateMixin = dijit._CssStateMixin;
43 var _Container = dijit._Container;
44 var _Contained = dijit._Contained;
50 // dijit.Tree widget, and internal dijit._TreeNode widget
53 var TreeNode
= declare(
55 [_Widget
, _TemplatedMixin
, _Container
, _Contained
, _CssStateMixin
],
58 // Single node within a tree. This class is used internally
59 // by Tree and should not be accessed directly.
64 // the dojo.data entry this tree represents
67 // isTreeNode: [protected] Boolean
68 // Indicates that this is a TreeNode. Used by `dijit.Tree` only,
69 // should not be accessed directly.
73 // Text of this tree node
75 _setLabelAttr
: {node
: "labelNode", type
: "innerText"},
77 // isExpandable: [private] Boolean
78 // This node has children, so show the expando node (+ sign)
81 // isExpanded: [readonly] Boolean
82 // This node is currently expanded (ie, opened)
85 // state: [private] String
86 // Dynamic loading-related stuff.
87 // When an empty folder node appears, it is "UNCHECKED" first,
88 // then after dojo.data query it becomes "LOADING" and, finally "LOADED"
91 templateString
: treeNodeTemplate
,
93 baseClass
: "dijitTreeNode",
95 // For hover effect for tree node, and focus effect for label
97 rowNode
: "dijitTreeRow",
98 labelNode
: "dijitTreeLabel"
101 // Tooltip is defined in _WidgetBase but we need to handle the mapping to DOM here
102 _setTooltipAttr
: {node
: "rowNode", type
: "attribute", attribute
: "title"},
104 buildRendering: function(){
105 this.inherited(arguments
);
107 // set expand icon for leaf
110 // set icon and label class based on item
111 this._updateItemClasses(this.item
);
113 if(this.isExpandable
){
114 this.labelNode
.setAttribute("aria-expanded", this.isExpanded
);
117 //aria-selected should be false on all selectable elements.
118 this.setSelected(false);
121 _setIndentAttr: function(indent
){
123 // Tell this node how many levels it should be indented
125 // 0 for top level nodes, 1 for their children, 2 for their
126 // grandchildren, etc.
128 // Math.max() is to prevent negative padding on hidden root node (when indent == -1)
129 var pixels
= (Math
.max(indent
, 0) * this.tree
._nodePixelIndent
) + "px";
131 domStyle
.set(this.domNode
, "backgroundPosition", pixels
+ " 0px");
132 domStyle
.set(this.rowNode
, this.isLeftToRight() ? "paddingLeft" : "paddingRight", pixels
);
134 array
.forEach(this.getChildren(), function(child
){
135 child
.set("indent", indent
+1);
138 this._set("indent", indent
);
141 markProcessing: function(){
143 // Visually denote that tree is loading data, etc.
146 this.state
= "LOADING";
147 this._setExpando(true);
150 unmarkProcessing: function(){
152 // Clear markup from markProcessing() call
155 this._setExpando(false);
158 _updateItemClasses: function(item
){
160 // Set appropriate CSS classes for icon and label dom node
161 // (used to allow for item updates to change respective CSS)
164 var tree
= this.tree
, model
= tree
.model
;
165 if(tree
._v10Compat
&& item
=== model
.root
){
166 // For back-compat with 1.0, need to use null to specify root item (TODO: remove in 2.0)
169 this._applyClassAndStyle(item
, "icon", "Icon");
170 this._applyClassAndStyle(item
, "label", "Label");
171 this._applyClassAndStyle(item
, "row", "Row");
174 _applyClassAndStyle: function(item
, lower
, upper
){
176 // Set the appropriate CSS classes and styles for labels, icons and rows.
182 // The lower case attribute to use, e.g. 'icon', 'label' or 'row'.
185 // The upper case attribute to use, e.g. 'Icon', 'Label' or 'Row'.
190 var clsName
= "_" + lower
+ "Class";
191 var nodeName
= lower
+ "Node";
192 var oldCls
= this[clsName
];
194 this[clsName
] = this.tree
["get" + upper
+ "Class"](item
, this.isExpanded
);
195 domClass
.replace(this[nodeName
], this[clsName
] || "", oldCls
|| "");
197 domStyle
.set(this[nodeName
], this.tree
["get" + upper
+ "Style"](item
, this.isExpanded
) || {});
200 _updateLayout: function(){
202 // Set appropriate CSS classes for this.domNode
205 var parent
= this.getParent();
206 if(!parent
|| !parent
.rowNode
|| parent
.rowNode
.style
.display
== "none"){
207 /* if we are hiding the root node then make every first level child look like a root node */
208 domClass
.add(this.domNode
, "dijitTreeIsRoot");
210 domClass
.toggle(this.domNode
, "dijitTreeIsLast", !this.getNextSibling());
214 _setExpando: function(/*Boolean*/ processing
){
216 // Set the right image for the expando node
220 var styles
= ["dijitTreeExpandoLoading", "dijitTreeExpandoOpened",
221 "dijitTreeExpandoClosed", "dijitTreeExpandoLeaf"],
222 _a11yStates
= ["*","-","+","*"],
223 idx
= processing
? 0 : (this.isExpandable
? (this.isExpanded
? 1 : 2) : 3);
225 // apply the appropriate class to the expando node
226 domClass
.replace(this.expandoNode
, styles
[idx
], styles
);
228 // provide a non-image based indicator for images-off mode
229 this.expandoNodeText
.innerHTML
= _a11yStates
[idx
];
237 // Deferred that fires when expansion is complete
239 // If there's already an expand in progress or we are already expanded, just return
240 if(this._expandDeferred
){
241 return this._expandDeferred
; // dojo.Deferred
244 // cancel in progress collapse operation
245 this._wipeOut
&& this._wipeOut
.stop();
247 // All the state information for when a node is expanded, maybe this should be
248 // set when the animation completes instead
249 this.isExpanded
= true;
250 this.labelNode
.setAttribute("aria-expanded", "true");
251 if(this.tree
.showRoot
|| this !== this.tree
.rootNode
){
252 this.containerNode
.setAttribute("role", "group");
254 domClass
.add(this.contentNode
,'dijitTreeContentExpanded');
256 this._updateItemClasses(this.item
);
257 if(this == this.tree
.rootNode
){
258 this.tree
.domNode
.setAttribute("aria-expanded", "true");
262 wipeIn
= fxUtils
.wipeIn({
263 node
: this.containerNode
, duration
: manager
.defaultDuration
,
269 // Deferred that fires when expand is complete
270 def
= (this._expandDeferred
= new Deferred(function(){
277 return def
; // dojo.Deferred
280 collapse: function(){
282 // Collapse this node (if it's expanded)
284 if(!this.isExpanded
){ return; }
286 // cancel in progress expand operation
287 if(this._expandDeferred
){
288 this._expandDeferred
.cancel();
289 delete this._expandDeferred
;
292 this.isExpanded
= false;
293 this.labelNode
.setAttribute("aria-expanded", "false");
294 if(this == this.tree
.rootNode
){
295 this.tree
.domNode
.setAttribute("aria-expanded", "false");
297 domClass
.remove(this.contentNode
,'dijitTreeContentExpanded');
299 this._updateItemClasses(this.item
);
302 this._wipeOut
= fxUtils
.wipeOut({
303 node
: this.containerNode
, duration
: manager
.defaultDuration
306 this._wipeOut
.play();
310 // Levels from this node to the root node
313 setChildItems: function(/* Object[] */ items
){
315 // Sets the child items of this node, removing/adding nodes
316 // from current children to match specified items[] array.
317 // Also, if this.persist == true, expands any children that were previously
320 // Deferred object that fires after all previously opened children
321 // have been expanded again (or fires instantly if there are no such children).
323 var tree
= this.tree
,
325 defs
= []; // list of deferreds that need to fire before I am complete
328 // Orphan all my existing children.
329 // If items contains some of the same items as before then we will reattach them.
330 // Don't call this.removeChild() because that will collapse the tree etc.
331 array
.forEach(this.getChildren(), function(child
){
332 _Container
.prototype.removeChild
.call(this, child
);
335 this.state
= "LOADED";
337 if(items
&& items
.length
> 0){
338 this.isExpandable
= true;
340 // Create _TreeNode widget for each specified tree node, unless one already
341 // exists and isn't being used (presumably it's from a DnD move and was recently
343 array
.forEach(items
, function(item
){
344 var id
= model
.getIdentity(item
),
345 existingNodes
= tree
._itemNodesMap
[id
],
348 for(var i
=0;i
<existingNodes
.length
;i
++){
349 if(existingNodes
[i
] && !existingNodes
[i
].getParent()){
350 node
= existingNodes
[i
];
351 node
.set('indent', this.indent
+1);
357 node
= this.tree
._createTreeNode({
360 isExpandable
: model
.mayHaveChildren(item
),
361 label
: tree
.getLabel(item
),
362 tooltip
: tree
.getTooltip(item
),
365 textDir
: tree
.textDir
,
366 indent
: this.indent
+ 1
369 existingNodes
.push(node
);
371 tree
._itemNodesMap
[id
] = [node
];
376 // If node was previously opened then open it again now (this may trigger
377 // more data store accesses, recursively)
378 if(this.tree
.autoExpand
|| this.tree
._state(node
)){
379 defs
.push(tree
._expandNode(node
));
383 // note that updateLayout() needs to be called on each child after
384 // _all_ the children exist
385 array
.forEach(this.getChildren(), function(child
){
386 child
._updateLayout();
389 this.isExpandable
=false;
392 if(this._setExpando
){
393 // change expando to/from dot or + icon, as appropriate
394 this._setExpando(false);
397 // Set leaf icon or folder icon, as appropriate
398 this._updateItemClasses(this.item
);
400 // On initial tree show, make the selected TreeNode as either the root node of the tree,
401 // or the first child, if the root node is hidden
402 if(this == tree
.rootNode
){
403 var fc
= this.tree
.showRoot
? this : this.getChildren()[0];
405 fc
.setFocusable(true);
406 tree
.lastFocused
= fc
;
408 // fallback: no nodes in tree so focus on Tree <div> itself
409 tree
.domNode
.setAttribute("tabIndex", "0");
413 return new DeferredList(defs
); // dojo.Deferred
416 getTreePath: function(){
419 while(node
&& node
!== this.tree
.rootNode
){
420 path
.unshift(node
.item
);
421 node
= node
.getParent();
423 path
.unshift(this.tree
.rootNode
.item
);
428 getIdentity: function(){
429 return this.tree
.model
.getIdentity(this.item
);
432 removeChild: function(/* treeNode */ node
){
433 this.inherited(arguments
);
435 var children
= this.getChildren();
436 if(children
.length
== 0){
437 this.isExpandable
= false;
441 array
.forEach(children
, function(child
){
442 child
._updateLayout();
446 makeExpandable: function(){
448 // if this node wasn't already showing the expando node,
449 // turn it into one and call _setExpando()
451 // TODO: hmm this isn't called from anywhere, maybe should remove it for 2.0
453 this.isExpandable
= true;
454 this._setExpando(false);
457 _onLabelFocus: function(){
459 // Called when this row is focused (possibly programatically)
460 // Note that we aren't using _onFocus() builtin to dijit
461 // because it's called when focus is moved to a descendant TreeNode.
464 this.tree
._onNodeFocus(this);
467 setSelected: function(/*Boolean*/ selected
){
469 // A Tree has a (single) currently selected node.
470 // Mark that this node is/isn't that currently selected node.
472 // In particular, setting a node as selected involves setting tabIndex
473 // so that when user tabs to the tree, focus will go to that node (only).
474 this.labelNode
.setAttribute("aria-selected", selected
);
475 domClass
.toggle(this.rowNode
, "dijitTreeRowSelected", selected
);
478 setFocusable: function(/*Boolean*/ selected
){
480 // A Tree has a (single) node that's focusable.
481 // Mark that this node is/isn't that currently focsuable node.
483 // In particular, setting a node as selected involves setting tabIndex
484 // so that when user tabs to the tree, focus will go to that node (only).
486 this.labelNode
.setAttribute("tabIndex", selected
? "0" : "-1");
489 _onClick: function(evt
){
491 // Handler for onclick event on a node
494 this.tree
._onClick(this, evt
);
496 _onDblClick: function(evt
){
498 // Handler for ondblclick event on a node
501 this.tree
._onDblClick(this, evt
);
504 _onMouseEnter: function(evt
){
506 // Handler for onmouseenter event on a node
509 this.tree
._onNodeMouseEnter(this, evt
);
512 _onMouseLeave: function(evt
){
514 // Handler for onmouseenter event on a node
517 this.tree
._onNodeMouseLeave(this, evt
);
520 _setTextDirAttr: function(textDir
){
521 if(textDir
&&((this.textDir
!= textDir
) || !this._created
)){
522 this._set("textDir", textDir
);
523 this.applyTextDir(this.labelNode
, this.labelNode
.innerText
|| this.labelNode
.textContent
|| "");
524 array
.forEach(this.getChildren(), function(childNode
){
525 childNode
.set("textDir", textDir
);
531 var Tree
= declare("dijit.Tree", [_Widget
, _TemplatedMixin
], {
533 // This widget displays hierarchical data from a store.
535 // store: [deprecated] String||dojo.data.Store
536 // Deprecated. Use "model" parameter instead.
537 // The store to get data to display in the tree.
540 // model: dijit.Tree.model
541 // Interface to read tree data, get notifications of changes to tree data,
542 // and for handling drop operations (i.e drag and drop onto the tree)
545 // query: [deprecated] anything
546 // Deprecated. User should specify query to the model directly instead.
547 // Specifies datastore query to return the root item or top items for the tree.
550 // label: [deprecated] String
551 // Deprecated. Use dijit.tree.ForestStoreModel directly instead.
552 // Used in conjunction with query parameter.
553 // If a query is specified (rather than a root node id), and a label is also specified,
554 // then a fake root node is created and displayed, with this label.
557 // showRoot: [const] Boolean
558 // Should the root node be displayed, or hidden?
561 // childrenAttr: [deprecated] String[]
562 // Deprecated. This information should be specified in the model.
563 // One ore more attributes that holds children of a tree node
564 childrenAttr
: ["children"],
566 // paths: String[][] or Item[][]
567 // Full paths from rootNode to selected nodes expressed as array of items or array of ids.
568 // Since setting the paths may be asynchronous (because ofwaiting on dojo.data), set("paths", ...)
569 // returns a Deferred to indicate when the set is complete.
572 // path: String[] or Item[]
573 // Backward compatible singular variant of paths.
576 // selectedItems: [readonly] Item[]
577 // The currently selected items in this tree.
578 // This property can only be set (via set('selectedItems', ...)) when that item is already
579 // visible in the tree. (I.e. the tree has already been expanded to show that node.)
580 // Should generally use `paths` attribute to set the selected items instead.
583 // selectedItem: [readonly] Item
584 // Backward compatible singular variant of selectedItems.
587 // openOnClick: Boolean
588 // If true, clicking a folder node's label will open it, rather than calling onClick()
591 // openOnDblClick: Boolean
592 // If true, double-clicking a folder node's label will open it, rather than calling onDblClick()
593 openOnDblClick
: false,
595 templateString
: treeTemplate
,
598 // Enables/disables use of cookies for state saving.
601 // autoExpand: Boolean
602 // Fully expand the tree on load. Overrides `persist`.
605 // dndController: [protected] Function|String
606 // Class to use as as the dnd controller. Specifying this class enables DnD.
607 // Generally you should specify this as dijit.tree.dndSource.
608 // Setting of dijit.tree._dndSelector handles selection only (no actual DnD).
609 dndController
: _dndSelector
,
611 // parameters to pull off of the tree and pass on to the dndController as its params
612 dndParams
: ["onDndDrop","itemCreator","onDndCancel","checkAcceptance", "checkItemAcceptance", "dragThreshold", "betweenThreshold"],
614 //declare the above items so they can be pulled from the tree's markup
616 // onDndDrop: [protected] Function
617 // Parameter to dndController, see `dijit.tree.dndSource.onDndDrop`.
618 // Generally this doesn't need to be set.
622 itemCreator: function(nodes, target, source){
624 // Returns objects passed to `Tree.model.newItem()` based on DnD nodes
625 // dropped onto the tree. Developer must override this method to enable
626 // dropping from external sources onto this Tree, unless the Tree.model's items
627 // happen to look like {id: 123, name: "Apple" } with no other attributes.
629 // For each node in nodes[], which came from source, create a hash of name/value
630 // pairs to be passed to Tree.model.newItem(). Returns array of those hashes.
632 // The DOMNodes dragged from the source container
634 // The target TreeNode.rowNode
635 // source: dojo.dnd.Source
636 // The source container the nodes were dragged from, perhaps another Tree or a plain dojo.dnd.Source
638 // Array of name/value hashes for each new item to be added to the Tree, like:
640 // | { id: 123, label: "apple", foo: "bar" },
641 // | { id: 456, label: "pear", zaz: "bam" }
650 // onDndCancel: [protected] Function
651 // Parameter to dndController, see `dijit.tree.dndSource.onDndCancel`.
652 // Generally this doesn't need to be set.
656 checkAcceptance: function(source, nodes){
658 // Checks if the Tree itself can accept nodes from this source
659 // source: dijit.tree._dndSource
660 // The source which provides items
662 // Array of DOM nodes corresponding to nodes being dropped, dijitTreeRow nodes if
663 // source is a dijit.Tree.
666 return true; // Boolean
669 checkAcceptance
: null,
672 checkItemAcceptance: function(target, source, position){
674 // Stub function to be overridden if one wants to check for the ability to drop at the node/item level
676 // In the base case, this is called to check if target can become a child of source.
677 // When betweenThreshold is set, position="before" or "after" means that we
678 // are asking if the source node can be dropped before/after the target node.
680 // The dijitTreeRoot DOM node inside of the TreeNode that we are dropping on to
681 // Use dijit.getEnclosingWidget(target) to get the TreeNode.
682 // source: dijit.tree.dndSource
683 // The (set of) nodes we are dropping
685 // "over", "before", or "after"
688 return true; // Boolean
691 checkItemAcceptance
: null,
693 // dragThreshold: Integer
694 // Number of pixels mouse moves before it's considered the start of a drag operation
697 // betweenThreshold: Integer
698 // Set to a positive value to allow drag and drop "between" nodes.
700 // If during DnD mouse is over a (target) node but less than betweenThreshold
701 // pixels from the bottom edge, dropping the the dragged node will make it
702 // the next sibling of the target node, rather than the child.
704 // Similarly, if mouse is over a target node but less that betweenThreshold
705 // pixels from the top edge, dropping the dragged node will make it
706 // the target node's previous sibling rather than the target node's child.
709 // _nodePixelIndent: Integer
710 // Number of pixels to indent tree nodes (relative to parent node).
711 // Default is 19 but can be overridden by setting CSS class dijitTreeIndent
712 // and calling resize() or startup() on tree after it's in the DOM.
713 _nodePixelIndent
: 19,
715 _publish: function(/*String*/ topicName
, /*Object*/ message
){
717 // Publish a message for this widget/topic
718 topic
.publish(this.id
, lang
.mixin({tree
: this, event
: topicName
}, message
|| {})); // publish
721 postMixInProperties: function(){
725 // There's little point in saving opened/closed state of nodes for a Tree
726 // that initially opens all it's nodes.
727 this.persist
= false;
730 this._itemNodesMap
={};
732 if(!this.cookieName
&& this.id
){
733 this.cookieName
= this.id
+ "SaveStateCookie";
736 this._loadDeferred
= new Deferred();
738 this.inherited(arguments
);
741 postCreate: function(){
744 // Create glue between store and Tree, if not specified directly by user
749 // monitor changes to items
750 this.connect(this.model
, "onChange", "_onItemChange");
751 this.connect(this.model
, "onChildrenChange", "_onItemChildrenChange");
752 this.connect(this.model
, "onDelete", "_onItemDelete");
756 this.inherited(arguments
);
758 if(this.dndController
){
759 if(lang
.isString(this.dndController
)){
760 this.dndController
= lang
.getObject(this.dndController
);
763 for(var i
=0; i
<this.dndParams
.length
;i
++){
764 if(this[this.dndParams
[i
]]){
765 params
[this.dndParams
[i
]] = this[this.dndParams
[i
]];
768 this.dndController
= new this.dndController(this, params
);
772 _store2model: function(){
774 // User specified a store&query rather than model, so create model from store/query
775 this._v10Compat
= true;
776 kernel
.deprecated("Tree: from version 2.0, should specify a model object rather than a store/query");
779 id
: this.id
+ "_ForestStoreModel",
782 childrenAttrs
: this.childrenAttr
785 // Only override the model's mayHaveChildren() method if the user has specified an override
786 if(this.params
.mayHaveChildren
){
787 modelParams
.mayHaveChildren
= lang
.hitch(this, "mayHaveChildren");
790 if(this.params
.getItemChildren
){
791 modelParams
.getChildren
= lang
.hitch(this, function(item
, onComplete
, onError
){
792 this.getItemChildren((this._v10Compat
&& item
=== this.model
.root
) ? null : item
, onComplete
, onError
);
795 this.model
= new ForestStoreModel(modelParams
);
797 // For backwards compatibility, the visibility of the root node is controlled by
798 // whether or not the user has specified a label
799 this.showRoot
= Boolean(this.label
);
804 // Called when tree finishes loading and expanding.
806 // If persist == true the loading may encompass many levels of fetches
807 // from the data store, each asynchronous. Waits for all to finish.
814 // Initial load of the tree.
815 // Load root node (possibly hidden) and it's children.
817 lang
.hitch(this, function(item
){
818 var rn
= (this.rootNode
= this.tree
._createTreeNode({
822 label
: this.label
|| this.getLabel(item
),
823 textDir
: this.textDir
,
824 indent
: this.showRoot
? 0 : -1
827 rn
.rowNode
.style
.display
="none";
828 // if root is not visible, move tree role to the invisible
829 // root node's containerNode, see #12135
830 this.domNode
.setAttribute("role", "presentation");
832 rn
.labelNode
.setAttribute("role", "presentation");
833 rn
.containerNode
.setAttribute("role", "tree");
835 this.domNode
.appendChild(rn
.domNode
);
836 var identity
= this.model
.getIdentity(item
);
837 if(this._itemNodesMap
[identity
]){
838 this._itemNodesMap
[identity
].push(rn
);
840 this._itemNodesMap
[identity
] = [rn
];
843 rn
._updateLayout(); // sets "dijitTreeIsRoot" CSS classname
845 // load top level children and then fire onLoad() event
846 this._expandNode(rn
).addCallback(lang
.hitch(this, function(){
847 this._loadDeferred
.callback(true);
852 console
.error(this, ": error loading root: ", err
);
857 getNodesByItem: function(/*Item or id*/ item
){
859 // Returns all tree nodes that refer to an item
861 // Array of tree nodes that refer to passed item
863 if(!item
){ return []; }
864 var identity
= lang
.isString(item
) ? item
: this.model
.getIdentity(item
);
865 // return a copy so widget don't get messed up by changes to returned array
866 return [].concat(this._itemNodesMap
[identity
]);
869 _setSelectedItemAttr: function(/*Item or id*/ item
){
870 this.set('selectedItems', [item
]);
873 _setSelectedItemsAttr: function(/*Items or ids*/ items
){
875 // Select tree nodes related to passed items.
876 // WARNING: if model use multi-parented items or desired tree node isn't already loaded
877 // behavior is undefined. Use set('paths', ...) instead.
879 this._loadDeferred
.addCallback( lang
.hitch(this, function(){
880 var identities
= array
.map(items
, function(item
){
881 return (!item
|| lang
.isString(item
)) ? item
: tree
.model
.getIdentity(item
);
884 array
.forEach(identities
, function(id
){
885 nodes
= nodes
.concat(tree
._itemNodesMap
[id
] || []);
887 this.set('selectedNodes', nodes
);
891 _setPathAttr: function(/*Item[] || String[]*/ path
){
893 // Singular variant of _setPathsAttr
895 return this.set("paths", [path
]);
897 // Empty list is interpreted as "select nothing"
898 return this.set("paths", []);
902 _setPathsAttr: function(/*Item[][] || String[][]*/ paths
){
904 // Select the tree nodes identified by passed paths.
906 // Array of arrays of items or item id's
908 // Deferred to indicate when the set is complete
911 // We may need to wait for some nodes to expand, so setting
912 // each path will involve a Deferred. We bring those deferreds
913 // together witha DeferredList.
914 return new DeferredList(array
.map(paths
, function(path
){
915 var d
= new Deferred();
917 // normalize path to use identity
918 path
= array
.map(path
, function(item
){
919 return lang
.isString(item
) ? item
: tree
.model
.getIdentity(item
);
923 // Wait for the tree to load, if it hasn't already.
924 tree
._loadDeferred
.addCallback(function(){ selectPath(path
, [tree
.rootNode
], d
); });
926 d
.errback("Empty path");
929 })).addCallback(setNodes
);
931 function selectPath(path
, nodes
, def
){
932 // Traverse path; the next path component should be among "nodes".
933 var nextPath
= path
.shift();
934 var nextNode
= array
.filter(nodes
, function(node
){
935 return node
.getIdentity() == nextPath
;
939 tree
._expandNode(nextNode
).addCallback(function(){ selectPath(path
, nextNode
.getChildren(), def
); });
941 //Successfully reached the end of this path
942 def
.callback(nextNode
);
945 def
.errback("Could not expand path at " + nextPath
);
949 function setNodes(newNodes
){
950 //After all expansion is finished, set the selection to
951 //the set of nodes successfully found.
952 tree
.set("selectedNodes", array
.map(
953 array
.filter(newNodes
,function(x
){return x
[0];}),
954 function(x
){return x
[1];}));
958 _setSelectedNodeAttr: function(node
){
959 this.set('selectedNodes', [node
]);
961 _setSelectedNodesAttr: function(nodes
){
962 this._loadDeferred
.addCallback( lang
.hitch(this, function(){
963 this.dndController
.setSelection(nodes
);
968 ////////////// Data store related functions //////////////////////
969 // These just get passed to the model; they are here for back-compat
971 mayHaveChildren: function(/*dojo.data.Item*/ /*===== item =====*/){
973 // Deprecated. This should be specified on the model itself.
975 // Overridable function to tell if an item has or may have children.
976 // Controls whether or not +/- expando icon is shown.
977 // (For efficiency reasons we may not want to check if an element actually
978 // has children until user clicks the expando node)
983 getItemChildren: function(/*===== parentItem, onComplete =====*/){
985 // Deprecated. This should be specified on the model itself.
987 // Overridable function that return array of child items of given parent item,
988 // or if parentItem==null then return top items in tree
993 ///////////////////////////////////////////////////////
994 // Functions for converting an item to a TreeNode
995 getLabel: function(/*dojo.data.Item*/ item
){
997 // Overridable function to get the label for a tree node (given the item)
1000 return this.model
.getLabel(item
); // String
1003 getIconClass: function(/*dojo.data.Item*/ item
, /*Boolean*/ opened
){
1005 // Overridable function to return CSS class name to display icon
1008 return (!item
|| this.model
.mayHaveChildren(item
)) ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "dijitLeaf"
1011 getLabelClass: function(/*===== item, opened =====*/){
1013 // Overridable function to return CSS class name to display label
1014 // item: dojo.data.Item
1022 getRowClass: function(/*===== item, opened =====*/){
1024 // Overridable function to return CSS class name to display row
1025 // item: dojo.data.Item
1033 getIconStyle: function(/*===== item, opened =====*/){
1035 // Overridable function to return CSS styles to display icon
1036 // item: dojo.data.Item
1039 // Object suitable for input to dojo.style() like {backgroundImage: "url(...)"}
1044 getLabelStyle: function(/*===== item, opened =====*/){
1046 // Overridable function to return CSS styles to display label
1047 // item: dojo.data.Item
1050 // Object suitable for input to dojo.style() like {color: "red", background: "green"}
1055 getRowStyle: function(/*===== item, opened =====*/){
1057 // Overridable function to return CSS styles to display row
1058 // item: dojo.data.Item
1061 // Object suitable for input to dojo.style() like {background-color: "#bbb"}
1066 getTooltip: function(/*dojo.data.Item*/ /*===== item =====*/){
1068 // Overridable function to get the tooltip for a tree node (given the item)
1071 return ""; // String
1074 /////////// Keyboard and Mouse handlers ////////////////////
1076 _onKeyPress: function(/*Event*/ e
){
1078 // Translates keypress events into commands for the controller
1079 if(e
.altKey
){ return; }
1080 var treeNode
= registry
.getEnclosingWidget(e
.target
);
1081 if(!treeNode
){ return; }
1083 var key
= e
.charOrCode
;
1084 if(typeof key
== "string" && key
!= " "){ // handle printables (letter navigation)
1085 // Check for key navigation.
1086 if(!e
.altKey
&& !e
.ctrlKey
&& !e
.shiftKey
&& !e
.metaKey
){
1087 this._onLetterKeyNav( { node
: treeNode
, key
: key
.toLowerCase() } );
1090 }else{ // handle non-printables (arrow keys)
1091 // clear record of recent printables (being saved for multi-char letter navigation),
1092 // because "a", down-arrow, "b" shouldn't search for "ab"
1093 if(this._curSearch
){
1094 clearTimeout(this._curSearch
.timer
);
1095 delete this._curSearch
;
1098 var map
= this._keyHandlerMap
;
1100 // setup table mapping keys to events
1102 map
[keys
.ENTER
]="_onEnterKey";
1103 //On WebKit based browsers, the combination ctrl-enter
1104 //does not get passed through. To allow accessible
1105 //multi-select on those browsers, the space key is
1106 //also used for selection.
1107 map
[keys
.SPACE
]= map
[" "] = "_onEnterKey";
1108 map
[this.isLeftToRight() ? keys
.LEFT_ARROW
: keys
.RIGHT_ARROW
]="_onLeftArrow";
1109 map
[this.isLeftToRight() ? keys
.RIGHT_ARROW
: keys
.LEFT_ARROW
]="_onRightArrow";
1110 map
[keys
.UP_ARROW
]="_onUpArrow";
1111 map
[keys
.DOWN_ARROW
]="_onDownArrow";
1112 map
[keys
.HOME
]="_onHomeKey";
1113 map
[keys
.END
]="_onEndKey";
1114 this._keyHandlerMap
= map
;
1116 if(this._keyHandlerMap
[key
]){
1117 this[this._keyHandlerMap
[key
]]( { node
: treeNode
, item
: treeNode
.item
, evt
: e
} );
1123 _onEnterKey: function(/*Object*/ message
){
1124 this._publish("execute", { item
: message
.item
, node
: message
.node
} );
1125 this.dndController
.userSelect(message
.node
, connect
.isCopyKey( message
.evt
), message
.evt
.shiftKey
);
1126 this.onClick(message
.item
, message
.node
, message
.evt
);
1129 _onDownArrow: function(/*Object*/ message
){
1131 // down arrow pressed; get next visible node, set focus there
1132 var node
= this._getNextNode(message
.node
);
1133 if(node
&& node
.isTreeNode
){
1134 this.focusNode(node
);
1138 _onUpArrow: function(/*Object*/ message
){
1140 // Up arrow pressed; move to previous visible node
1142 var node
= message
.node
;
1144 // if younger siblings
1145 var previousSibling
= node
.getPreviousSibling();
1146 if(previousSibling
){
1147 node
= previousSibling
;
1148 // if the previous node is expanded, dive in deep
1149 while(node
.isExpandable
&& node
.isExpanded
&& node
.hasChildren()){
1150 // move to the last child
1151 var children
= node
.getChildren();
1152 node
= children
[children
.length
-1];
1155 // if this is the first child, return the parent
1156 // unless the parent is the root of a tree with a hidden root
1157 var parent
= node
.getParent();
1158 if(!(!this.showRoot
&& parent
=== this.rootNode
)){
1163 if(node
&& node
.isTreeNode
){
1164 this.focusNode(node
);
1168 _onRightArrow: function(/*Object*/ message
){
1170 // Right arrow pressed; go to child node
1171 var node
= message
.node
;
1173 // if not expanded, expand, else move to 1st child
1174 if(node
.isExpandable
&& !node
.isExpanded
){
1175 this._expandNode(node
);
1176 }else if(node
.hasChildren()){
1177 node
= node
.getChildren()[0];
1178 if(node
&& node
.isTreeNode
){
1179 this.focusNode(node
);
1184 _onLeftArrow: function(/*Object*/ message
){
1186 // Left arrow pressed.
1187 // If not collapsed, collapse, else move to parent.
1189 var node
= message
.node
;
1191 if(node
.isExpandable
&& node
.isExpanded
){
1192 this._collapseNode(node
);
1194 var parent
= node
.getParent();
1195 if(parent
&& parent
.isTreeNode
&& !(!this.showRoot
&& parent
=== this.rootNode
)){
1196 this.focusNode(parent
);
1201 _onHomeKey: function(){
1203 // Home key pressed; get first visible node, and set focus there
1204 var node
= this._getRootOrFirstNode();
1206 this.focusNode(node
);
1210 _onEndKey: function(){
1212 // End key pressed; go to last visible node.
1214 var node
= this.rootNode
;
1215 while(node
.isExpanded
){
1216 var c
= node
.getChildren();
1217 node
= c
[c
.length
- 1];
1220 if(node
&& node
.isTreeNode
){
1221 this.focusNode(node
);
1225 // multiCharSearchDuration: Number
1226 // If multiple characters are typed where each keystroke happens within
1227 // multiCharSearchDuration of the previous keystroke,
1228 // search for nodes matching all the keystrokes.
1230 // For example, typing "ab" will search for entries starting with
1231 // "ab" unless the delay between "a" and "b" is greater than multiCharSearchDuration.
1232 multiCharSearchDuration
: 250,
1234 _onLetterKeyNav: function(message
){
1236 // Called when user presses a prinatable key; search for node starting with recently typed letters.
1238 // Like { node: TreeNode, key: 'a' } where key is the key the user pressed.
1240 // Branch depending on whether this key starts a new search, or modifies an existing search
1241 var cs
= this._curSearch
;
1243 // We are continuing a search. Ex: user has pressed 'a', and now has pressed
1244 // 'b', so we want to search for nodes starting w/"ab".
1245 cs
.pattern
= cs
.pattern
+ message
.key
;
1246 clearTimeout(cs
.timer
);
1248 // We are starting a new search
1249 cs
= this._curSearch
= {
1250 pattern
: message
.key
,
1251 startNode
: message
.node
1255 // set/reset timer to forget recent keystrokes
1257 cs
.timer
= setTimeout(function(){
1258 delete self
._curSearch
;
1259 }, this.multiCharSearchDuration
);
1261 // Navigate to TreeNode matching keystrokes [entered so far].
1262 var node
= cs
.startNode
;
1264 node
= this._getNextNode(node
);
1265 //check for last node, jump to first node if necessary
1267 node
= this._getRootOrFirstNode();
1269 }while(node
!== cs
.startNode
&& (node
.label
.toLowerCase().substr(0, cs
.pattern
.length
) != cs
.pattern
));
1270 if(node
&& node
.isTreeNode
){
1271 // no need to set focus if back where we started
1272 if(node
!== cs
.startNode
){
1273 this.focusNode(node
);
1278 isExpandoNode: function(node
, widget
){
1280 // check whether a dom node is the expandoNode for a particular TreeNode widget
1281 return dom
.isDescendant(node
, widget
.expandoNode
);
1283 _onClick: function(/*TreeNode*/ nodeWidget
, /*Event*/ e
){
1285 // Translates click events into commands for the controller to process
1287 var domElement
= e
.target
,
1288 isExpandoClick
= this.isExpandoNode(domElement
, nodeWidget
);
1290 if( (this.openOnClick
&& nodeWidget
.isExpandable
) || isExpandoClick
){
1291 // expando node was clicked, or label of a folder node was clicked; open it
1292 if(nodeWidget
.isExpandable
){
1293 this._onExpandoClick({node
:nodeWidget
});
1296 this._publish("execute", { item
: nodeWidget
.item
, node
: nodeWidget
, evt
: e
} );
1297 this.onClick(nodeWidget
.item
, nodeWidget
, e
);
1298 this.focusNode(nodeWidget
);
1302 _onDblClick: function(/*TreeNode*/ nodeWidget
, /*Event*/ e
){
1304 // Translates double-click events into commands for the controller to process
1306 var domElement
= e
.target
,
1307 isExpandoClick
= (domElement
== nodeWidget
.expandoNode
|| domElement
== nodeWidget
.expandoNodeText
);
1309 if( (this.openOnDblClick
&& nodeWidget
.isExpandable
) ||isExpandoClick
){
1310 // expando node was clicked, or label of a folder node was clicked; open it
1311 if(nodeWidget
.isExpandable
){
1312 this._onExpandoClick({node
:nodeWidget
});
1315 this._publish("execute", { item
: nodeWidget
.item
, node
: nodeWidget
, evt
: e
} );
1316 this.onDblClick(nodeWidget
.item
, nodeWidget
, e
);
1317 this.focusNode(nodeWidget
);
1322 _onExpandoClick: function(/*Object*/ message
){
1324 // User clicked the +/- icon; expand or collapse my children.
1325 var node
= message
.node
;
1327 // If we are collapsing, we might be hiding the currently focused node.
1328 // Also, clicking the expando node might have erased focus from the current node.
1329 // For simplicity's sake just focus on the node with the expando.
1330 this.focusNode(node
);
1332 if(node
.isExpanded
){
1333 this._collapseNode(node
);
1335 this._expandNode(node
);
1339 onClick: function(/*===== item, node, evt =====*/){
1341 // Callback when a tree node is clicked
1342 // item: dojo.data.Item
1348 onDblClick: function(/*===== item, node, evt =====*/){
1350 // Callback when a tree node is double-clicked
1351 // item: dojo.data.Item
1357 onOpen: function(/*===== item, node =====*/){
1359 // Callback when a node is opened
1360 // item: dojo.data.Item
1365 onClose: function(/*===== item, node =====*/){
1367 // Callback when a node is closed
1368 // item: dojo.data.Item
1374 _getNextNode: function(node
){
1376 // Get next visible node
1378 if(node
.isExpandable
&& node
.isExpanded
&& node
.hasChildren()){
1379 // if this is an expanded node, get the first child
1380 return node
.getChildren()[0]; // _TreeNode
1382 // find a parent node with a sibling
1383 while(node
&& node
.isTreeNode
){
1384 var returnNode
= node
.getNextSibling();
1386 return returnNode
; // _TreeNode
1388 node
= node
.getParent();
1394 _getRootOrFirstNode: function(){
1396 // Get first visible node
1397 return this.showRoot
? this.rootNode
: this.rootNode
.getChildren()[0];
1400 _collapseNode: function(/*_TreeNode*/ node
){
1402 // Called when the user has requested to collapse the node
1404 if(node
._expandNodeDeferred
){
1405 delete node
._expandNodeDeferred
;
1408 if(node
.isExpandable
){
1409 if(node
.state
== "LOADING"){
1410 // ignore clicks while we are in the process of loading data
1415 this.onClose(node
.item
, node
);
1417 this._state(node
, false);
1421 _expandNode: function(/*_TreeNode*/ node
, /*Boolean?*/ recursive
){
1423 // Called when the user has requested to expand the node
1425 // Internal flag used when _expandNode() calls itself, don't set.
1427 // Deferred that fires when the node is loaded and opened and (if persist=true) all it's descendants
1428 // that were previously opened too
1430 if(node
._expandNodeDeferred
&& !recursive
){
1431 // there's already an expand in progress (or completed), so just return
1432 return node
._expandNodeDeferred
; // dojo.Deferred
1435 var model
= this.model
,
1441 // need to load all the children, and then expand
1442 node
.markProcessing();
1444 // Setup deferred to signal when the load and expand are finished.
1445 // Save that deferred in this._expandDeferred as a flag that operation is in progress.
1446 var def
= (node
._expandNodeDeferred
= new Deferred());
1452 node
.unmarkProcessing();
1454 // Display the children and also start expanding any children that were previously expanded
1455 // (if this.persist == true). The returned Deferred will fire when those expansions finish.
1456 var scid
= node
.setChildItems(items
);
1458 // Call _expandNode() again but this time it will just to do the animation (default branch).
1459 // The returned Deferred will fire when the animation completes.
1460 // TODO: seems like I can avoid recursion and just use a deferred to sequence the events?
1461 var ed
= _this
._expandNode(node
, true);
1463 // After the above two tasks (setChildItems() and recursive _expandNode()) finish,
1464 // signal that I am done.
1465 scid
.addCallback(function(){
1466 ed
.addCallback(function(){
1472 console
.error(_this
, ": error loading root children: ", err
);
1477 default: // "LOADED"
1478 // data is already loaded; just expand node
1479 def
= (node
._expandNodeDeferred
= node
.expand());
1481 this.onOpen(node
.item
, node
);
1483 this._state(node
, true);
1486 return def
; // dojo.Deferred
1489 ////////////////// Miscellaneous functions ////////////////
1491 focusNode: function(/* _tree.Node */ node
){
1493 // Focus on the specified node (which must be visible)
1497 // set focus so that the label will be voiced using screen readers
1498 focus
.focus(node
.labelNode
);
1501 _onNodeFocus: function(/*dijit._Widget*/ node
){
1503 // Called when a TreeNode gets focus, either by user clicking
1504 // it, or programatically by arrow key handling code.
1506 // It marks that the current node is the selected one, and the previously
1507 // selected node no longer is.
1509 if(node
&& node
!= this.lastFocused
){
1510 if(this.lastFocused
&& !this.lastFocused
._destroyed
){
1511 // mark that the previously focsable node is no longer focusable
1512 this.lastFocused
.setFocusable(false);
1515 // mark that the new node is the currently selected one
1516 node
.setFocusable(true);
1517 this.lastFocused
= node
;
1521 _onNodeMouseEnter: function(/*dijit._Widget*/ /*===== node =====*/){
1523 // Called when mouse is over a node (onmouseenter event),
1524 // this is monitored by the DND code
1527 _onNodeMouseLeave: function(/*dijit._Widget*/ /*===== node =====*/){
1529 // Called when mouse leaves a node (onmouseleave event),
1530 // this is monitored by the DND code
1533 //////////////// Events from the model //////////////////////////
1535 _onItemChange: function(/*Item*/ item
){
1537 // Processes notification of a change to an item's scalar values like label
1538 var model
= this.model
,
1539 identity
= model
.getIdentity(item
),
1540 nodes
= this._itemNodesMap
[identity
];
1543 var label
= this.getLabel(item
),
1544 tooltip
= this.getTooltip(item
);
1545 array
.forEach(nodes
, function(node
){
1547 item
: item
, // theoretically could be new JS Object representing same item
1551 node
._updateItemClasses(item
);
1556 _onItemChildrenChange: function(/*dojo.data.Item*/ parent
, /*dojo.data.Item[]*/ newChildrenList
){
1558 // Processes notification of a change to an item's children
1559 var model
= this.model
,
1560 identity
= model
.getIdentity(parent
),
1561 parentNodes
= this._itemNodesMap
[identity
];
1564 array
.forEach(parentNodes
,function(parentNode
){
1565 parentNode
.setChildItems(newChildrenList
);
1570 _onItemDelete: function(/*Item*/ item
){
1572 // Processes notification of a deletion of an item
1573 var model
= this.model
,
1574 identity
= model
.getIdentity(item
),
1575 nodes
= this._itemNodesMap
[identity
];
1578 array
.forEach(nodes
,function(node
){
1579 // Remove node from set of selected nodes (if it's selected)
1580 this.dndController
.removeTreeNode(node
);
1582 var parent
= node
.getParent();
1584 // if node has not already been orphaned from a _onSetItem(parent, "children", ..) call...
1585 parent
.removeChild(node
);
1587 node
.destroyRecursive();
1589 delete this._itemNodesMap
[identity
];
1593 /////////////// Miscellaneous funcs
1595 _initState: function(){
1597 // Load in which nodes should be opened automatically
1598 this._openedNodes
= {};
1599 if(this.persist
&& this.cookieName
){
1600 var oreo
= cookie(this.cookieName
);
1602 array
.forEach(oreo
.split(','), function(item
){
1603 this._openedNodes
[item
] = true;
1608 _state: function(node
, expanded
){
1610 // Query or set expanded state for an node
1614 var path
= array
.map(node
.getTreePath(), function(item
){
1615 return this.model
.getIdentity(item
);
1617 if(arguments
.length
=== 1){
1618 return this._openedNodes
[path
];
1621 this._openedNodes
[path
] = true;
1623 delete this._openedNodes
[path
];
1626 for(var id
in this._openedNodes
){
1629 cookie(this.cookieName
, ary
.join(","), {expires
:365});
1633 destroy: function(){
1634 if(this._curSearch
){
1635 clearTimeout(this._curSearch
.timer
);
1636 delete this._curSearch
;
1639 this.rootNode
.destroyRecursive();
1641 if(this.dndController
&& !lang
.isString(this.dndController
)){
1642 this.dndController
.destroy();
1644 this.rootNode
= null;
1645 this.inherited(arguments
);
1648 destroyRecursive: function(){
1649 // A tree is treated as a leaf, not as a node with children (like a grid),
1650 // but defining destroyRecursive for back-compat.
1654 resize: function(changeSize
){
1656 domGeometry
.setMarginBox(this.domNode
, changeSize
);
1659 // The only JS sizing involved w/tree is the indentation, which is specified
1660 // in CSS and read in through this dummy indentDetector node (tree must be
1661 // visible and attached to the DOM to read this)
1662 this._nodePixelIndent
= domGeometry
.position(this.tree
.indentDetector
).w
;
1664 if(this.tree
.rootNode
){
1665 // If tree has already loaded, then reset indent for all the nodes
1666 this.tree
.rootNode
.set('indent', this.showRoot
? 0 : -1);
1670 _createTreeNode: function(/*Object*/ args
){
1672 // creates a TreeNode
1674 // Developers can override this method to define their own TreeNode class;
1675 // However it will probably be removed in a future release in favor of a way
1676 // of just specifying a widget for the label, rather than one that contains
1677 // the children too.
1678 return new TreeNode(args
);
1681 _setTextDirAttr: function(textDir
){
1682 if(textDir
&& this.textDir
!= textDir
){
1683 this._set("textDir",textDir
);
1684 this.rootNode
.set("textDir", textDir
);
1689 Tree
._TreeNode
= TreeNode
; // for monkey patching