2015-04-06 18:50:39 +00:00
|
|
|
define( [
|
2016-04-06 13:22:59 +00:00
|
|
|
"qunit",
|
2015-04-06 18:50:39 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-07-15 02:08:51 +00:00
|
|
|
"ui/widgets/sortable"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, helper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "sortable: options", { afterEach: helper.moduleAfterEach } );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-11-02 00:54:52 +00:00
|
|
|
/*
|
2016-04-06 13:22:59 +00:00
|
|
|
Test("{ appendTo: 'parent' }, default", function() {
|
2009-02-03 00:33:00 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ appendTo: Selector }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
2013-03-15 02:56:48 +00:00
|
|
|
*/
|
2009-02-03 00:33:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ axis: false }, default", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2013-03-15 02:56:48 +00:00
|
|
|
|
|
|
|
var offsetAfter,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable" ).sortable( {
|
2013-03-15 02:56:48 +00:00
|
|
|
axis: false,
|
|
|
|
change: function() {
|
|
|
|
offsetAfter = item.offset();
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" );
|
|
|
|
assert.notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" );
|
2013-03-15 02:56:48 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2013-03-15 02:56:48 +00:00
|
|
|
item = element.find( "li" ).eq( 0 ),
|
|
|
|
offsetBefore = item.offset();
|
|
|
|
|
|
|
|
item.simulate( "drag", {
|
|
|
|
dx: 50,
|
|
|
|
dy: 25,
|
|
|
|
moves: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-03 00:33:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ axis: 'x' }", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2013-03-15 02:56:48 +00:00
|
|
|
|
|
|
|
var offsetAfter,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable" ).sortable( {
|
2013-03-15 02:56:48 +00:00
|
|
|
axis: "x",
|
|
|
|
change: function() {
|
|
|
|
offsetAfter = item.offset();
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" );
|
|
|
|
assert.equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" );
|
2013-03-15 02:56:48 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2013-03-15 02:56:48 +00:00
|
|
|
item = element.find( "li" ).eq( 0 ),
|
|
|
|
offsetBefore = item.offset();
|
|
|
|
|
|
|
|
item.simulate( "drag", {
|
|
|
|
dx: 50,
|
|
|
|
dy: 25,
|
|
|
|
moves: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-03 00:33:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ axis: 'y' }", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2013-03-15 02:56:48 +00:00
|
|
|
|
|
|
|
var offsetAfter,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable" ).sortable( {
|
2013-03-15 02:56:48 +00:00
|
|
|
axis: "y",
|
|
|
|
change: function() {
|
|
|
|
offsetAfter = item.offset();
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" );
|
|
|
|
assert.notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" );
|
2013-03-15 02:56:48 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2013-03-15 02:56:48 +00:00
|
|
|
item = element.find( "li" ).eq( 0 ),
|
|
|
|
offsetBefore = item.offset();
|
|
|
|
|
|
|
|
item.simulate( "drag", {
|
|
|
|
dx: 50,
|
|
|
|
dy: 25,
|
|
|
|
moves: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-03 00:33:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "#7415: Incorrect revert animation with axis: 'y'", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 2 );
|
2013-03-15 02:56:48 +00:00
|
|
|
var expectedLeft,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable" ).sortable( {
|
2013-03-15 02:56:48 +00:00
|
|
|
axis: "y",
|
|
|
|
revert: true,
|
|
|
|
sort: function() {
|
|
|
|
expectedLeft = item.css( "left" );
|
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2013-03-15 02:56:48 +00:00
|
|
|
item = element.find( "li" ).eq( 0 );
|
|
|
|
|
|
|
|
item.simulate( "drag", {
|
|
|
|
dy: 300,
|
|
|
|
dx: 50
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-15 02:56:48 +00:00
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
setTimeout( function() {
|
2013-03-15 02:56:48 +00:00
|
|
|
var top = parseFloat( item.css( "top" ) );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( item.css( "left" ), expectedLeft, "left not animated" );
|
|
|
|
assert.ok( top > 0 && top < 300, "top is animated" );
|
2020-05-16 07:16:24 +00:00
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
item.stop( true );
|
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
ready();
|
2013-03-15 02:56:48 +00:00
|
|
|
}, 100 );
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2009-02-03 00:33:00 +00:00
|
|
|
|
2013-03-15 02:56:48 +00:00
|
|
|
/*
|
2016-04-06 13:22:59 +00:00
|
|
|
Test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
2009-02-03 00:33:00 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ cancel: Selector }", function() {
|
2009-02-02 14:36:08 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
2013-03-08 21:38:41 +00:00
|
|
|
*/
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "#8792: issues with floated items in connected lists", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
|
|
|
var element,
|
|
|
|
changeCount = 0;
|
|
|
|
|
|
|
|
$( "#qunit-fixture" )
|
|
|
|
.html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" )
|
2015-08-24 12:57:53 +00:00
|
|
|
.find( "ul" ).css( { "float": "left", width: "100px" } ).end()
|
|
|
|
.find( "li" ).css( { "float": "left", width: "50px", height: "50px" } );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
$( "#qunit-fixture .c" ).sortable( {
|
2013-03-08 21:38:41 +00:00
|
|
|
connectWith: "#qunit-fixture .c",
|
|
|
|
change: function() {
|
|
|
|
changeCount++;
|
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2020-01-22 15:44:34 +00:00
|
|
|
element = $( "#qunit-fixture li" ).eq( 0 );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2015-08-21 04:05:15 +00:00
|
|
|
// Move the first li to the right of the second li in the first ul
|
2013-03-08 21:38:41 +00:00
|
|
|
element.simulate( "drag", {
|
2013-03-31 16:06:28 +00:00
|
|
|
dx: 55,
|
2013-03-08 21:38:41 +00:00
|
|
|
moves: 15
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2015-08-21 04:05:15 +00:00
|
|
|
// Move the first li ( which is now in the second spot )
|
2013-03-31 16:06:28 +00:00
|
|
|
// through the first spot in the second ul to the second spot in the second ul
|
2013-03-08 21:38:41 +00:00
|
|
|
element.simulate( "drag", {
|
2013-03-31 16:06:28 +00:00
|
|
|
dx: 100,
|
2013-03-08 21:38:41 +00:00
|
|
|
moves: 15
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-08 21:38:41 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "#8301: single axis with connected list", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2013-03-21 14:56:39 +00:00
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
var element = $( "#sortable" ).sortable( {
|
2013-03-21 14:56:39 +00:00
|
|
|
axis: "y",
|
|
|
|
tolerance: "pointer",
|
|
|
|
connectWith: ".connected"
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-21 14:56:39 +00:00
|
|
|
|
|
|
|
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
|
2015-08-24 12:57:53 +00:00
|
|
|
.sortable( {
|
2013-03-21 14:56:39 +00:00
|
|
|
axis: "y",
|
|
|
|
tolerance: "pointer",
|
|
|
|
connectWith: "#sortable",
|
|
|
|
receive: function() {
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.ok( true, "connected list received item" );
|
2013-03-21 14:56:39 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} )
|
2013-03-21 14:56:39 +00:00
|
|
|
.insertAfter( element );
|
|
|
|
|
|
|
|
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
|
|
|
handle: "corner",
|
2013-03-31 16:06:28 +00:00
|
|
|
dy: 120,
|
2013-03-21 14:56:39 +00:00
|
|
|
moves: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-21 14:56:39 +00:00
|
|
|
|
2013-03-08 21:38:41 +00:00
|
|
|
/*
|
2016-04-06 13:22:59 +00:00
|
|
|
Test("{ connectWith: false }, default", function() {
|
2009-02-03 02:49:49 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ connectWith: Selector }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: Element }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: 'document' }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: 'parent' }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: 'window' }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ containment: Selector }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ cursor: 'auto' }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ cursor: 'move' }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ cursorAt: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ cursorAt: true }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ delay: 0 }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ delay: 100 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ distance: 1 }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ distance: 10 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ dropOnEmpty: true }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ dropOnEmpty: false }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
2015-07-16 01:10:19 +00:00
|
|
|
*/
|
2009-02-03 02:49:49 +00:00
|
|
|
|
2015-07-16 01:10:19 +00:00
|
|
|
QUnit.test( "{ forcePlaceholderSize: false } table rows", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2009-02-03 02:49:49 +00:00
|
|
|
|
2015-07-16 01:10:19 +00:00
|
|
|
var element = $( "#sortable-table2 tbody" );
|
|
|
|
|
|
|
|
element.sortable( {
|
|
|
|
placeholder: "test",
|
|
|
|
forcePlaceholderSize: false,
|
|
|
|
start: function( event, ui ) {
|
|
|
|
assert.notEqual( ui.placeholder.height(), ui.item.height(),
|
|
|
|
"placeholder is same height as item" );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
// This row has a non-standard height
|
|
|
|
$( "tr", element ).eq( 0 ).simulate( "drag", {
|
|
|
|
dy: 1
|
|
|
|
} );
|
|
|
|
} );
|
2009-02-03 02:49:49 +00:00
|
|
|
|
2015-07-16 01:10:19 +00:00
|
|
|
QUnit.test( "{ forcePlaceholderSize: true } table rows", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
|
|
|
|
|
|
|
// Table should have the placeholder's height set the same as the row we're dragging
|
2021-03-08 23:11:40 +00:00
|
|
|
var element = $( "#sortable-table2 tbody" ),
|
|
|
|
jqMinor = $.fn.jquery.substring( 0, 4 );
|
2015-07-16 01:10:19 +00:00
|
|
|
|
|
|
|
element.sortable( {
|
|
|
|
placeholder: "test",
|
|
|
|
forcePlaceholderSize: true,
|
|
|
|
start: function( event, ui ) {
|
2021-03-08 23:11:40 +00:00
|
|
|
|
|
|
|
// Support: IE 11+, Edge <79 only
|
|
|
|
// In IE & Edge Legacy these values may differ a little
|
|
|
|
// when jQuery >=3.0 <3.2 is used.
|
|
|
|
if ( jqMinor === "3.0." || jqMinor === "3.1." ) {
|
|
|
|
assert.ok( Math.abs( ui.placeholder.height() - ui.item.height() ) < 0.25,
|
|
|
|
"placeholder height is within 0.25 px of item's" );
|
|
|
|
} else {
|
|
|
|
assert.equal( ui.placeholder.height(), ui.item.height(),
|
|
|
|
"placeholder is same height as item" );
|
|
|
|
}
|
2015-07-16 01:10:19 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
// First row has a non-standard height
|
|
|
|
$( "tr", element ).eq( 0 ).simulate( "drag", {
|
|
|
|
dy: 1
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Second row's height is normal
|
|
|
|
$( "tr", element ).eq( 1 ).simulate( "drag", {
|
|
|
|
dy: 1
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/*
|
2009-02-03 02:49:49 +00:00
|
|
|
test("{ forceHelperSize: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ forceHelperSize: true }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ grid: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ grid: [17, 3] }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ grid: [3, 7] }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ handle: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ handle: Element }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ handle: Selector }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ helper: 'original' }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ helper: Function }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ items: '> *' }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ items: Selector }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ opacity: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ opacity: .37 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ opacity: 1 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ placeholder: false }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
2013-02-21 01:16:29 +00:00
|
|
|
*/
|
2013-03-07 17:55:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ placeholder: false } img", function( assert ) {
|
|
|
|
assert.expect( 3 );
|
2013-03-07 17:55:00 +00:00
|
|
|
|
2020-05-16 06:28:26 +00:00
|
|
|
var done = assert.async(),
|
|
|
|
element = $( "#sortable-images" ).sortable( {
|
2013-03-07 17:55:00 +00:00
|
|
|
start: function( event, ui ) {
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" );
|
|
|
|
assert.equal( ui.placeholder.height(), 32, "placeholder has correct height" );
|
|
|
|
assert.equal( ui.placeholder.width(), 32, "placeholder has correct width" );
|
2013-03-07 17:55:00 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-07 17:55:00 +00:00
|
|
|
|
2020-05-16 06:28:26 +00:00
|
|
|
// Give browsers some time to load the image if cache is disabled.
|
|
|
|
// This resolves a frequent issue in Chrome/Safari.
|
|
|
|
setTimeout( function() {
|
|
|
|
element.find( "img" ).eq( 0 ).simulate( "drag", {
|
|
|
|
dy: 1
|
|
|
|
} );
|
|
|
|
done();
|
|
|
|
}, 500 );
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-03-07 17:55:00 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ placeholder: String }", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2009-02-03 02:49:49 +00:00
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
var element = $( "#sortable" ).sortable( {
|
2013-02-21 01:16:29 +00:00
|
|
|
placeholder: "test",
|
|
|
|
start: function( event, ui ) {
|
2015-02-03 00:37:32 +00:00
|
|
|
assert.hasClasses( ui.placeholder, "test" );
|
2013-02-21 01:16:29 +00:00
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
2013-02-21 01:16:29 +00:00
|
|
|
|
|
|
|
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
|
|
|
dy: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2009-02-03 02:49:49 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ placholder: String } tr", function( assert ) {
|
|
|
|
assert.expect( 4 );
|
2013-04-02 14:42:21 +00:00
|
|
|
|
|
|
|
var originalWidths,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable-table tbody" ).sortable( {
|
2013-04-02 14:42:21 +00:00
|
|
|
placeholder: "test",
|
|
|
|
start: function( event, ui ) {
|
2015-08-24 12:57:53 +00:00
|
|
|
var currentWidths = otherRow.children().map( function() {
|
2013-04-02 14:42:21 +00:00
|
|
|
return $( this ).width();
|
2015-08-24 12:57:53 +00:00
|
|
|
} ).get();
|
2015-02-03 00:37:32 +00:00
|
|
|
assert.hasClasses( ui.placeholder, "test" );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.deepEqual( currentWidths, originalWidths, "table cells maintian size" );
|
|
|
|
assert.equal( ui.placeholder.children().length, dragRow.children().length,
|
2013-04-02 14:42:21 +00:00
|
|
|
"placeholder has correct number of cells" );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( ui.placeholder.children().html(), $( "<span> </span>" ).html(),
|
2013-04-02 14:42:21 +00:00
|
|
|
"placeholder td has content for forced dimensions" );
|
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2013-04-02 14:42:21 +00:00
|
|
|
rows = element.children( "tr" ),
|
|
|
|
dragRow = rows.eq( 0 ),
|
|
|
|
otherRow = rows.eq( 1 );
|
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
originalWidths = otherRow.children().map( function() {
|
2013-04-02 14:42:21 +00:00
|
|
|
return $( this ).width();
|
2015-08-24 12:57:53 +00:00
|
|
|
} ).get();
|
2013-04-02 14:42:21 +00:00
|
|
|
dragRow.simulate( "drag", {
|
2013-02-21 01:16:29 +00:00
|
|
|
dy: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2013-02-21 01:16:29 +00:00
|
|
|
|
2016-04-06 13:22:59 +00:00
|
|
|
QUnit.test( "{ placholder: String } tbody", function( assert ) {
|
|
|
|
assert.expect( 6 );
|
2014-10-31 13:24:29 +00:00
|
|
|
|
|
|
|
var originalWidths,
|
2015-08-24 12:57:53 +00:00
|
|
|
element = $( "#sortable-table" ).sortable( {
|
2014-10-31 13:24:29 +00:00
|
|
|
placeholder: "test",
|
|
|
|
start: function( event, ui ) {
|
2015-08-24 12:57:53 +00:00
|
|
|
var currentWidths = otherBody.children().map( function() {
|
2014-10-31 13:24:29 +00:00
|
|
|
return $( this ).width();
|
2015-08-24 12:57:53 +00:00
|
|
|
} ).get();
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
|
|
|
assert.deepEqual( currentWidths, originalWidths, "table cells maintain size" );
|
|
|
|
assert.equal( ui.placeholder.children().length, 1,
|
2014-10-31 13:24:29 +00:00
|
|
|
"placeholder has one child" );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( ui.placeholder.children( "tr" ).length, 1,
|
2014-10-31 13:24:29 +00:00
|
|
|
"placeholder's child is tr" );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( ui.placeholder.find( "> tr" ).children().length,
|
2020-01-22 15:44:34 +00:00
|
|
|
dragBody.find( "> tr" ).first().children().length,
|
2014-10-31 13:24:29 +00:00
|
|
|
"placeholder's tr has correct number of cells" );
|
2016-04-06 13:22:59 +00:00
|
|
|
assert.equal( ui.placeholder.find( "> tr" ).children().html(),
|
2014-10-31 13:24:29 +00:00
|
|
|
$( "<span> </span>" ).html(),
|
|
|
|
"placeholder td has content for forced dimensions" );
|
|
|
|
}
|
2015-08-24 12:57:53 +00:00
|
|
|
} ),
|
2014-10-31 13:24:29 +00:00
|
|
|
bodies = element.children( "tbody" ),
|
|
|
|
dragBody = bodies.eq( 0 ),
|
|
|
|
otherBody = bodies.eq( 1 );
|
|
|
|
|
2015-08-24 12:57:53 +00:00
|
|
|
originalWidths = otherBody.children().map( function() {
|
2014-10-31 13:24:29 +00:00
|
|
|
return $( this ).width();
|
2015-08-24 12:57:53 +00:00
|
|
|
} ).get();
|
2014-10-31 13:24:29 +00:00
|
|
|
dragBody.simulate( "drag", {
|
|
|
|
dy: 1
|
2015-08-24 12:57:53 +00:00
|
|
|
} );
|
|
|
|
} );
|
2014-10-31 13:24:29 +00:00
|
|
|
|
2021-11-15 17:39:25 +00:00
|
|
|
// gh-2001
|
|
|
|
// Sortable: Draggable items moved into a sortable had incorrect position
|
|
|
|
QUnit.test( "{ connectToSortable: Selector } positioning (gh-2001)", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
|
|
|
// Code from jQuery Simulate with minor modifications.
|
|
|
|
function findCenter( elem ) {
|
|
|
|
var offset,
|
|
|
|
document = $( elem[ 0 ].ownerDocument );
|
|
|
|
offset = elem.offset();
|
|
|
|
|
|
|
|
return {
|
|
|
|
x: Math.floor( offset.left + elem.outerWidth() / 2 - document.scrollLeft() ),
|
|
|
|
y: Math.floor( offset.top + elem.outerHeight() / 2 - document.scrollTop( ) )
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var sortableElem = $( "#sortable" );
|
|
|
|
|
|
|
|
sortableElem.css( "position", "relative" );
|
|
|
|
|
|
|
|
var item = $( "<div></div>" )
|
|
|
|
.text( "6" )
|
|
|
|
.insertBefore( "#sortable" );
|
|
|
|
|
|
|
|
// Padding
|
|
|
|
$( "<div></div>" )
|
|
|
|
.css( {
|
|
|
|
width: "100px",
|
|
|
|
height: "100px"
|
|
|
|
} )
|
|
|
|
.insertBefore( "#sortable" );
|
|
|
|
|
|
|
|
item.draggable( {
|
|
|
|
connectToSortable: "#sortable"
|
|
|
|
} );
|
|
|
|
sortableElem.sortable();
|
|
|
|
|
|
|
|
// Simulate a drag without a drop.
|
|
|
|
var center = findCenter( item );
|
|
|
|
item.simulate( "mousedown", {
|
|
|
|
clientX: center.x,
|
|
|
|
clientY: center.y
|
|
|
|
} );
|
|
|
|
item.simulate( "mousemove", {
|
|
|
|
clientX: center.x,
|
|
|
|
clientY: center.y + 60
|
|
|
|
} );
|
|
|
|
item.simulate( "mousemove", {
|
|
|
|
clientX: center.x,
|
|
|
|
clientY: center.y + 120
|
|
|
|
} );
|
|
|
|
|
|
|
|
assert.ok( item.offset().top > sortableElem.children().eq( 0 ).offset().top,
|
|
|
|
"Draggable offset correct after moving into a sortable" );
|
|
|
|
} );
|
|
|
|
|
2013-02-21 01:16:29 +00:00
|
|
|
/*
|
2016-04-06 13:22:59 +00:00
|
|
|
Test("{ revert: false }, default", function() {
|
2009-02-03 02:49:49 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ revert: true }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scroll: true }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scroll: false }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSensitivity: 20 }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSensitivity: 2 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSensitivity: 200 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSpeed: 20 }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSpeed: 2 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scrollSpeed: 200 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scope: 'default' }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ scope: ??? }, unexpected", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ tolerance: 'intersect' }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ tolerance: 'pointer' }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ zIndex: 1000 }, default", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ zIndex: 1 }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ zIndex: false }", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
2012-11-02 00:54:52 +00:00
|
|
|
*/
|
2015-04-06 18:50:39 +00:00
|
|
|
} );
|