1
1
TestHelpers . draggable = {
2
- // todo : remove the unreliable offset hacks
2
+ // TODO : remove the unreliable offset hacks
3
3
unreliableOffset : $ . ui . ie && ( ! document . documentMode || document . documentMode < 8 ) ? 2 : 0 ,
4
4
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
5
5
unreliableContains : function ( ) {
6
6
var element = $ ( "<div>" ) ;
7
7
return $ . contains ( element [ 0 ] . ownerDocument , element [ 0 ] ) ;
8
8
} ( ) ,
9
- testDrag : function ( el , handle , dx , dy , expectedDX , expectedDY , msg ) {
9
+ testDrag : function ( el , handle , dx , dy , expectedDX , expectedDY , msg ) {
10
10
var offsetAfter , actual , expected ,
11
11
offsetBefore = el . offset ( ) ;
12
12
@@ -20,64 +20,60 @@ TestHelpers.draggable = {
20
20
expected = { left : offsetBefore . left + expectedDX , top : offsetBefore . top + expectedDY } ;
21
21
22
22
msg = msg ? msg + "." : "" ;
23
- deepEqual ( actual , expected , "dragged[" + dx + ", " + dy + "] " + msg ) ;
23
+ deepEqual ( actual , expected , "dragged[" + dx + ", " + dy + "] " + msg ) ;
24
24
} ,
25
- shouldMove : function ( el , why ) {
26
- TestHelpers . draggable . testDrag ( el , el , 50 , 50 , 50 , 50 , why ) ;
25
+ shouldMove : function ( el , why ) {
26
+ TestHelpers . draggable . testDrag ( el , el , 50 , 50 , 50 , 50 , why ) ;
27
27
} ,
28
- shouldNotMove : function ( el , why ) {
29
- TestHelpers . draggable . testDrag ( el , el , 50 , 50 , 0 , 0 , why ) ;
28
+ shouldNotMove : function ( el , why ) {
29
+ TestHelpers . draggable . testDrag ( el , el , 50 , 50 , 0 , 0 , why ) ;
30
30
} ,
31
- testScroll : function ( el , position ) {
32
- var oldPosition = $ ( "#main" ) . css ( "position" ) ;
33
- $ ( "#main" ) . css ( "position" , position ) ;
34
- TestHelpers . draggable . shouldMove ( el , position + " parent" ) ;
35
- $ ( "#main" ) . css ( "position" , oldPosition ) ;
31
+ testScroll : function ( el , position ) {
32
+ var oldPosition = $ ( "#main" ) . css ( "position" ) ;
33
+ $ ( "#main" ) . css ( "position" , position ) ;
34
+ TestHelpers . draggable . shouldMove ( el , position + " parent" ) ;
35
+ $ ( "#main" ) . css ( "position" , oldPosition ) ;
36
36
} ,
37
37
restoreScroll : function ( what ) {
38
38
if ( what ) {
39
- $ ( document ) . scrollTop ( 0 ) ; $ ( document ) . scrollLeft ( 0 ) ;
39
+ $ ( document ) . scrollTop ( 0 ) . scrollLeft ( 0 ) ;
40
40
} else {
41
- $ ( "#main" ) . scrollTop ( 0 ) ; $ ( "#main" ) . scrollLeft ( 0 ) ;
41
+ $ ( "#main" ) . scrollTop ( 0 ) . scrollLeft ( 0 ) ;
42
42
}
43
43
} ,
44
44
setScroll : function ( what ) {
45
- if ( what ) {
46
- // todo : currently, the draggable interaction doesn't properly account for scrolled pages,
45
+ if ( what ) {
46
+ // TODO : currently, the draggable interaction doesn't properly account for scrolled pages,
47
47
// uncomment the line below to make the tests fail that should when the page is scrolled
48
- // $(document).scrollTop(100); $(document ).scrollLeft(100);
48
+ // $( document ).scrollTop( 100 ).scrollLeft( 100 );
49
49
} else {
50
- $ ( "#main" ) . scrollTop ( 100 ) ; $ ( "#main" ) . scrollLeft ( 100 ) ;
50
+ $ ( "#main" ) . scrollTop ( 100 ) . scrollLeft ( 100 ) ;
51
51
}
52
52
} ,
53
- border : function ( el , side ) {
54
- return parseInt ( el . css ( "border-" + side + "-width" ) , 10 ) || 0 ;
53
+ border : function ( el , side ) {
54
+ return parseInt ( el . css ( "border-" + side + "-width" ) , 10 ) || 0 ;
55
55
} ,
56
- margin : function ( el , side ) {
57
- return parseInt ( el . css ( "margin-" + side ) , 10 ) || 0 ;
56
+ margin : function ( el , side ) {
57
+ return parseInt ( el . css ( "margin-" + side ) , 10 ) || 0 ;
58
58
} ,
59
59
move : function ( el , x , y ) {
60
-
61
60
$ ( el ) . simulate ( "drag" , {
62
61
dx : x ,
63
62
dy : y
64
63
} ) ;
65
-
66
64
} ,
67
65
trackMouseCss : function ( el ) {
68
66
el . bind ( "drag" , function ( ) {
69
- el . data ( "last_dragged_cursor" , $ ( "body" ) . css ( "cursor" ) ) ;
67
+ el . data ( "last_dragged_cursor" , $ ( "body" ) . css ( "cursor" ) ) ;
70
68
} ) ;
71
69
} ,
72
70
trackAppendedParent : function ( el ) {
73
-
74
- // appendTo ignored without being clone
71
+ // TODO: appendTo is currently ignored if helper is original (see #7044)
75
72
el . draggable ( "option" , "helper" , "clone" ) ;
76
73
74
+ // Get what parent is at time of drag
77
75
el . bind ( "drag" , function ( e , ui ) {
78
- // Get what parent is at time of drag
79
- el . data ( "last_dragged_parent" , ui . helper . parent ( ) [ 0 ] ) ;
76
+ el . data ( "last_dragged_parent" , ui . helper . parent ( ) [ 0 ] ) ;
80
77
} ) ;
81
-
82
78
}
83
79
} ;
0 commit comments