mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
parent
23d0884e66
commit
62c8217185
@ -48,6 +48,6 @@ common.testWidget( "sortable", {
|
||||
stop: null,
|
||||
update: null
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -9,12 +9,12 @@ module( "sortable: core" );
|
||||
test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() {
|
||||
expect( 1 );
|
||||
|
||||
var el = $( ".connectWith" ).sortable({
|
||||
var el = $( ".connectWith" ).sortable( {
|
||||
connectWith: ".connectWith"
|
||||
});
|
||||
} );
|
||||
|
||||
testHelper.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
|
||||
});
|
||||
} );
|
||||
|
||||
test( "ui-sortable-handle applied to appropriate element", function( assert ) {
|
||||
expect( 8 );
|
||||
@ -37,6 +37,6 @@ test( "ui-sortable-handle applied to appropriate element", function( assert ) {
|
||||
|
||||
el.sortable( "destroy" );
|
||||
equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );
|
||||
});
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -5,223 +5,223 @@ define( [
|
||||
"ui/widgets/draggable"
|
||||
], function( $, testHelper ) {
|
||||
|
||||
module("sortable: events");
|
||||
module( "sortable: events" );
|
||||
|
||||
test("start", function() {
|
||||
test( "start", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
start: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 10
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "start event triggered");
|
||||
ok(hash.helper, "UI hash includes: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "start event triggered" );
|
||||
ok( hash.helper, "UI hash includes: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
// Todo: see if these events should actually have sane values in them
|
||||
ok("position" in hash, "UI hash includes: position");
|
||||
ok("offset" in hash, "UI hash includes: offset");
|
||||
});
|
||||
ok( "position" in hash, "UI hash includes: position" );
|
||||
ok( "offset" in hash, "UI hash includes: offset" );
|
||||
} );
|
||||
|
||||
test("sort", function() {
|
||||
test( "sort", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
sort: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 10
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "sort event triggered");
|
||||
ok(hash.helper, "UI hash includes: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "sort event triggered" );
|
||||
ok( hash.helper, "UI hash includes: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
|
||||
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("change", function() {
|
||||
test( "change", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
} );
|
||||
|
||||
ok(!hash, "1px drag, change event should not be triggered");
|
||||
ok( !hash, "1px drag, change event should not be triggered" );
|
||||
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 22
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "change event triggered");
|
||||
ok(hash.helper, "UI hash includes: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "change event triggered" );
|
||||
ok( hash.helper, "UI hash includes: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
|
||||
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("beforeStop", function() {
|
||||
test( "beforeStop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
beforeStop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "beforeStop event triggered");
|
||||
ok(hash.helper, "UI hash includes: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "beforeStop event triggered" );
|
||||
ok( hash.helper, "UI hash includes: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
|
||||
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("stop", function() {
|
||||
test( "stop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
stop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "stop event triggered");
|
||||
ok(!hash.helper, "UI should not include: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "stop event triggered" );
|
||||
ok( !hash.helper, "UI should not include: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
|
||||
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("update", function() {
|
||||
test( "update", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
} );
|
||||
|
||||
ok(!hash, "1px drag, update event should not be triggered");
|
||||
ok( !hash, "1px drag, update event should not be triggered" );
|
||||
|
||||
$("#sortable").sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 22
|
||||
});
|
||||
} );
|
||||
|
||||
ok(hash, "update event triggered");
|
||||
ok(!hash.helper, "UI hash should not include: helper");
|
||||
ok(hash.placeholder, "UI hash includes: placeholder");
|
||||
ok(hash.position && ("top" in hash.position && "left" in hash.position), "UI hash includes: position");
|
||||
ok(hash.offset && (hash.offset.top && hash.offset.left), "UI hash includes: offset");
|
||||
ok(hash.item, "UI hash includes: item");
|
||||
ok(!hash.sender, "UI hash does not include: sender");
|
||||
ok( hash, "update event triggered" );
|
||||
ok( !hash.helper, "UI hash should not include: helper" );
|
||||
ok( hash.placeholder, "UI hash includes: placeholder" );
|
||||
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
|
||||
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( !hash.sender, "UI hash does not include: sender" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("#3019: Stop fires too early", function() {
|
||||
expect(2);
|
||||
test( "#3019: Stop fires too early", function() {
|
||||
expect( 2 );
|
||||
|
||||
var helper = null,
|
||||
el = $("#sortable").sortable({
|
||||
stop: function(event, ui) {
|
||||
el = $( "#sortable" ).sortable( {
|
||||
stop: function( event, ui ) {
|
||||
helper = ui.helper;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
testHelper.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable");
|
||||
equal(helper, null, "helper should be false");
|
||||
testHelper.sort( $( "li", el )[ 0 ], 0, 44, 2, "Dragging the sortable" );
|
||||
equal( helper, null, "helper should be false" );
|
||||
|
||||
});
|
||||
} );
|
||||
|
||||
test("#4752: link event firing on sortable with connect list", function () {
|
||||
test( "#4752: link event firing on sortable with connect list", function() {
|
||||
expect( 10 );
|
||||
|
||||
var fired = {},
|
||||
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
|
||||
hasFired = function( type ) { return ( type in fired ) && ( true === fired[ type ] ); };
|
||||
|
||||
$("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable");
|
||||
$( "#sortable" ).clone().attr( "id", "sortable2" ).insertAfter( "#sortable" );
|
||||
|
||||
$("#qunit-fixture ul").sortable({
|
||||
$( "#qunit-fixture ul" ).sortable( {
|
||||
connectWith: "#qunit-fixture ul",
|
||||
change: function () {
|
||||
change: function() {
|
||||
fired.change = true;
|
||||
},
|
||||
receive: function () {
|
||||
receive: function() {
|
||||
fired.receive = true;
|
||||
},
|
||||
remove: function () {
|
||||
remove: function() {
|
||||
fired.remove = true;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
$("#qunit-fixture ul").on("click.ui-sortable-test", function () {
|
||||
$( "#qunit-fixture ul" ).on( "click.ui-sortable-test", function() {
|
||||
fired.click = true;
|
||||
});
|
||||
} );
|
||||
|
||||
$("#sortable li:eq(0)").simulate("click");
|
||||
ok(!hasFired("change"), "Click only, change event should not have fired");
|
||||
ok(hasFired("click"), "Click event should have fired");
|
||||
$( "#sortable li:eq(0)" ).simulate( "click" );
|
||||
ok( !hasFired( "change" ), "Click only, change event should not have fired" );
|
||||
ok( hasFired( "click" ), "Click event should have fired" );
|
||||
|
||||
// Drag an item within the first list
|
||||
fired = {};
|
||||
$("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 40 });
|
||||
ok(hasFired("change"), "40px drag, change event should have fired");
|
||||
ok(!hasFired("receive"), "Receive event should not have fired");
|
||||
ok(!hasFired("remove"), "Remove event should not have fired");
|
||||
ok(!hasFired("click"), "Click event should not have fired");
|
||||
$( "#sortable li:eq(0)" ).simulate( "drag", { dx: 0, dy: 40 } );
|
||||
ok( hasFired( "change" ), "40px drag, change event should have fired" );
|
||||
ok( !hasFired( "receive" ), "Receive event should not have fired" );
|
||||
ok( !hasFired( "remove" ), "Remove event should not have fired" );
|
||||
ok( !hasFired( "click" ), "Click event should not have fired" );
|
||||
|
||||
// Drag an item from the first list to the second, connected list
|
||||
fired = {};
|
||||
$("#sortable li:eq(0)").simulate("drag", { dx: 0, dy: 150 });
|
||||
ok(hasFired("change"), "150px drag, change event should have fired");
|
||||
ok(hasFired("receive"), "Receive event should have fired");
|
||||
ok(hasFired("remove"), "Remove event should have fired");
|
||||
ok(!hasFired("click"), "Click event should not have fired");
|
||||
});
|
||||
$( "#sortable li:eq(0)" ).simulate( "drag", { dx: 0, dy: 150 } );
|
||||
ok( hasFired( "change" ), "150px drag, change event should have fired" );
|
||||
ok( hasFired( "receive" ), "Receive event should have fired" );
|
||||
ok( hasFired( "remove" ), "Remove event should have fired" );
|
||||
ok( !hasFired( "click" ), "Click event should not have fired" );
|
||||
} );
|
||||
|
||||
/*
|
||||
test("receive", function() {
|
||||
@ -239,14 +239,14 @@ test( "over", function() {
|
||||
var hash,
|
||||
overCount = 0;
|
||||
|
||||
$( "#sortable" ).sortable({
|
||||
$( "#sortable" ).sortable( {
|
||||
over: function( e, ui ) {
|
||||
hash = ui;
|
||||
overCount++;
|
||||
}
|
||||
}).find( "li:eq(0)" ).simulate( "drag", {
|
||||
} ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
} );
|
||||
|
||||
ok( hash, "over event triggered" );
|
||||
ok( hash.helper, "UI includes: helper" );
|
||||
@ -256,7 +256,7 @@ test( "over", function() {
|
||||
ok( hash.item, "UI hash includes: item" );
|
||||
ok( hash.sender, "UI hash includes: sender" );
|
||||
equal( overCount, 1, "over fires only once" );
|
||||
});
|
||||
} );
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/9335
|
||||
// Sortable: over & out events does not consistently fire
|
||||
@ -267,25 +267,25 @@ test( "over, fires with draggable connected to sortable", function() {
|
||||
overCount = 0,
|
||||
item = $( "<div></div>" ).text( "6" ).insertAfter( "#sortable" );
|
||||
|
||||
item.draggable({
|
||||
item.draggable( {
|
||||
connectToSortable: "#sortable"
|
||||
});
|
||||
$( ".connectWith" ).sortable({
|
||||
} );
|
||||
$( ".connectWith" ).sortable( {
|
||||
connectWith: ".connectWith",
|
||||
over: function( event, ui ) {
|
||||
hash = ui;
|
||||
overCount++;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
item.simulate( "drag", {
|
||||
dy: -20
|
||||
});
|
||||
} );
|
||||
|
||||
ok( hash, "over event triggered" );
|
||||
ok( !hash.sender, "UI should not include: sender" );
|
||||
equal( overCount, 1, "over fires only once" );
|
||||
});
|
||||
} );
|
||||
|
||||
test( "over, with connected sortable", function() {
|
||||
expect( 3 );
|
||||
@ -293,21 +293,21 @@ test( "over, with connected sortable", function() {
|
||||
var hash,
|
||||
overCount = 0;
|
||||
|
||||
$( ".connectWith" ).sortable({
|
||||
$( ".connectWith" ).sortable( {
|
||||
connectWith: ".connectWith"
|
||||
});
|
||||
} );
|
||||
$( "#sortable2" ).on( "sortover", function( event, ui ) {
|
||||
hash = ui;
|
||||
overCount++;
|
||||
});
|
||||
} );
|
||||
$( "#sortable" ).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 102
|
||||
});
|
||||
} );
|
||||
|
||||
ok( hash, "over event triggered" );
|
||||
equal( hash.sender[ 0 ], $(" #sortable" )[ 0 ], "UI includes: sender" );
|
||||
equal( hash.sender[ 0 ], $( " #sortable" )[ 0 ], "UI includes: sender" );
|
||||
equal( overCount, 1, "over fires only once" );
|
||||
});
|
||||
} );
|
||||
|
||||
/*
|
||||
test("out", function() {
|
||||
@ -321,20 +321,20 @@ test( "out, with connected sortable", function() {
|
||||
var hash,
|
||||
outCount = 0;
|
||||
|
||||
$( ".connectWith" ).sortable({
|
||||
$( ".connectWith" ).sortable( {
|
||||
connectWith: ".connectWith"
|
||||
});
|
||||
} );
|
||||
$( "#sortable" ).on( "sortout", function( event, ui ) {
|
||||
hash = ui;
|
||||
outCount++;
|
||||
});
|
||||
} );
|
||||
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
|
||||
dy: 40
|
||||
});
|
||||
} );
|
||||
|
||||
ok( hash, "out event triggered" );
|
||||
equal( outCount, 1, "out fires only once" );
|
||||
});
|
||||
} );
|
||||
|
||||
test( "repeated out & over between connected sortables", function() {
|
||||
expect( 2 );
|
||||
@ -342,28 +342,29 @@ test( "repeated out & over between connected sortables", function() {
|
||||
var outCount = 0,
|
||||
overCount = 0;
|
||||
|
||||
$( ".connectWith" ).sortable({
|
||||
$( ".connectWith" ).sortable( {
|
||||
connectWith: ".connectWith",
|
||||
over: function() {
|
||||
overCount++;
|
||||
},
|
||||
out: function( event, ui ) {
|
||||
|
||||
// Ignore events that trigger when an item has dropped
|
||||
// checking for the presence of the helper.
|
||||
if ( !ui.helper ) {
|
||||
outCount++;
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
$( "#sortable" ).find( "li:last" ).simulate( "drag", {
|
||||
dy: 40
|
||||
}).simulate( "drag", {
|
||||
} ).simulate( "drag", {
|
||||
dy: -40
|
||||
});
|
||||
} );
|
||||
|
||||
equal( outCount, 2, "out fires twice" );
|
||||
equal( overCount, 4, "over fires four times" );
|
||||
});
|
||||
} );
|
||||
|
||||
/*
|
||||
test("activate", function() {
|
||||
|
@ -8,7 +8,7 @@ return $.extend( helper, {
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
} );
|
||||
equal( $( handle ).parent().children().index( handle ), index, msg );
|
||||
}
|
||||
} );
|
||||
|
@ -4,72 +4,72 @@ define( [
|
||||
"ui/widgets/sortable"
|
||||
], function( $, testHelper ) {
|
||||
|
||||
module("sortable: methods");
|
||||
module( "sortable: methods" );
|
||||
|
||||
test("init", function() {
|
||||
expect(5);
|
||||
test( "init", function() {
|
||||
expect( 5 );
|
||||
|
||||
$("<div></div>").appendTo("body").sortable().remove();
|
||||
ok(true, ".sortable() called on element");
|
||||
$( "<div></div>" ).appendTo( "body" ).sortable().remove();
|
||||
ok( true, ".sortable() called on element" );
|
||||
|
||||
$([]).sortable();
|
||||
ok(true, ".sortable() called on empty collection");
|
||||
$( [] ).sortable();
|
||||
ok( true, ".sortable() called on empty collection" );
|
||||
|
||||
$("<div></div>").sortable();
|
||||
ok(true, ".sortable() called on disconnected DOMElement");
|
||||
$( "<div></div>" ).sortable();
|
||||
ok( true, ".sortable() called on disconnected DOMElement" );
|
||||
|
||||
$("<div></div>").sortable().sortable("option", "foo");
|
||||
ok(true, "arbitrary option getter after init");
|
||||
$( "<div></div>" ).sortable().sortable( "option", "foo" );
|
||||
ok( true, "arbitrary option getter after init" );
|
||||
|
||||
$("<div></div>").sortable().sortable("option", "foo", "bar");
|
||||
ok(true, "arbitrary option setter after init");
|
||||
});
|
||||
$( "<div></div>" ).sortable().sortable( "option", "foo", "bar" );
|
||||
ok( true, "arbitrary option setter after init" );
|
||||
} );
|
||||
|
||||
test("destroy", function() {
|
||||
expect(4);
|
||||
$("<div></div>").appendTo("body").sortable().sortable("destroy").remove();
|
||||
ok(true, ".sortable('destroy') called on element");
|
||||
test( "destroy", function() {
|
||||
expect( 4 );
|
||||
$( "<div></div>" ).appendTo( "body" ).sortable().sortable( "destroy" ).remove();
|
||||
ok( true, ".sortable('destroy') called on element" );
|
||||
|
||||
$([]).sortable().sortable("destroy");
|
||||
ok(true, ".sortable('destroy') called on empty collection");
|
||||
$( [] ).sortable().sortable( "destroy" );
|
||||
ok( true, ".sortable('destroy') called on empty collection" );
|
||||
|
||||
$("<div></div>").sortable().sortable("destroy");
|
||||
ok(true, ".sortable('destroy') called on disconnected DOMElement");
|
||||
$( "<div></div>" ).sortable().sortable( "destroy" );
|
||||
ok( true, ".sortable('destroy') called on disconnected DOMElement" );
|
||||
|
||||
var expected = $("<div></div>").sortable(),
|
||||
actual = expected.sortable("destroy");
|
||||
equal(actual, expected, "destroy is chainable");
|
||||
});
|
||||
var expected = $( "<div></div>" ).sortable(),
|
||||
actual = expected.sortable( "destroy" );
|
||||
equal( actual, expected, "destroy is chainable" );
|
||||
} );
|
||||
|
||||
test("enable", function() {
|
||||
expect(5);
|
||||
test( "enable", function() {
|
||||
expect( 5 );
|
||||
|
||||
var el, actual, expected;
|
||||
|
||||
el = $("#sortable").sortable({ disabled: true });
|
||||
el = $( "#sortable" ).sortable( { disabled: true } );
|
||||
|
||||
testHelper.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");
|
||||
testHelper.sort( $( "li", el )[ 0 ], 0, 44, 0, ".sortable({ disabled: true })" );
|
||||
|
||||
el.sortable("enable");
|
||||
equal(el.sortable("option", "disabled"), false, "disabled option getter");
|
||||
el.sortable( "enable" );
|
||||
equal( el.sortable( "option", "disabled" ), false, "disabled option getter" );
|
||||
|
||||
el.sortable("destroy");
|
||||
el.sortable({ disabled: true });
|
||||
el.sortable("option", "disabled", false);
|
||||
equal(el.sortable("option", "disabled"), false, "disabled option setter");
|
||||
el.sortable( "destroy" );
|
||||
el.sortable( { disabled: true } );
|
||||
el.sortable( "option", "disabled", false );
|
||||
equal( el.sortable( "option", "disabled" ), false, "disabled option setter" );
|
||||
|
||||
testHelper.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)");
|
||||
testHelper.sort( $( "li", el )[ 0 ], 0, 44, 2, ".sortable('option', 'disabled', false)" );
|
||||
|
||||
expected = $("<div></div>").sortable(),
|
||||
actual = expected.sortable("enable");
|
||||
equal(actual, expected, "enable is chainable");
|
||||
});
|
||||
expected = $( "<div></div>" ).sortable(),
|
||||
actual = expected.sortable( "enable" );
|
||||
equal( actual, expected, "enable is chainable" );
|
||||
} );
|
||||
|
||||
test( "disable", function( assert ) {
|
||||
expect( 9 );
|
||||
|
||||
var chainable,
|
||||
element = $( "#sortable" ).sortable({ disabled: false });
|
||||
element = $( "#sortable" ).sortable( { disabled: false } );
|
||||
|
||||
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
|
||||
|
||||
@ -78,18 +78,18 @@ test( "disable", function( assert ) {
|
||||
|
||||
element.sortable( "destroy" );
|
||||
|
||||
element.sortable({ disabled: false });
|
||||
element.sortable( { disabled: false } );
|
||||
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
|
||||
element.sortable( "option", "disabled", true);
|
||||
element.sortable( "option", "disabled", true );
|
||||
equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
|
||||
|
||||
assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" );
|
||||
ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" );
|
||||
|
||||
testHelper.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
|
||||
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
|
||||
equal( chainable, element, "disable is chainable" );
|
||||
});
|
||||
} );
|
||||
|
||||
test( "refresh() should update the positions of initially empty lists (see #7498)", function() {
|
||||
expect( 1 );
|
||||
@ -98,22 +98,22 @@ test( "refresh() should update the positions of initially empty lists (see #7498
|
||||
element = $( "#qunit-fixture" ).html( "<ul></ul>" ).find( "ul" );
|
||||
|
||||
element
|
||||
.css({
|
||||
.css( {
|
||||
"float": "left",
|
||||
width: "100px"
|
||||
})
|
||||
.sortable({
|
||||
} )
|
||||
.sortable( {
|
||||
change: function() {
|
||||
changeCount++;
|
||||
}
|
||||
})
|
||||
} )
|
||||
.append( "<li>a</li><li>a</li>" )
|
||||
.find( "li" )
|
||||
.css({
|
||||
.css( {
|
||||
"float": "left",
|
||||
width: "50px",
|
||||
height: "50px"
|
||||
});
|
||||
} );
|
||||
|
||||
element.sortable( "refresh" );
|
||||
|
||||
@ -121,9 +121,9 @@ test( "refresh() should update the positions of initially empty lists (see #7498
|
||||
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
||||
dx: 55,
|
||||
moves: 15
|
||||
});
|
||||
} );
|
||||
|
||||
equal( changeCount, 1 );
|
||||
});
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -3,7 +3,7 @@ define( [
|
||||
"ui/widgets/sortable"
|
||||
], function( $ ) {
|
||||
|
||||
module("sortable: options");
|
||||
module( "sortable: options" );
|
||||
|
||||
/*
|
||||
test("{ appendTo: 'parent' }, default", function() {
|
||||
@ -19,14 +19,14 @@ test( "{ axis: false }, default", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
element = $( "#sortable" ).sortable({
|
||||
element = $( "#sortable" ).sortable( {
|
||||
axis: false,
|
||||
change: function() {
|
||||
offsetAfter = item.offset();
|
||||
notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" );
|
||||
notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
item = element.find( "li" ).eq( 0 ),
|
||||
offsetBefore = item.offset();
|
||||
|
||||
@ -34,21 +34,21 @@ test( "{ axis: false }, default", function() {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
test( "{ axis: 'x' }", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
element = $( "#sortable" ).sortable({
|
||||
element = $( "#sortable" ).sortable( {
|
||||
axis: "x",
|
||||
change: function() {
|
||||
offsetAfter = item.offset();
|
||||
notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" );
|
||||
equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
item = element.find( "li" ).eq( 0 ),
|
||||
offsetBefore = item.offset();
|
||||
|
||||
@ -56,21 +56,21 @@ test( "{ axis: 'x' }", function() {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
test( "{ axis: 'y' }", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
element = $( "#sortable" ).sortable({
|
||||
element = $( "#sortable" ).sortable( {
|
||||
axis: "y",
|
||||
change: function() {
|
||||
offsetAfter = item.offset();
|
||||
equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" );
|
||||
notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
item = element.find( "li" ).eq( 0 ),
|
||||
offsetBefore = item.offset();
|
||||
|
||||
@ -78,33 +78,33 @@ test( "{ axis: 'y' }", function() {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() {
|
||||
expect( 2 );
|
||||
var expectedLeft,
|
||||
element = $( "#sortable" ).sortable({
|
||||
element = $( "#sortable" ).sortable( {
|
||||
axis: "y",
|
||||
revert: true,
|
||||
stop: start,
|
||||
sort: function() {
|
||||
expectedLeft = item.css( "left" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
item = element.find( "li" ).eq( 0 );
|
||||
|
||||
item.simulate( "drag", {
|
||||
dy: 300,
|
||||
dx: 50
|
||||
});
|
||||
} );
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout( function() {
|
||||
var top = parseFloat( item.css( "top" ) );
|
||||
equal( item.css( "left" ), expectedLeft, "left not animated" );
|
||||
ok( top > 0 && top < 300, "top is animated" );
|
||||
}, 100 );
|
||||
});
|
||||
} );
|
||||
|
||||
/*
|
||||
test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
||||
@ -124,15 +124,15 @@ test( "#8792: issues with floated items in connected lists", function() {
|
||||
|
||||
$( "#qunit-fixture" )
|
||||
.html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" )
|
||||
.find( "ul" ).css({ "float": "left", width: "100px" }).end()
|
||||
.find( "li" ).css({ "float": "left", width: "50px", height: "50px" });
|
||||
.find( "ul" ).css( { "float": "left", width: "100px" } ).end()
|
||||
.find( "li" ).css( { "float": "left", width: "50px", height: "50px" } );
|
||||
|
||||
$( "#qunit-fixture .c" ).sortable({
|
||||
$( "#qunit-fixture .c" ).sortable( {
|
||||
connectWith: "#qunit-fixture .c",
|
||||
change: function() {
|
||||
changeCount++;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
element = $( "#qunit-fixture li:eq(0)" );
|
||||
|
||||
@ -140,7 +140,7 @@ test( "#8792: issues with floated items in connected lists", function() {
|
||||
element.simulate( "drag", {
|
||||
dx: 55,
|
||||
moves: 15
|
||||
});
|
||||
} );
|
||||
|
||||
equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
|
||||
|
||||
@ -149,37 +149,37 @@ test( "#8792: issues with floated items in connected lists", function() {
|
||||
element.simulate( "drag", {
|
||||
dx: 100,
|
||||
moves: 15
|
||||
});
|
||||
} );
|
||||
|
||||
equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
|
||||
});
|
||||
} );
|
||||
|
||||
test( "#8301: single axis with connected list", function() {
|
||||
expect( 1 );
|
||||
|
||||
var element = $( "#sortable" ).sortable({
|
||||
var element = $( "#sortable" ).sortable( {
|
||||
axis: "y",
|
||||
tolerance: "pointer",
|
||||
connectWith: ".connected"
|
||||
});
|
||||
} );
|
||||
|
||||
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
|
||||
.sortable({
|
||||
.sortable( {
|
||||
axis: "y",
|
||||
tolerance: "pointer",
|
||||
connectWith: "#sortable",
|
||||
receive: function() {
|
||||
ok( true, "connected list received item" );
|
||||
}
|
||||
})
|
||||
} )
|
||||
.insertAfter( element );
|
||||
|
||||
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
||||
handle: "corner",
|
||||
dy: 120,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
/*
|
||||
test("{ connectWith: false }, default", function() {
|
||||
@ -330,44 +330,44 @@ test("{ placeholder: false }, default", function() {
|
||||
test( "{ placeholder: false } img", function() {
|
||||
expect( 3 );
|
||||
|
||||
var element = $( "#sortable-images" ).sortable({
|
||||
var element = $( "#sortable-images" ).sortable( {
|
||||
start: function( event, ui ) {
|
||||
ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" );
|
||||
equal( ui.placeholder.height(), 32, "placeholder has correct height" );
|
||||
equal( ui.placeholder.width(), 32, "placeholder has correct width" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
element.find( "img" ).eq( 0 ).simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
test( "{ placeholder: String }", function( assert ) {
|
||||
expect( 1 );
|
||||
|
||||
var element = $( "#sortable" ).sortable({
|
||||
var element = $( "#sortable" ).sortable( {
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
assert.hasClasses( ui.placeholder, "test" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
test( "{ placholder: String } tr", function( assert ) {
|
||||
expect( 4 );
|
||||
|
||||
var originalWidths,
|
||||
element = $( "#sortable-table tbody" ).sortable({
|
||||
element = $( "#sortable-table tbody" ).sortable( {
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
var currentWidths = otherRow.children().map(function() {
|
||||
var currentWidths = otherRow.children().map( function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
} ).get();
|
||||
assert.hasClasses( ui.placeholder, "test" );
|
||||
deepEqual( currentWidths, originalWidths, "table cells maintian size" );
|
||||
equal( ui.placeholder.children().length, dragRow.children().length,
|
||||
@ -375,29 +375,29 @@ test( "{ placholder: String } tr", function( assert ) {
|
||||
equal( ui.placeholder.children().html(), $( "<span> </span>" ).html(),
|
||||
"placeholder td has content for forced dimensions" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
rows = element.children( "tr" ),
|
||||
dragRow = rows.eq( 0 ),
|
||||
otherRow = rows.eq( 1 );
|
||||
|
||||
originalWidths = otherRow.children().map(function() {
|
||||
originalWidths = otherRow.children().map( function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
} ).get();
|
||||
dragRow.simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
test( "{ placholder: String } tbody", function() {
|
||||
expect( 6 );
|
||||
|
||||
var originalWidths,
|
||||
element = $( "#sortable-table" ).sortable({
|
||||
element = $( "#sortable-table" ).sortable( {
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
var currentWidths = otherBody.children().map(function() {
|
||||
var currentWidths = otherBody.children().map( function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
} ).get();
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
deepEqual( currentWidths, originalWidths, "table cells maintain size" );
|
||||
equal( ui.placeholder.children().length, 1,
|
||||
@ -411,18 +411,18 @@ test( "{ placholder: String } tbody", function() {
|
||||
$( "<span> </span>" ).html(),
|
||||
"placeholder td has content for forced dimensions" );
|
||||
}
|
||||
}),
|
||||
} ),
|
||||
bodies = element.children( "tbody" ),
|
||||
dragBody = bodies.eq( 0 ),
|
||||
otherBody = bodies.eq( 1 );
|
||||
|
||||
originalWidths = otherBody.children().map(function() {
|
||||
originalWidths = otherBody.children().map( function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
} ).get();
|
||||
dragBody.simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
} );
|
||||
} );
|
||||
|
||||
/*
|
||||
test("{ revert: false }, default", function() {
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user