1 |
/* |
2 |
* selectable_events.js |
3 |
*/ |
4 |
(function( $ ) { |
5 |
|
6 |
module("selectable: events"); |
7 |
|
8 |
test( "start", function() { |
9 |
expect( 2 ); |
10 |
var el = $("#selectable1"); |
11 |
el.selectable({ |
12 |
start: function() { |
13 |
ok( true, "drag fired start callback" ); |
14 |
equal( this, el[0], "context of callback" ); |
15 |
} |
16 |
}); |
17 |
el.simulate( "drag", { |
18 |
dx: 20, |
19 |
dy: 20 |
20 |
}); |
21 |
}); |
22 |
|
23 |
test( "stop", function() { |
24 |
expect( 2 ); |
25 |
var el = $("#selectable1"); |
26 |
el.selectable({ |
27 |
start: function() { |
28 |
ok( true, "drag fired stop callback" ); |
29 |
equal( this, el[0], "context of callback" ); |
30 |
} |
31 |
}); |
32 |
el.simulate( "drag", { |
33 |
dx: 20, |
34 |
dy: 20 |
35 |
}); |
36 |
}); |
37 |
|
38 |
test( "mousedown: initial position of helper", function() { |
39 |
expect( 2 ); |
40 |
|
41 |
var helperOffset, |
42 |
element = $( "#selectable1" ).selectable(), |
43 |
contentToForceScroll = $( "<div>" ).css({ |
44 |
height: "10000px", |
45 |
width: "10000px" |
46 |
}); |
47 |
|
48 |
contentToForceScroll.appendTo( "body" ); |
49 |
$( window ).scrollTop( 100 ).scrollLeft( 100 ); |
50 |
|
51 |
element.simulate( "mousedown", { |
52 |
clientX: 10, |
53 |
clientY: 10 |
54 |
}); |
55 |
|
56 |
// we do a GTE comparison here because IE7 erroneously subtracts |
57 |
// 2 pixels from a simulated mousedown for clientX/Y |
58 |
// Support: IE7 |
59 |
helperOffset = $( ".ui-selectable-helper" ).offset(); |
60 |
ok( helperOffset.top >= 99, "Scroll top should be accounted for." ); |
61 |
ok( helperOffset.left >= 99, "Scroll left should be accounted for." ); |
62 |
|
63 |
// Cleanup |
64 |
element.simulate( "mouseup" ); |
65 |
contentToForceScroll.remove(); |
66 |
$( window ).scrollTop( 0 ).scrollLeft( 0 ); |
67 |
}); |
68 |
|
69 |
})( jQuery ); |