Opened 14 years ago

Closed 6 years ago

#5859 closed enhancement (patchwelcome)

[patch][cla] dnd patch for nested targets

Reported by: Brett Gardner Owned by: Eugene Lazutkin
Priority: low Milestone: 1.13
Component: DnD Version: 1.0
Keywords: needsreview Cc:
Blocked By: Blocking:

Description (last modified by bill)

A patch to allow nested targets in drag and drop. The nested targets can accept different source types. eg I had a setup where a Page can contain Sections. A Section can contain more Sections or Questions.

Index: dnd/Manager.js
--- dnd/Manager.js	(revision 12205)
+++ dnd/Manager.js	(working copy)
@@ -14,6 +14,9 @@ = null;
 		this.canDropFlag = false; = [];
+		this.nestedTargets = false;
+		this.sources = new dojo.NodeList();
+		this.leftSource = false;
 	// avatar's offset from the mouse
@@ -159,6 +162,17 @@
 		dojo.removeClass(dojo.body(), "dojoDnd" + (this.copy ? "Move" : "Copy"));
 		dojo.addClass(dojo.body(), "dojoDnd" + (this.copy ? "Copy" : "Move"));
+	},
+	registerSource: function(source){
+		this.sources.push(source);
+	},
+	sourceById: function(id){
+		for (var i = 0; i < this.sources.length; i++){
+			if (this.sources[i] == id){
+				return this.sources[i];
+			}
+		}
+		return null;
Index: dnd/Source.js
--- dnd/Source.js	(revision 12205)
+++ dnd/Source.js	(working copy)
@@ -78,6 +78,9 @@
 			dojo.subscribe("/dnd/drop",   this, "onDndDrop"),
 			dojo.subscribe("/dnd/cancel", this, "onDndCancel")
+		var m = dojo.dnd.manager();
+		m.registerSource(this); //nestedTargets will be set by the client after this so always register the source
 	// methods
@@ -129,6 +132,13 @@, e);
 		var m = dojo.dnd.manager();
+			if (m.leftSource){
+				m.leftSource = false;
+				m.overSource(this);
+				return;
+			}
 			// calculate before/after
 			var before = false;
@@ -210,8 +220,27 @@
 		// source: Object: the source which provides items
 		// nodes: Array: the list of transferred items
 		// copy: Boolean: copy items, if true, move items otherwise
+		var m = dojo.dnd.manager();
 		do{ //break box
 			if(this.containerState != "Over"){ break; }
+			/*If this source, contains any sources itself that have
+			their "containerState" set to "Over" then break*/
+			if (m.nestedTargets){
+				var sources = m.sources;
+				if (dojo.some(sources,function(item){
+					return Boolean(
+ !=
+					&& item.containerState == 'Over'
+					&& dojo.isDescendant(item.node,this.node)
+				);
+				},this)){
+					break;
+				}
+			}
 			var oldCreator = this._normalizedCreator;
 			if(this != source){
 				// transferring nodes from the source to the target
@@ -314,6 +343,10 @@
 	onOutEvent: function(){
 		// summary: this function is called once, when mouse is out of our container
+		var m = dojo.dnd.manager();
+		if (m.nestedTargets){
+			m.leftSource = true;
+		};

Change History (11)

comment:1 Changed 14 years ago by dylan

Milestone: 1.2
Summary: dnd patch for nested targets[patch][needs cla] dnd patch for nested targets

Who is this patch from? Do you have a CLA on file?

comment:2 Changed 14 years ago by guest

I submitted this patch

Brett Gardner [email protected]

I submitted a CLA on Feb 25 2008.

comment:3 Changed 14 years ago by bill

Summary: [patch][needs cla] dnd patch for nested targets[patch][cla] dnd patch for nested targets

comment:4 Changed 14 years ago by bill

Resolution: fixed
Status: newclosed

(In [13065]) Fixes #5859, #6186: problems with initial BorderContainer? sizing on IE. Setting the size of a node and then immediately querying the size sometimes doesn't work (plus which it's inefficient). Fixed that for IE although not for other browsers. (IE is a separate code path since it doesn't use t/l/b/r four-corners setting for styling.) !strict

comment:5 Changed 14 years ago by bill

Resolution: fixed
Status: closedreopened

Oops, above checkin fixes #5895, not this bug (#5859)

comment:6 Changed 14 years ago by guest

i try this patch for my problem, but i have an error :

t has no properties
[Break on this error] return {node: node, data:, type: t.type};

comment:7 Changed 14 years ago by guest

That patch was several iterations ago. My latest patch is here

Note, I applied this patch to the latest from the SVN repo 6 weeks ago so it may need some tweaking again.

comment:8 Changed 13 years ago by Eugene Lazutkin

Milestone: 1.2future

Moving all open ticketd to the future.

comment:9 Changed 10 years ago by ben hockey

Description: modified (diff)
Keywords: needsreview added
Priority: highlow

i'm trying to identify stale tickets. if there is a need to keep this ticket open, please replace the "needsreview" keyword with "reviewed". if there is no need to keep this ticket open then please close it.

comment:10 Changed 10 years ago by bill

Description: modified (diff)
Reporter: changed from guest to Brett Gardner

Unfortunately the link doesn't work anymore. Our fault because we erased the forums.

Kris checked in something in [28150] to allow nested div's in sources, so that the draggable items don't need to be direct children of the top level node, but this patch with it's registerSource() method seems different.

Whether or not we want this feature though is another question.

comment:11 Changed 6 years ago by dylan

Milestone: future1.12
Resolution: patchwelcome
Status: reopenedclosed

Given that we addressed most of this 4 years ago, I'm closing as patchwelcome if further additions should be made.

Note: See TracTickets for help on using tickets.