|
|
@ -1,15 +1,19 @@
|
|
|
|
(function( $ ) {
|
|
|
|
define( [
|
|
|
|
|
|
|
|
"jquery",
|
|
|
|
module( "draggable: options" );
|
|
|
|
"./draggable_test_helpers",
|
|
|
|
|
|
|
|
"ui/draggable",
|
|
|
|
|
|
|
|
"ui/droppable",
|
|
|
|
|
|
|
|
"ui/sortable"
|
|
|
|
|
|
|
|
], function( $, draggableTestHelpers ) {
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
|
test( "{ appendTo: 'parent' }, default, no clone", function() {
|
|
|
|
test( "{ appendTo: 'parent' }, default, no clone", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: "parent" });
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: "parent" });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "absolute appendTo: parent" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "absolute appendTo: parent" );
|
|
|
|
|
|
|
|
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: "parent" });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: "parent" });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "relative appendTo: parent" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "relative appendTo: parent" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
@ -17,20 +21,20 @@ test( "{ appendTo: Element }, no clone", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "absolute appendTo: Element" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "absolute appendTo: Element" );
|
|
|
|
|
|
|
|
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "relative appendTo: Element" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "relative appendTo: Element" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
|
// TODO: This doesn't actually test whether append happened, possibly remove
|
|
|
|
test( "{ appendTo: Selector }, no clone", function() {
|
|
|
|
test( "{ appendTo: Selector }, no clone", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: "#main" });
|
|
|
|
var element = $( "#draggable2" ).draggable({ appendTo: "#main" });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "absolute appendTo: Selector" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "absolute appendTo: Selector" );
|
|
|
|
|
|
|
|
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: "#main" });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: "#main" });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "relative appendTo: Selector" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "relative appendTo: Selector" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ appendTo: 'parent' }, default", function() {
|
|
|
|
test( "{ appendTo: 'parent' }, default", function() {
|
|
|
@ -38,11 +42,11 @@ test( "{ appendTo: 'parent' }, default", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackAppendedParent( element );
|
|
|
|
draggableTestHelpers.trackAppendedParent( element );
|
|
|
|
|
|
|
|
|
|
|
|
equal( element.draggable( "option", "appendTo" ), "parent" );
|
|
|
|
equal( element.draggable( "option", "appendTo" ), "parent" );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -52,9 +56,9 @@ test( "{ appendTo: Element }", function() {
|
|
|
|
var appendTo = $( "#draggable2" ).parent()[ 0 ],
|
|
|
|
var appendTo = $( "#draggable2" ).parent()[ 0 ],
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackAppendedParent( element );
|
|
|
|
draggableTestHelpers.trackAppendedParent( element );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), appendTo );
|
|
|
|
equal( element.data( "last_dragged_parent" ), appendTo );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -64,9 +68,9 @@ test( "{ appendTo: jQuery }", function() {
|
|
|
|
var appendTo = $( "#draggable2" ).parent(),
|
|
|
|
var appendTo = $( "#draggable2" ).parent(),
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackAppendedParent( element );
|
|
|
|
draggableTestHelpers.trackAppendedParent( element );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] );
|
|
|
|
equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -76,9 +80,9 @@ test( "{ appendTo: Selector }", function() {
|
|
|
|
var appendTo = "#main",
|
|
|
|
var appendTo = "#main",
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
element = $( "#draggable1" ).draggable({ appendTo: appendTo });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackAppendedParent( element );
|
|
|
|
draggableTestHelpers.trackAppendedParent( element );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -87,34 +91,34 @@ test( "appendTo, default, switching after initialization", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable({ helper: "clone" });
|
|
|
|
var element = $( "#draggable1" ).draggable({ helper: "clone" });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackAppendedParent( element );
|
|
|
|
draggableTestHelpers.trackAppendedParent( element );
|
|
|
|
|
|
|
|
|
|
|
|
// Move and make sure element was appended to fixture
|
|
|
|
// Move and make sure element was appended to fixture
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] );
|
|
|
|
|
|
|
|
|
|
|
|
// Move and make sure element was appended to main
|
|
|
|
// Move and make sure element was appended to main
|
|
|
|
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
|
|
|
|
element.draggable( "option", "appendTo", $( "#qunit-fixture" ) );
|
|
|
|
TestHelpers.draggable.move( element, 2, 2 );
|
|
|
|
draggableTestHelpers.move( element, 2, 2 );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
|
|
|
|
equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ axis: false }, default", function() {
|
|
|
|
test( "{ axis: false }, default", function() {
|
|
|
|
expect( 2 );
|
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: false });
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: false });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "axis: false" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "axis: false" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ axis: 'x' }", function() {
|
|
|
|
test( "{ axis: 'x' }", function() {
|
|
|
|
expect( 2 );
|
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: "x" });
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: "x" });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 50, 50, 50, 0, "axis: x" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ axis: 'y' }", function() {
|
|
|
|
test( "{ axis: 'y' }", function() {
|
|
|
|
expect( 2 );
|
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: "y" });
|
|
|
|
var element = $( "#draggable2" ).draggable({ axis: "y" });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 50, 50, 0, 50, "axis: y" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ axis: ? }, unexpected", function() {
|
|
|
|
test( "{ axis: ? }, unexpected", function() {
|
|
|
@ -132,7 +136,7 @@ test( "{ axis: ? }, unexpected", function() {
|
|
|
|
|
|
|
|
|
|
|
|
$.each(unexpected, function(key, val) {
|
|
|
|
$.each(unexpected, function(key, val) {
|
|
|
|
element = $( "#draggable2" ).draggable({ axis: val });
|
|
|
|
element = $( "#draggable2" ).draggable({ axis: val });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "axis: " + key );
|
|
|
|
draggableTestHelpers.shouldMove( element, "axis: " + key );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -143,15 +147,15 @@ test( "axis, default, switching after initialization", function() {
|
|
|
|
var element = $( "#draggable1" ).draggable({ axis: false });
|
|
|
|
var element = $( "#draggable1" ).draggable({ axis: false });
|
|
|
|
|
|
|
|
|
|
|
|
// Any Direction
|
|
|
|
// Any Direction
|
|
|
|
TestHelpers.draggable.shouldMove( element, "axis: default" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "axis: default" );
|
|
|
|
|
|
|
|
|
|
|
|
// Only horizontal
|
|
|
|
// Only horizontal
|
|
|
|
element.draggable( "option", "axis", "x" );
|
|
|
|
element.draggable( "option", "axis", "x" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" );
|
|
|
|
|
|
|
|
|
|
|
|
// Vertical only
|
|
|
|
// Vertical only
|
|
|
|
element.draggable( "option", "axis", "y" );
|
|
|
|
element.draggable( "option", "axis", "y" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" );
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -161,12 +165,12 @@ test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
|
|
|
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
|
|
|
|
$( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
|
|
|
var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "cancel: default, element dragged" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
|
|
|
|
|
|
|
|
element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
|
|
|
element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -174,12 +178,12 @@ test( "{ cancel: 'span' }", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable2" ).draggable();
|
|
|
|
var element = $( "#draggable2" ).draggable();
|
|
|
|
TestHelpers.draggable.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
|
|
|
|
|
|
|
|
element = $( "#draggable2" ).draggable({ cancel: "span" });
|
|
|
|
element = $( "#draggable2" ).draggable({ cancel: "span" });
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ cancel: ? }, unexpected", function() {
|
|
|
|
test( "{ cancel: ? }, unexpected", function() {
|
|
|
@ -197,7 +201,7 @@ test( "{ cancel: ? }, unexpected", function() {
|
|
|
|
|
|
|
|
|
|
|
|
$.each( unexpected, function( key, val ) {
|
|
|
|
$.each( unexpected, function( key, val ) {
|
|
|
|
element = $( "#draggable2" ).draggable({ cancel: val });
|
|
|
|
element = $( "#draggable2" ).draggable({ cancel: val });
|
|
|
|
TestHelpers.draggable.shouldMove( element, "cancel: " + key );
|
|
|
|
draggableTestHelpers.shouldMove( element, "cancel: " + key );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
element.draggable( "destroy" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -215,15 +219,15 @@ test( "{ cancel: Selectors }, matching parent selector", function() {
|
|
|
|
|
|
|
|
|
|
|
|
$( "#wrapping a" ).append( element );
|
|
|
|
$( "#wrapping a" ).append( element );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "drag span child", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "drag span child", "#draggable2 span" );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" );
|
|
|
|
|
|
|
|
|
|
|
|
$( "#draggable2" ).draggable( "option", "cancel", "span > a" );
|
|
|
|
$( "#draggable2" ).draggable( "option", "cancel", "span > a" );
|
|
|
|
$( "#draggable2" ).find( "a" ).append( "<a>" );
|
|
|
|
$( "#draggable2" ).find( "a" ).append( "<a>" );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() );
|
|
|
|
draggableTestHelpers.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
@ -235,13 +239,13 @@ test( "cancelement, default, switching after initialization", function() {
|
|
|
|
var input = $( "#draggable-option-cancel-default input" ),
|
|
|
|
var input = $( "#draggable-option-cancel-default input" ),
|
|
|
|
element = $( "#draggable-option-cancel-default" ).draggable();
|
|
|
|
element = $( "#draggable-option-cancel-default" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", input );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "cancel: default, input dragged", input );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "cancel", "textarea" );
|
|
|
|
element.draggable( "option", "cancel", "textarea" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "cancel: textarea, input dragged", input );
|
|
|
|
draggableTestHelpers.shouldMove( element, "cancel: textarea, input dragged", input );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "cancel", "input" );
|
|
|
|
element.draggable( "option", "cancel", "input" );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "cancel: input, input dragged", input );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "cancel: input, input dragged", input );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "connectToSortable, dragging out of a sortable", function() {
|
|
|
|
test( "connectToSortable, dragging out of a sortable", function() {
|
|
|
@ -436,8 +440,8 @@ test( "{ containment: Element }", function() {
|
|
|
|
p = element.parent(),
|
|
|
|
p = element.parent(),
|
|
|
|
po = p.offset(),
|
|
|
|
po = p.offset(),
|
|
|
|
expected = {
|
|
|
|
expected = {
|
|
|
|
left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ),
|
|
|
|
left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ),
|
|
|
|
top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" )
|
|
|
|
top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" )
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
element.simulate( "drag", {
|
|
|
|
element.simulate( "drag", {
|
|
|
@ -456,8 +460,8 @@ test( "{ containment: Selector }", function() {
|
|
|
|
p = element.parent(),
|
|
|
|
p = element.parent(),
|
|
|
|
po = p.offset(),
|
|
|
|
po = p.offset(),
|
|
|
|
expected = {
|
|
|
|
expected = {
|
|
|
|
left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ),
|
|
|
|
left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ),
|
|
|
|
top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" )
|
|
|
|
top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" )
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
element.simulate( "drag", {
|
|
|
|
element.simulate( "drag", {
|
|
|
@ -476,7 +480,7 @@ test( "{ containment: [x1, y1, x2, y2] }", function() {
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] );
|
|
|
|
element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ containment: 'parent' }, relative", function() {
|
|
|
|
test( "{ containment: 'parent' }, relative", function() {
|
|
|
@ -487,8 +491,8 @@ test( "{ containment: 'parent' }, relative", function() {
|
|
|
|
p = element.parent(),
|
|
|
|
p = element.parent(),
|
|
|
|
po = p.offset(),
|
|
|
|
po = p.offset(),
|
|
|
|
expected = {
|
|
|
|
expected = {
|
|
|
|
left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ),
|
|
|
|
left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ),
|
|
|
|
top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" )
|
|
|
|
top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" )
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
element.simulate( "drag", {
|
|
|
|
element.simulate( "drag", {
|
|
|
@ -507,8 +511,8 @@ test( "{ containment: 'parent' }, absolute", function() {
|
|
|
|
p = element.parent(),
|
|
|
|
p = element.parent(),
|
|
|
|
po = p.offset(),
|
|
|
|
po = p.offset(),
|
|
|
|
expected = {
|
|
|
|
expected = {
|
|
|
|
left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ),
|
|
|
|
left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ),
|
|
|
|
top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" )
|
|
|
|
top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" )
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
element.simulate( "drag", {
|
|
|
|
element.simulate( "drag", {
|
|
|
@ -531,8 +535,8 @@ test( "containment, account for border", function( assert ) {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
parentBottom = parent.offset().top + parent.outerHeight(),
|
|
|
|
parentBottom = parent.offset().top + parent.outerHeight(),
|
|
|
|
parentRight = parent.offset().left + parent.outerWidth(),
|
|
|
|
parentRight = parent.offset().left + parent.outerWidth(),
|
|
|
|
parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ),
|
|
|
|
parentBorderBottom = draggableTestHelpers.border( parent, "bottom" ),
|
|
|
|
parentBorderRight = TestHelpers.draggable.border( parent, "right" );
|
|
|
|
parentBorderRight = draggableTestHelpers.border( parent, "right" );
|
|
|
|
|
|
|
|
|
|
|
|
el.css({
|
|
|
|
el.css({
|
|
|
|
height: "5px",
|
|
|
|
height: "5px",
|
|
|
@ -587,16 +591,16 @@ test( "containment, default, switching after initialization", function() {
|
|
|
|
po = element.parent().offset(),
|
|
|
|
po = element.parent().offset(),
|
|
|
|
containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ];
|
|
|
|
containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ];
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 });
|
|
|
|
element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "containment", containment ).css({ top: 0, left: 0 });
|
|
|
|
element.draggable( "option", "containment", containment ).css({ top: 0, left: 0 });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "containment", false );
|
|
|
|
element.draggable( "option", "containment", false );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ cursor: 'auto' }, default", function() {
|
|
|
|
test( "{ cursor: 'auto' }, default", function() {
|
|
|
@ -674,7 +678,7 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
expected = getCursor();
|
|
|
|
expected = getCursor();
|
|
|
|
|
|
|
|
|
|
|
|
if ( TestHelpers.draggable.unreliableContains ) {
|
|
|
|
if ( draggableTestHelpers.unreliableContains ) {
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -690,17 +694,17 @@ test( "cursor, default, switching after initialization", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.trackMouseCss( element );
|
|
|
|
draggableTestHelpers.trackMouseCss( element );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "auto" );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "auto" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "cursor", "move" );
|
|
|
|
element.draggable( "option", "cursor", "move" );
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "move" );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "move" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "cursor", "ns-resize" );
|
|
|
|
element.draggable( "option", "cursor", "ns-resize" );
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "ns-resize" );
|
|
|
|
equal( element.data( "last_dragged_cursor" ), "ns-resize" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -727,11 +731,11 @@ test( "cursorAt", function() {
|
|
|
|
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
|
|
|
|
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
|
|
|
|
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
|
|
|
|
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
|
|
|
|
} else if ( testData.cursorAt.right ) {
|
|
|
|
} else if ( testData.cursorAt.right ) {
|
|
|
|
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - draggableTestHelpers.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - draggableTestHelpers.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( event.clientX - ui.offset.left, testData.x + draggableTestHelpers.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
equal( event.clientY - ui.offset.top, testData.y + draggableTestHelpers.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -769,11 +773,11 @@ test( "cursorAt, switching after initialization", function() {
|
|
|
|
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
|
|
|
|
equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" );
|
|
|
|
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
|
|
|
|
equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" );
|
|
|
|
} else if ( testData.cursorAt.right ) {
|
|
|
|
} else if ( testData.cursorAt.right ) {
|
|
|
|
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - draggableTestHelpers.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - draggableTestHelpers.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( event.clientX - ui.offset.left, testData.x + draggableTestHelpers.unreliableOffset, testName + " " + position + " left" );
|
|
|
|
equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
equal( event.clientY - ui.offset.top, testData.y + draggableTestHelpers.unreliableOffset, testName + " " + position + " top" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -795,29 +799,29 @@ test( "disabled", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "disabled: default" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "disabled: default" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "disabled", true );
|
|
|
|
element.draggable( "option", "disabled", true );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "option: disabled true" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "option: disabled true" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "disabled", false );
|
|
|
|
element.draggable( "option", "disabled", false );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "option: disabled false" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "option: disabled false" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ grid: [50, 50] }, relative", function() {
|
|
|
|
test( "{ grid: [50, 50] }, relative", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] });
|
|
|
|
var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ grid: [50, 50] }, absolute", function() {
|
|
|
|
test( "{ grid: [50, 50] }, absolute", function() {
|
|
|
|
expect( 4 );
|
|
|
|
expect( 4 );
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] });
|
|
|
|
var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] });
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "grid, switching after initialization", function() {
|
|
|
|
test( "grid, switching after initialization", function() {
|
|
|
@ -826,13 +830,13 @@ test( "grid, switching after initialization", function() {
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
// Forward
|
|
|
|
// Forward
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24, "grid: default" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 24, 24, 24, 24, "grid: default" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0, "grid: default" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 0, 0, 0, 0, "grid: default" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "grid", [ 50, 50 ] );
|
|
|
|
element.draggable( "option", "grid", [ 50, 50 ] );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" );
|
|
|
|
TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
|
|
|
|
draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "{ handle: 'span' }", function() {
|
|
|
|
test( "{ handle: 'span' }", function() {
|
|
|
@ -840,9 +844,9 @@ test( "{ handle: 'span' }", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable2" ).draggable({ handle: "span" });
|
|
|
|
var element = $( "#draggable2" ).draggable({ handle: "span" });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: span", "#draggable2 span");
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: span", "#draggable2 span");
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: span child", "#draggable2 span em" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: span child", "#draggable2 span em" );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "handle: span element" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "handle: span element" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "handle, default, switching after initialization", function() {
|
|
|
|
test( "handle, default, switching after initialization", function() {
|
|
|
@ -850,31 +854,31 @@ test( "handle, default, switching after initialization", function() {
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable2" ).draggable();
|
|
|
|
var element = $( "#draggable2" ).draggable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: default, element dragged" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: default, element dragged" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: default, span dragged", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: default, span dragged", "#draggable2 span" );
|
|
|
|
|
|
|
|
|
|
|
|
// Switch
|
|
|
|
// Switch
|
|
|
|
element.draggable( "option", "handle", "span" );
|
|
|
|
element.draggable( "option", "handle", "span" );
|
|
|
|
TestHelpers.draggable.shouldNotDrag( element, "handle: span as option, element dragged" );
|
|
|
|
draggableTestHelpers.shouldNotDrag( element, "handle: span as option, element dragged" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" );
|
|
|
|
|
|
|
|
|
|
|
|
// And back
|
|
|
|
// And back
|
|
|
|
element.draggable( "option", "handle", false );
|
|
|
|
element.draggable( "option", "handle", false );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: false as option, element dragged" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: false as option, element dragged" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "helper, default, switching after initialization", function() {
|
|
|
|
test( "helper, default, switching after initialization", function() {
|
|
|
|
expect( 6 );
|
|
|
|
expect( 6 );
|
|
|
|
|
|
|
|
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
var element = $( "#draggable1" ).draggable();
|
|
|
|
TestHelpers.draggable.shouldMove( element, "helper: default" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "helper: default" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "helper", "clone" );
|
|
|
|
element.draggable( "option", "helper", "clone" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "helper: clone" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "helper: clone" );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "helper", "original" );
|
|
|
|
element.draggable( "option", "helper", "original" );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "helper: original" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "helper: original" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// http://bugs.jqueryui.com/ticket/9446
|
|
|
|
// http://bugs.jqueryui.com/ticket/9446
|
|
|
@ -888,7 +892,7 @@ test( "helper, function returning original element", function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" );
|
|
|
|
draggableTestHelpers.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" );
|
|
|
|
|
|
|
|
|
|
|
|
element.simulate( "drag", {
|
|
|
|
element.simulate( "drag", {
|
|
|
|
dx: 100,
|
|
|
|
dx: 100,
|
|
|
@ -907,25 +911,25 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
|
|
|
|
if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) {
|
|
|
|
TestHelpers.draggable.setScrollable( "#main", false );
|
|
|
|
draggableTestHelpers.setScrollable( "#main", false );
|
|
|
|
TestHelpers.draggable.setScrollable( "#scrollParent", true );
|
|
|
|
draggableTestHelpers.setScrollable( "#scrollParent", true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for ( j = 0; j < scrollPositions.length; j++ ) {
|
|
|
|
for ( j = 0; j < scrollPositions.length; j++ ) {
|
|
|
|
for ( i = 0; i < scrollElements.length; i++ ) {
|
|
|
|
for ( i = 0; i < scrollElements.length; i++ ) {
|
|
|
|
TestHelpers.draggable.setScroll( scrollElements[ i ] );
|
|
|
|
draggableTestHelpers.setScroll( scrollElements[ i ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.testScroll( element, scrollPositions[ j ] );
|
|
|
|
draggableTestHelpers.testScroll( element, scrollPositions[ j ] );
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < scrollElements.length; i++ ) {
|
|
|
|
for ( i = 0; i < scrollElements.length; i++ ) {
|
|
|
|
TestHelpers.draggable.restoreScroll( scrollElements[ i ] );
|
|
|
|
draggableTestHelpers.restoreScroll( scrollElements[ i ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
|
|
|
|
if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
|
|
|
|
TestHelpers.draggable.setScrollable( "#main", true );
|
|
|
|
draggableTestHelpers.setScrollable( "#main", true );
|
|
|
|
TestHelpers.draggable.setScrollable( "#scrollParent", false );
|
|
|
|
draggableTestHelpers.setScrollable( "#scrollParent", false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -983,15 +987,15 @@ test( "opacity, default, switching after initialization", function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( opacity, 1 );
|
|
|
|
equal( opacity, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "opacity", 0.5 );
|
|
|
|
element.draggable( "option", "opacity", 0.5 );
|
|
|
|
TestHelpers.draggable.move( element, 2, 1 );
|
|
|
|
draggableTestHelpers.move( element, 2, 1 );
|
|
|
|
equal( opacity, 0.5 );
|
|
|
|
equal( opacity, 0.5 );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "opacity", false );
|
|
|
|
element.draggable( "option", "opacity", false );
|
|
|
|
TestHelpers.draggable.move( element, 3, 1 );
|
|
|
|
draggableTestHelpers.move( element, 3, 1 );
|
|
|
|
equal( opacity, 1 );
|
|
|
|
equal( opacity, 1 );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1002,13 +1006,13 @@ asyncTest( "revert and revertDuration", function() {
|
|
|
|
revert: true,
|
|
|
|
revert: true,
|
|
|
|
revertDuration: 0
|
|
|
|
revertDuration: 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" );
|
|
|
|
draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" );
|
|
|
|
|
|
|
|
|
|
|
|
$( "#draggable2" ).draggable( "option", "revert", "invalid" );
|
|
|
|
$( "#draggable2" ).draggable( "option", "revert", "invalid" );
|
|
|
|
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" );
|
|
|
|
draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" );
|
|
|
|
|
|
|
|
|
|
|
|
$( "#draggable2" ).draggable( "option", "revert", false );
|
|
|
|
$( "#draggable2" ).draggable( "option", "revert", false );
|
|
|
|
TestHelpers.draggable.shouldMove( element, "revert: false should allow movement" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "revert: false should allow movement" );
|
|
|
|
|
|
|
|
|
|
|
|
$( "#draggable2" ).draggable( "option", {
|
|
|
|
$( "#draggable2" ).draggable( "option", {
|
|
|
|
revert: true,
|
|
|
|
revert: true,
|
|
|
@ -1019,7 +1023,7 @@ asyncTest( "revert and revertDuration", function() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// animation are async, so test for it asynchronously
|
|
|
|
// animation are async, so test for it asynchronously
|
|
|
|
TestHelpers.draggable.move( element, 50, 50 );
|
|
|
|
draggableTestHelpers.move( element, 50, 50 );
|
|
|
|
setTimeout( function() {
|
|
|
|
setTimeout( function() {
|
|
|
|
ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" );
|
|
|
|
ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" );
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1035,7 +1039,7 @@ test( "revert: valid", function() {
|
|
|
|
|
|
|
|
|
|
|
|
$( "#droppable" ).droppable();
|
|
|
|
$( "#droppable" ).droppable();
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" );
|
|
|
|
draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "scope", function() {
|
|
|
|
test( "scope", function() {
|
|
|
@ -1049,17 +1053,17 @@ test( "scope", function() {
|
|
|
|
|
|
|
|
|
|
|
|
$( "#droppable" ).droppable({ scope: "tasks" });
|
|
|
|
$( "#droppable" ).droppable({ scope: "tasks" });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" );
|
|
|
|
draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" );
|
|
|
|
|
|
|
|
|
|
|
|
$( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" });
|
|
|
|
$( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" });
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" );
|
|
|
|
draggableTestHelpers.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
|
|
|
|
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
|
|
|
|
expect( 2 );
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.setScrollable( "#main", false );
|
|
|
|
draggableTestHelpers.setScrollable( "#main", false );
|
|
|
|
|
|
|
|
|
|
|
|
var currentScrollTop,
|
|
|
|
var currentScrollTop,
|
|
|
|
viewportHeight = $( window ).height(),
|
|
|
|
viewportHeight = $( window ).height(),
|
|
|
@ -1101,7 +1105,7 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
|
|
|
|
moves: 1
|
|
|
|
moves: 1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.restoreScroll( document );
|
|
|
|
draggableTestHelpers.restoreScroll( document );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "scroll ignores containers that are overflow: hidden", function() {
|
|
|
|
test( "scroll ignores containers that are overflow: hidden", function() {
|
|
|
@ -1140,7 +1144,7 @@ test( "scroll ignores containers that are overflow: hidden", function() {
|
|
|
|
test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
|
|
|
|
test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
|
|
|
|
expect( 2 );
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.restoreScroll( document );
|
|
|
|
draggableTestHelpers.restoreScroll( document );
|
|
|
|
|
|
|
|
|
|
|
|
var offsetBefore,
|
|
|
|
var offsetBefore,
|
|
|
|
distance = 10,
|
|
|
|
distance = 10,
|
|
|
@ -1171,7 +1175,7 @@ test( "#6817: auto scroll goes double distance when dragging", function( assert
|
|
|
|
moves: 1
|
|
|
|
moves: 1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.restoreScroll( document );
|
|
|
|
draggableTestHelpers.restoreScroll( document );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
test( "snap, snapMode, and snapTolerance", function( assert ) {
|
|
|
|
test( "snap, snapMode, and snapTolerance", function( assert ) {
|
|
|
@ -1333,7 +1337,7 @@ test( "#8459: element can snap to an element that was removed during drag", func
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
|
|
|
// Support: Opera 12.10, Safari 5.1, jQuery <1.8
|
|
|
|
if ( TestHelpers.draggable.unreliableContains ) {
|
|
|
|
if ( draggableTestHelpers.unreliableContains ) {
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -1390,10 +1394,10 @@ test( "stack", function() {
|
|
|
|
stack: "#draggable1, #draggable2"
|
|
|
|
stack: "#draggable1, #draggable2"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" );
|
|
|
|
equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element2, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element2, 1, 1 );
|
|
|
|
equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" );
|
|
|
|
equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -1431,15 +1435,15 @@ test( "zIndex, default, switching after initialization", function() {
|
|
|
|
|
|
|
|
|
|
|
|
element.css( "z-index", 1 );
|
|
|
|
element.css( "z-index", 1 );
|
|
|
|
|
|
|
|
|
|
|
|
TestHelpers.draggable.move( element, 1, 1 );
|
|
|
|
draggableTestHelpers.move( element, 1, 1 );
|
|
|
|
equal( zindex, 1 );
|
|
|
|
equal( zindex, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "zIndex", 5 );
|
|
|
|
element.draggable( "option", "zIndex", 5 );
|
|
|
|
TestHelpers.draggable.move( element, 2, 1 );
|
|
|
|
draggableTestHelpers.move( element, 2, 1 );
|
|
|
|
equal( zindex, 5 );
|
|
|
|
equal( zindex, 5 );
|
|
|
|
|
|
|
|
|
|
|
|
element.draggable( "option", "zIndex", false );
|
|
|
|
element.draggable( "option", "zIndex", false );
|
|
|
|
TestHelpers.draggable.move( element, 3, 1 );
|
|
|
|
draggableTestHelpers.move( element, 3, 1 );
|
|
|
|
equal( zindex, 1 );
|
|
|
|
equal( zindex, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1486,4 +1490,4 @@ test( "iframeFix", function() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
})( jQuery );
|
|
|
|
} );
|
|
|
|