2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* selectable_events.js
|
|
|
|
*/
|
2012-12-09 02:27:37 +00:00
|
|
|
(function( $ ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
|
|
|
module("selectable: events");
|
|
|
|
|
2012-12-09 02:27:37 +00:00
|
|
|
test( "start", function() {
|
|
|
|
expect( 2 );
|
2012-10-31 01:50:08 +00:00
|
|
|
var el = $("#selectable1");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable({
|
2012-10-23 14:36:42 +00:00
|
|
|
start: function() {
|
2012-12-09 02:27:37 +00:00
|
|
|
ok( true, "drag fired start callback" );
|
|
|
|
equal( this, el[0], "context of callback" );
|
2009-02-04 04:53:09 +00:00
|
|
|
}
|
|
|
|
});
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
2012-12-09 02:27:37 +00:00
|
|
|
test( "stop", function() {
|
|
|
|
expect( 2 );
|
2012-10-31 01:50:08 +00:00
|
|
|
var el = $("#selectable1");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable({
|
2012-10-23 14:36:42 +00:00
|
|
|
start: function() {
|
2012-12-09 02:27:37 +00:00
|
|
|
ok( true, "drag fired stop callback" );
|
|
|
|
equal( this, el[0], "context of callback" );
|
2009-02-04 04:53:09 +00:00
|
|
|
}
|
|
|
|
});
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2012-12-29 03:17:50 +00:00
|
|
|
test( "mousedown: initial position of helper", function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
var helperOffset,
|
|
|
|
element = $( "#selectable1" ).selectable(),
|
|
|
|
contentToForceScroll = $( "<div>" ).css({
|
|
|
|
height: "10000px",
|
|
|
|
width: "10000px"
|
|
|
|
});
|
2012-12-29 03:17:50 +00:00
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
contentToForceScroll.appendTo( "body" );
|
|
|
|
$( window ).scrollTop( 100 ).scrollLeft( 100 );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
|
|
|
element.simulate( "mousedown", {
|
|
|
|
clientX: 10,
|
|
|
|
clientY: 10
|
|
|
|
});
|
|
|
|
|
2013-03-31 15:49:54 +00:00
|
|
|
// we do a GTE comparison here because IE7 erroneously subtracts
|
|
|
|
// 2 pixels from a simulated mousedown for clientX/Y
|
|
|
|
// Support: IE7
|
|
|
|
helperOffset = $( ".ui-selectable-helper" ).offset();
|
|
|
|
ok( helperOffset.top >= 99, "Scroll top should be accounted for." );
|
|
|
|
ok( helperOffset.left >= 99, "Scroll left should be accounted for." );
|
2012-12-29 03:17:50 +00:00
|
|
|
|
|
|
|
// Cleanup
|
2013-03-31 15:49:54 +00:00
|
|
|
element.simulate( "mouseup" );
|
2012-12-29 03:17:50 +00:00
|
|
|
contentToForceScroll.remove();
|
|
|
|
$( window ).scrollTop( 0 ).scrollLeft( 0 );
|
|
|
|
});
|
|
|
|
|
2012-12-09 02:27:37 +00:00
|
|
|
})( jQuery );
|