Ticket #5859 (reopened enhancement)

Opened 9 months ago

Last modified 3 months ago

[patch][cla] dnd patch for nested targets

Reported by: guest Owned by: elazutkin
Priority: normal Milestone: future
Component: DnD Version: 1.0
Severity: normal Keywords:
Cc:

Description

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 @@

this.target = null; this.canDropFlag = false; this.events = [];

+ this.nestedTargets = false; + this.sources = new dojo.NodeList?(); + this.leftSource = false;

},

// avatar's offset from the mouse

@@ -159,6 +162,17 @@

this.updateAvatar(); 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].node.id == 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 @@

dojo.dnd.Source.superclass.onMouseMove.call(this, e); var m = dojo.dnd.manager(); if(this.isDragging){

+ + if (m.leftSource){ + m.leftSource = false; + m.overSource(this); + return; + } +

// calculate before/after var before = false; if(this.current){

@@ -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.node.id != this.node.id + && 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; + }

dojo.dnd.Source.superclass.onOutEvent.call(this); dojo.dnd.manager().outSource(this);

},

Change History

Changed 9 months ago by dylan

  • summary changed from dnd patch for nested targets to [patch][needs cla] dnd patch for nested targets
  • milestone set to 1.2

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

Changed 9 months ago by guest

I submitted this patch

Brett Gardner brett@…

I submitted a CLA on Feb 25 2008.

Changed 9 months ago by bill

  • summary changed from [patch][needs cla] dnd patch for nested targets to [patch][cla] dnd patch for nested targets

Changed 8 months ago by bill

  • status changed from new to closed
  • resolution set to fixed

(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

Changed 8 months ago by bill

  • status changed from closed to reopened
  • resolution deleted

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

Changed 6 months ago by guest

http://www.dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/dnd-source-dnd-source

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

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

Changed 6 months ago by guest

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

http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-development-discussion/dnd-nested-targets-patch

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

Changed 3 months ago by elazutkin

  • milestone changed from 1.2 to future

Moving all open ticketd to the future.

Note: See TracTickets for help on using tickets.