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.HtmlDragMove");
|
|
|
14 |
dojo.require("dojo.dnd.*");
|
|
|
15 |
dojo.declare("dojo.dnd.HtmlDragMoveSource", dojo.dnd.HtmlDragSource, {onDragStart:function () {
|
|
|
16 |
var dragObj = new dojo.dnd.HtmlDragMoveObject(this.dragObject, this.type);
|
|
|
17 |
if (this.constrainToContainer) {
|
|
|
18 |
dragObj.constrainTo(this.constrainingContainer);
|
|
|
19 |
}
|
|
|
20 |
return dragObj;
|
|
|
21 |
}, onSelected:function () {
|
|
|
22 |
for (var i = 0; i < this.dragObjects.length; i++) {
|
|
|
23 |
dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragMoveSource(this.dragObjects[i]));
|
|
|
24 |
}
|
|
|
25 |
}});
|
|
|
26 |
dojo.declare("dojo.dnd.HtmlDragMoveObject", dojo.dnd.HtmlDragObject, {onDragStart:function (e) {
|
|
|
27 |
dojo.html.clearSelection();
|
|
|
28 |
this.dragClone = this.domNode;
|
|
|
29 |
if (dojo.html.getComputedStyle(this.domNode, "position") != "absolute") {
|
|
|
30 |
this.domNode.style.position = "relative";
|
|
|
31 |
}
|
|
|
32 |
var left = parseInt(dojo.html.getComputedStyle(this.domNode, "left"));
|
|
|
33 |
var top = parseInt(dojo.html.getComputedStyle(this.domNode, "top"));
|
|
|
34 |
this.dragStartPosition = {x:isNaN(left) ? 0 : left, y:isNaN(top) ? 0 : top};
|
|
|
35 |
this.scrollOffset = dojo.html.getScroll().offset;
|
|
|
36 |
this.dragOffset = {y:this.dragStartPosition.y - e.pageY, x:this.dragStartPosition.x - e.pageX};
|
|
|
37 |
this.containingBlockPosition = {x:0, y:0};
|
|
|
38 |
if (this.constrainToContainer) {
|
|
|
39 |
this.constraints = this.getConstraints();
|
|
|
40 |
}
|
|
|
41 |
dojo.event.connect(this.domNode, "onclick", this, "_squelchOnClick");
|
|
|
42 |
}, onDragEnd:function (e) {
|
|
|
43 |
}, setAbsolutePosition:function (x, y) {
|
|
|
44 |
if (!this.disableY) {
|
|
|
45 |
this.domNode.style.top = y + "px";
|
|
|
46 |
}
|
|
|
47 |
if (!this.disableX) {
|
|
|
48 |
this.domNode.style.left = x + "px";
|
|
|
49 |
}
|
|
|
50 |
}, _squelchOnClick:function (e) {
|
|
|
51 |
dojo.event.browser.stopEvent(e);
|
|
|
52 |
dojo.event.disconnect(this.domNode, "onclick", this, "_squelchOnClick");
|
|
|
53 |
}});
|
|
|
54 |
|