Subversion Repositories Applications.papyrus

Rev

Rev 1318 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
1422 alexandre_ 11
 
12
 
1318 alexandre_ 13
dojo.provide("dojo.dnd.HtmlDragCopy");
14
dojo.require("dojo.dnd.*");
15
dojo.declare("dojo.dnd.HtmlDragCopySource", dojo.dnd.HtmlDragSource, function (node, type, copyOnce) {
16
	this.copyOnce = copyOnce;
17
	this.makeCopy = true;
18
}, {onDragStart:function () {
19
	var dragObj = new dojo.dnd.HtmlDragCopyObject(this.dragObject, this.type, this);
20
	if (this.dragClass) {
21
		dragObj.dragClass = this.dragClass;
22
	}
23
	if (this.constrainToContainer) {
24
		dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
25
	}
26
	return dragObj;
27
}, onSelected:function () {
28
	for (var i = 0; i < this.dragObjects.length; i++) {
29
		dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragCopySource(this.dragObjects[i]));
30
	}
31
}});
32
dojo.declare("dojo.dnd.HtmlDragCopyObject", dojo.dnd.HtmlDragObject, function (dragObject, type, source) {
33
	this.copySource = source;
34
}, {onDragStart:function (e) {
35
	dojo.dnd.HtmlDragCopyObject.superclass.onDragStart.apply(this, arguments);
36
	if (this.copySource.makeCopy) {
37
		this.sourceNode = this.domNode;
38
		this.domNode = this.domNode.cloneNode(true);
39
	}
40
}, onDragEnd:function (e) {
41
	switch (e.dragStatus) {
42
	  case "dropFailure":
43
		var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
44
		var endCoords = {left:this.dragStartPosition.x + 1, top:this.dragStartPosition.y + 1};
45
		var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 500, dojo.lfx.easeOut);
46
		var dragObject = this;
47
		dojo.event.connect(anim, "onEnd", function (e) {
48
			dojo.lang.setTimeout(function () {
49
				dojo.html.removeNode(dragObject.dragClone);
50
				dragObject.dragClone = null;
51
				if (dragObject.copySource.makeCopy) {
52
					dojo.html.removeNode(dragObject.domNode);
53
					dragObject.domNode = dragObject.sourceNode;
54
					dragObject.sourceNode = null;
55
				}
56
			}, 200);
57
		});
58
		anim.play();
59
		dojo.event.topic.publish("dragEnd", {source:this});
60
		return;
61
	}
62
	dojo.dnd.HtmlDragCopyObject.superclass.onDragEnd.apply(this, arguments);
63
	this.copySource.dragObject = this.domNode;
64
	if (this.copySource.copyOnce) {
65
		this.copySource.makeCopy = false;
66
	}
67
	new dojo.dnd.HtmlDragCopySource(this.sourceNode, this.type, this.copySource.copyOnce);
68
	this.sourceNode = null;
69
}});
70