/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/draggable/draggable_test_helpers.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/draggable/draggable_test_helpers.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 2573 byte(s)
initial import
1 TestHelpers.draggable = {
2 // TODO: remove the unreliable offset hacks
3 unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
4 // Support: Opera 12.10, Safari 5.1, jQuery <1.8
5 unreliableContains: (function(){
6 var element = $( "<div>" );
7 return $.contains( element[ 0 ].ownerDocument, element[ 0 ] );
8 })(),
9 testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
10 var offsetAfter, actual, expected,
11 offsetBefore = el.offset();
12
13 $( handle ).simulate( "drag", {
14 dx: dx,
15 dy: dy
16 });
17 offsetAfter = el.offset();
18
19 actual = { left: offsetAfter.left, top: offsetAfter.top };
20 expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
21
22 msg = msg ? msg + "." : "";
23 deepEqual( actual, expected, "dragged[" + dx + ", " + dy + "] " + msg );
24 },
25 shouldMove: function( el, why ) {
26 TestHelpers.draggable.testDrag( el, el, 50, 50, 50, 50, why );
27 },
28 shouldNotMove: function( el, why ) {
29 TestHelpers.draggable.testDrag( el, el, 50, 50, 0, 0, why );
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 );
36 },
37 restoreScroll: function( what ) {
38 if( what ) {
39 $( document ).scrollTop( 0 ).scrollLeft( 0 );
40 } else {
41 $( "#main" ).scrollTop( 0 ).scrollLeft( 0 );
42 }
43 },
44 setScroll: function( what ) {
45 if( what ) {
46 // TODO: currently, the draggable interaction doesn't properly account for scrolled pages,
47 // uncomment the line below to make the tests fail that should when the page is scrolled
48 // $( document ).scrollTop( 100 ).scrollLeft( 100 );
49 } else {
50 $( "#main" ).scrollTop( 100 ).scrollLeft( 100 );
51 }
52 },
53 border: function( el, side ) {
54 return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0;
55 },
56 margin: function( el, side ) {
57 return parseInt( el.css( "margin-" + side ), 10 ) || 0;
58 },
59 move: function( el, x, y ) {
60 $( el ).simulate( "drag", {
61 dx: x,
62 dy: y
63 });
64 },
65 trackMouseCss : function( el ) {
66 el.bind( "drag", function() {
67 el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) );
68 });
69 },
70 trackAppendedParent : function( el ) {
71 // TODO: appendTo is currently ignored if helper is original (see #7044)
72 el.draggable( "option", "helper", "clone" );
73
74 // Get what parent is at time of drag
75 el.bind( "drag", function(e,ui) {
76 el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] );
77 });
78 }
79 };

  ViewVC Help
Powered by ViewVC 1.1.20