]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/move.js.uncompressed.js
1 define("dojo/dnd/move", ["../main", "./Mover", "./Moveable"], function(dojo
) {
9 dojo.declare("dojo.dnd.move.__constrainedMoveableArgs", [dojo.dnd.__MoveableArgs], {
10 // constraints: Function
11 // Calculates a constraint box.
12 // It is called in a context of the moveable object.
13 constraints: function(){},
16 // restrict move within boundaries.
21 dojo
.declare("dojo.dnd.move.constrainedMoveable", dojo
.dnd
.Moveable
, {
22 // object attributes (for markup)
23 constraints: function(){},
26 constructor: function(node
, params
){
28 // an object that makes a node moveable
30 // a node (or node's id) to be moved
31 // params: dojo.dnd.move.__constrainedMoveableArgs?
32 // an optional object with additional parameters;
33 // the rest is passed to the base class
34 if(!params
){ params
= {}; }
35 this.constraints
= params
.constraints
;
36 this.within
= params
.within
;
38 onFirstMove: function(/* dojo.dnd.Mover */ mover
){
40 // called during the very first move notification;
41 // can be used to initialize coordinates, can be overwritten.
42 var c
= this.constraintBox
= this.constraints
.call(this, mover
);
46 var mb
= dojo
._getMarginSize(mover
.node
);
51 onMove: function(/* dojo.dnd.Mover */ mover
, /* Object */ leftTop
){
53 // called during every move notification;
54 // should actually move the node; can be overwritten.
55 var c
= this.constraintBox
, s
= mover
.node
.style
;
56 this.onMoving(mover
, leftTop
);
57 leftTop
.l
= leftTop
.l
< c
.l
? c
.l
: c
.r
< leftTop
.l
? c
.r
: leftTop
.l
;
58 leftTop
.t
= leftTop
.t
< c
.t
? c
.t
: c
.b
< leftTop
.t
? c
.b
: leftTop
.t
;
59 s
.left
= leftTop
.l
+ "px";
60 s
.top
= leftTop
.t
+ "px";
61 this.onMoved(mover
, leftTop
);
66 dojo.declare("dojo.dnd.move.__boxConstrainedMoveableArgs", [dojo.dnd.move.__constrainedMoveableArgs], {
73 dojo
.declare("dojo.dnd.move.boxConstrainedMoveable", dojo
.dnd
.move.constrainedMoveable
, {
75 // object attributes (for markup)
78 constructor: function(node
, params
){
80 // an object, which makes a node moveable
82 // a node (or node's id) to be moved
83 // params: dojo.dnd.move.__boxConstrainedMoveableArgs?
84 // an optional object with parameters
85 var box
= params
&& params
.box
;
86 this.constraints = function(){ return box
; };
91 dojo.declare("dojo.dnd.move.__parentConstrainedMoveableArgs", [dojo.dnd.move.__constrainedMoveableArgs], {
93 // A parent's area to restrict the move.
94 // Can be "margin", "border", "padding", or "content".
99 dojo
.declare("dojo.dnd.move.parentConstrainedMoveable", dojo
.dnd
.move.constrainedMoveable
, {
101 // object attributes (for markup)
104 constructor: function(node
, params
){
106 // an object, which makes a node moveable
108 // a node (or node's id) to be moved
109 // params: dojo.dnd.move.__parentConstrainedMoveableArgs?
110 // an optional object with parameters
111 var area
= params
&& params
.area
;
112 this.constraints = function(){
113 var n
= this.node
.parentNode
,
114 s
= dojo
.getComputedStyle(n
),
115 mb
= dojo
._getMarginBox(n
, s
);
116 if(area
== "margin"){
119 var t
= dojo
._getMarginExtents(n
, s
);
120 mb
.l
+= t
.l
, mb
.t
+= t
.t
, mb
.w
-= t
.w
, mb
.h
-= t
.h
;
121 if(area
== "border"){
124 t
= dojo
._getBorderExtents(n
, s
);
125 mb
.l
+= t
.l
, mb
.t
+= t
.t
, mb
.w
-= t
.w
, mb
.h
-= t
.h
;
126 if(area
== "padding"){
129 t
= dojo
._getPadExtents(n
, s
);
130 mb
.l
+= t
.l
, mb
.t
+= t
.t
, mb
.w
-= t
.w
, mb
.h
-= t
.h
;
136 // patching functions one level up for compatibility
138 dojo
.dnd
.constrainedMover
= dojo
.dnd
.move.constrainedMover
;
139 dojo
.dnd
.boxConstrainedMover
= dojo
.dnd
.move.boxConstrainedMover
;
140 dojo
.dnd
.parentConstrainedMover
= dojo
.dnd
.move.parentConstrainedMover
;
142 return dojo
.dnd
.move;