1 define("dijit/tree/_dndContainer", [
2 "dojo/aspect", // aspect.after
3 "dojo/_base/declare", // declare
4 "dojo/dom-class", // domClass.add domClass.remove domClass.replace
5 "dojo/_base/event", // event.stop
6 "dojo/_base/lang", // lang.getObject lang.mixin lang.hitch
7 "dojo/mouse", // mouse.enter, mouse.leave
9 ], function(aspect, declare, domClass, event, lang, mouse, on){
12 // dijit/tree/_dndContainer
14 // This is a base class for `dijit.tree._dndSelector`, and isn't meant to be used directly.
15 // It's modeled after `dojo.dnd.Container`.
17 return declare("dijit.tree._dndContainer", null, {
20 // This is a base class for `dijit.tree._dndSelector`, and isn't meant to be used directly.
21 // It's modeled after `dojo.dnd.Container`.
27 // The currently hovered TreeNode.rowNode (which is the DOM node
28 // associated w/a given node in the tree, excluding it's descendants)
32 constructor: function(tree, params){
34 // A constructor of the Container
36 // Node or node's id to build the container on
37 // params: dijit.tree.__SourceArgs
38 // A dict of parameters, which gets mixed into the object
42 this.node = tree.domNode; // TODO: rename; it's not a TreeNode but the whole Tree
43 lang.mixin(this, params);
45 // class-specific variables
46 this.current = null; // current TreeNode's DOM node
49 this.containerState = "";
50 domClass.add(this.node, "dojoDndContainer");
54 // container level events
55 on(this.node, mouse.enter, lang.hitch(this, "onOverEvent")),
56 on(this.node, mouse.leave, lang.hitch(this, "onOutEvent")),
58 // switching between TreeNodes
59 aspect.after(this.tree, "_onNodeMouseEnter", lang.hitch(this, "onMouseOver"), true),
60 aspect.after(this.tree, "_onNodeMouseLeave", lang.hitch(this, "onMouseOut"), true),
62 // cancel text selection and text dragging
63 on(this.node, "dragstart", lang.hitch(event, "stop")),
64 on(this.node, "selectstart", lang.hitch(event, "stop"))
70 // Prepares this object to be garbage-collected
73 while(h = this.events.pop()){ h.remove(); }
76 this.node = this.parent = null;
80 onMouseOver: function(widget /*===== , evt =====*/){
82 // Called when mouse is moved over a TreeNode
87 this.current = widget;
90 onMouseOut: function(/*===== widget, evt =====*/){
92 // Called when mouse is moved away from a TreeNode
100 _changeState: function(type, newState){
102 // Changes a named state to new state value
104 // A name of the state to change
107 var prefix = "dojoDnd" + type;
108 var state = type.toLowerCase() + "State";
109 //domClass.replace(this.node, prefix + newState, prefix + this[state]);
110 domClass.replace(this.node, prefix + newState, prefix + this[state]);
111 this[state] = newState;
114 _addItemClass: function(node, type){
116 // Adds a class with prefix "dojoDndItem"
120 // A variable suffix for a class name
121 domClass.add(node, "dojoDndItem" + type);
124 _removeItemClass: function(node, type){
126 // Removes a class with prefix "dojoDndItem"
130 // A variable suffix for a class name
131 domClass.remove(node, "dojoDndItem" + type);
134 onOverEvent: function(){
136 // This function is called once, when mouse is over our container
139 this._changeState("Container", "Over");
142 onOutEvent: function(){
144 // This function is called once, when mouse is out of our container
147 this._changeState("Container", "");