mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-05-24 00:24:07 +03:00
Merge commit 'd21ea7816e
' as 'jquery-ui'
This commit is contained in:
commit
e904a80717
629 changed files with 341074 additions and 0 deletions
26
jquery-ui/tests/unit/sortable/all.html
Normal file
26
jquery-ui/tests/unit/sortable/all.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Sortable Test Suite</title>
|
||||
|
||||
<script src="../../../external/jquery/jquery.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../qunit-composite.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../qunit-composite.js"></script>
|
||||
<script src="../subsuite.js"></script>
|
||||
|
||||
<script>
|
||||
testAllVersions( "sortable" );
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
140
jquery-ui/tests/unit/sortable/sortable.html
Normal file
140
jquery-ui/tests/unit/sortable/sortable.html
Normal file
|
@ -0,0 +1,140 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Sortable Test Suite</title>
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
|
||||
<script src="../testsuite.js"></script>
|
||||
<script>
|
||||
TestHelpers.loadResources({
|
||||
css: [ "core" ],
|
||||
js: [
|
||||
"ui/core.js",
|
||||
"ui/widget.js",
|
||||
"ui/mouse.js",
|
||||
"ui/sortable.js",
|
||||
"ui/draggable.js"
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="sortable_common.js"></script>
|
||||
<script src="sortable_core.js"></script>
|
||||
<script src="sortable_events.js"></script>
|
||||
<script src="sortable_methods.js"></script>
|
||||
<script src="sortable_options.js"></script>
|
||||
<script src="sortable_test_helpers.js"></script>
|
||||
|
||||
<script src="../swarminject.js"></script>
|
||||
<style>
|
||||
#sortable, #sortable2 {
|
||||
position:relative;
|
||||
top:0;
|
||||
left:0;
|
||||
padding: 0;
|
||||
margin: 1px;
|
||||
border-width: 0;
|
||||
}
|
||||
#sortable li, #sortable2 li{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border-width: 0;
|
||||
height:19px;
|
||||
}
|
||||
#sortable-table {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
<ul id="sortable" class="connectWith">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
<li>Item 4</li>
|
||||
<li>Item 5</li>
|
||||
</ul>
|
||||
|
||||
<ul id="sortable2" class="connectWith">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
<li>Item 4</li>
|
||||
<li>Item 5</li>
|
||||
</ul>
|
||||
|
||||
<table id="sortable-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1.1</td>
|
||||
<td>1.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1.3</td>
|
||||
<td>1.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1.5</td>
|
||||
<td>1.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1.7</td>
|
||||
<td>1.8</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>2.1</td>
|
||||
<td>2.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.3</td>
|
||||
<td>2.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.5</td>
|
||||
<td>2.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2.7</td>
|
||||
<td>2.8</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>3.1</td>
|
||||
<td>3.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.3</td>
|
||||
<td>3.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.5</td>
|
||||
<td>3.6</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3.7</td>
|
||||
<td>3.8</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="sortable-images">
|
||||
<img src="../../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../../images/jqueryui_32x32.png" alt="">
|
||||
<img src="../../images/jqueryui_32x32.png" alt="">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
45
jquery-ui/tests/unit/sortable/sortable_common.js
vendored
Normal file
45
jquery-ui/tests/unit/sortable/sortable_common.js
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
TestHelpers.commonWidgetTests( "sortable", {
|
||||
defaults: {
|
||||
appendTo: "parent",
|
||||
axis: false,
|
||||
cancel: "input,textarea,button,select,option",
|
||||
connectWith: false,
|
||||
containment: false,
|
||||
cursor: "auto",
|
||||
cursorAt: false,
|
||||
delay: 0,
|
||||
disabled: false,
|
||||
distance: 1,
|
||||
dropOnEmpty: true,
|
||||
forcePlaceholderSize: false,
|
||||
forceHelperSize: false,
|
||||
grid: false,
|
||||
handle: false,
|
||||
helper: "original",
|
||||
items: "> *",
|
||||
opacity: false,
|
||||
placeholder: false,
|
||||
revert: false,
|
||||
scroll: true,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 20,
|
||||
scope: "default",
|
||||
tolerance: "intersect",
|
||||
zIndex: 1000,
|
||||
|
||||
// callbacks
|
||||
activate: null,
|
||||
beforeStop: null,
|
||||
change: null,
|
||||
create: null,
|
||||
deactivate: null,
|
||||
out: null,
|
||||
over: null,
|
||||
receive: null,
|
||||
remove: null,
|
||||
sort: null,
|
||||
start: null,
|
||||
stop: null,
|
||||
update: null
|
||||
}
|
||||
});
|
40
jquery-ui/tests/unit/sortable/sortable_core.js
vendored
Normal file
40
jquery-ui/tests/unit/sortable/sortable_core.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* sortable_core.js
|
||||
*/
|
||||
|
||||
(function( $ ) {
|
||||
|
||||
module( "sortable: core" );
|
||||
|
||||
test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() {
|
||||
expect( 1 );
|
||||
|
||||
var el = $( ".connectWith" ).sortable({
|
||||
connectWith: ".connectWith"
|
||||
});
|
||||
|
||||
TestHelpers.sortable.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
|
||||
});
|
||||
|
||||
test( "ui-sortable-handle applied to appropriate element", function() {
|
||||
expect( 6 );
|
||||
var item = "<li><p></p></li>",
|
||||
el = $( "<ul>" + item + item + "</ul>" )
|
||||
.sortable()
|
||||
.appendTo( "#qunit-fixture" );
|
||||
|
||||
ok( el.find( "li:first" ).hasClass( "ui-sortable-handle" ), "defaults to item" );
|
||||
ok( el.find( "li:last" ).hasClass( "ui-sortable-handle" ), "both items received class name" );
|
||||
|
||||
el.sortable( "option", "handle", "p" );
|
||||
ok( !el.find( "li" ).hasClass( "ui-sortable-handle" ), "removed on change" );
|
||||
ok( el.find( "p" ).hasClass( "ui-sortable-handle" ), "applied to handle" );
|
||||
|
||||
el.append( item ).sortable( "refresh" );
|
||||
ok( el.find( "p:last" ).hasClass( "ui-sortable-handle" ), "class name applied on refresh" );
|
||||
|
||||
el.sortable( "destroy" );
|
||||
equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );
|
||||
});
|
||||
|
||||
})( jQuery );
|
378
jquery-ui/tests/unit/sortable/sortable_events.js
vendored
Normal file
378
jquery-ui/tests/unit/sortable/sortable_events.js
vendored
Normal file
|
@ -0,0 +1,378 @@
|
|||
/*
|
||||
* sortable_events.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("sortable: events");
|
||||
|
||||
test("start", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
start: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
// 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");
|
||||
|
||||
|
||||
});
|
||||
|
||||
test("sort", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
sort: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
});
|
||||
|
||||
test("change", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
|
||||
ok(!hash, "1px drag, change event should not be triggered");
|
||||
|
||||
$("#sortable").sortable({
|
||||
change: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
});
|
||||
|
||||
test("beforeStop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
beforeStop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
});
|
||||
|
||||
test("stop", function() {
|
||||
expect( 7 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
stop: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
});
|
||||
|
||||
test("update", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash;
|
||||
$("#sortable").sortable({
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).find("li:eq(0)").simulate( "drag", {
|
||||
dx: 1,
|
||||
dy: 1
|
||||
});
|
||||
|
||||
ok(!hash, "1px drag, update event should not be triggered");
|
||||
|
||||
$("#sortable").sortable({
|
||||
update: function( e, ui ) {
|
||||
hash = ui;
|
||||
}
|
||||
}).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");
|
||||
|
||||
});
|
||||
|
||||
test("#3019: Stop fires too early", function() {
|
||||
expect(2);
|
||||
|
||||
var helper = null,
|
||||
el = $("#sortable").sortable({
|
||||
stop: function(event, ui) {
|
||||
helper = ui.helper;
|
||||
}
|
||||
});
|
||||
|
||||
TestHelpers.sortable.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 () {
|
||||
expect( 10 );
|
||||
|
||||
var fired = {},
|
||||
hasFired = function (type) { return (type in fired) && (true === fired[type]); };
|
||||
|
||||
$("#sortable").clone().attr("id", "sortable2").insertAfter("#sortable");
|
||||
|
||||
$("#qunit-fixture ul").sortable({
|
||||
connectWith: "#qunit-fixture ul",
|
||||
change: function () {
|
||||
fired.change = true;
|
||||
},
|
||||
receive: function () {
|
||||
fired.receive = true;
|
||||
},
|
||||
remove: function () {
|
||||
fired.remove = true;
|
||||
}
|
||||
});
|
||||
|
||||
$("#qunit-fixture ul").bind("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");
|
||||
|
||||
// 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");
|
||||
|
||||
// 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");
|
||||
});
|
||||
|
||||
/*
|
||||
test("receive", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test("remove", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "over", function() {
|
||||
expect( 8 );
|
||||
|
||||
var hash,
|
||||
overCount = 0;
|
||||
|
||||
$( "#sortable" ).sortable({
|
||||
over: function( e, ui ) {
|
||||
hash = ui;
|
||||
overCount++;
|
||||
}
|
||||
}).find( "li:eq(0)" ).simulate( "drag", {
|
||||
dy: 20
|
||||
});
|
||||
|
||||
ok( hash, "over event triggered" );
|
||||
ok( hash.helper, "UI 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 includes: sender" );
|
||||
equal( overCount, 1, "over fires only once" );
|
||||
});
|
||||
|
||||
// http://bugs.jqueryui.com/ticket/9335
|
||||
// Sortable: over & out events does not consistently fire
|
||||
test( "over, fires with draggable connected to sortable", function() {
|
||||
expect( 3 );
|
||||
|
||||
var hash,
|
||||
overCount = 0,
|
||||
item = $( "<div></div>" ).text( "6" ).insertAfter( "#sortable" );
|
||||
|
||||
item.draggable({
|
||||
connectToSortable: "#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 );
|
||||
|
||||
var hash,
|
||||
overCount = 0;
|
||||
|
||||
$( ".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( overCount, 1, "over fires only once" );
|
||||
});
|
||||
|
||||
/*
|
||||
test("out", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "out, with connected sortable", function() {
|
||||
expect( 2 );
|
||||
|
||||
var hash,
|
||||
outCount = 0;
|
||||
|
||||
$( ".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 );
|
||||
|
||||
var outCount = 0,
|
||||
overCount = 0;
|
||||
|
||||
$( ".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", {
|
||||
dy: -40
|
||||
});
|
||||
|
||||
equal( outCount, 2, "out fires twice" );
|
||||
equal( overCount, 4, "over fires four times" );
|
||||
});
|
||||
|
||||
/*
|
||||
test("activate", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test("deactivate", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
})(jQuery);
|
128
jquery-ui/tests/unit/sortable/sortable_methods.js
vendored
Normal file
128
jquery-ui/tests/unit/sortable/sortable_methods.js
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* sortable_methods.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("sortable: methods");
|
||||
|
||||
test("init", function() {
|
||||
expect(5);
|
||||
|
||||
$("<div></div>").appendTo("body").sortable().remove();
|
||||
ok(true, ".sortable() called on element");
|
||||
|
||||
$([]).sortable();
|
||||
ok(true, ".sortable() called on empty collection");
|
||||
|
||||
$("<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", "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");
|
||||
|
||||
$([]).sortable().sortable("destroy");
|
||||
ok(true, ".sortable('destroy') called on empty collection");
|
||||
|
||||
$("<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");
|
||||
});
|
||||
|
||||
test("enable", function() {
|
||||
expect(5);
|
||||
|
||||
var el, actual, expected;
|
||||
|
||||
el = $("#sortable").sortable({ disabled: true });
|
||||
|
||||
TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })");
|
||||
|
||||
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");
|
||||
|
||||
TestHelpers.sortable.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");
|
||||
});
|
||||
|
||||
test( "disable", function() {
|
||||
expect( 9 );
|
||||
|
||||
var chainable,
|
||||
element = $( "#sortable" ).sortable({ disabled: false });
|
||||
|
||||
TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
|
||||
|
||||
chainable = element.sortable( "disable" );
|
||||
TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" );
|
||||
|
||||
element.sortable( "destroy" );
|
||||
|
||||
element.sortable({ disabled: false });
|
||||
TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
|
||||
element.sortable( "option", "disabled", true);
|
||||
equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
|
||||
|
||||
ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
|
||||
ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
||||
ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" );
|
||||
|
||||
TestHelpers.sortable.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 );
|
||||
|
||||
var changeCount = 0,
|
||||
element = $( "#qunit-fixture" ).html( "<ul></ul>" ).find( "ul" );
|
||||
|
||||
element
|
||||
.css({
|
||||
"float": "left",
|
||||
width: "100px"
|
||||
})
|
||||
.sortable({
|
||||
change: function() {
|
||||
changeCount++;
|
||||
}
|
||||
})
|
||||
.append( "<li>a</li><li>a</li>" )
|
||||
.find( "li" )
|
||||
.css({
|
||||
"float": "left",
|
||||
width: "50px",
|
||||
height: "50px"
|
||||
});
|
||||
|
||||
element.sortable( "refresh" );
|
||||
|
||||
// Switch the order of the two li elements
|
||||
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
||||
dx: 55,
|
||||
moves: 15
|
||||
});
|
||||
|
||||
equal( changeCount, 1 );
|
||||
});
|
||||
|
||||
})(jQuery);
|
496
jquery-ui/tests/unit/sortable/sortable_options.js
vendored
Normal file
496
jquery-ui/tests/unit/sortable/sortable_options.js
vendored
Normal file
|
@ -0,0 +1,496 @@
|
|||
/*
|
||||
* sortable_options.js
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
module("sortable: options");
|
||||
|
||||
/*
|
||||
test("{ appendTo: 'parent' }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test("{ appendTo: Selector }", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "{ axis: false }, default", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
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();
|
||||
|
||||
item.simulate( "drag", {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ axis: 'x' }", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
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();
|
||||
|
||||
item.simulate( "drag", {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ axis: 'y' }", function() {
|
||||
expect( 2 );
|
||||
|
||||
var offsetAfter,
|
||||
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();
|
||||
|
||||
item.simulate( "drag", {
|
||||
dx: 50,
|
||||
dy: 25,
|
||||
moves: 1
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() {
|
||||
expect( 2 );
|
||||
var expectedLeft,
|
||||
element = $( "#sortable" ).sortable({
|
||||
axis: "y",
|
||||
revert: true,
|
||||
sort: function() {
|
||||
expectedLeft = item.css( "left" );
|
||||
}
|
||||
}),
|
||||
item = element.find( "li" ).eq( 0 );
|
||||
|
||||
item.simulate( "drag", {
|
||||
dy: 300,
|
||||
dx: 50
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
var top = parseFloat( item.css( "top" ) );
|
||||
equal( item.css( "left" ), expectedLeft, "left not animated" );
|
||||
ok( top > 0 && top < 300, "top is animated" );
|
||||
start();
|
||||
}, 100 );
|
||||
});
|
||||
|
||||
/*
|
||||
test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test("{ cancel: Selector }", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "#8792: issues with floated items in connected lists", function() {
|
||||
expect( 2 );
|
||||
|
||||
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>" )
|
||||
.find( "ul" ).css({ "float": "left", width: "100px" }).end()
|
||||
.find( "li" ).css({ "float": "left", width: "50px", height: "50px" });
|
||||
|
||||
$( "#qunit-fixture .c" ).sortable({
|
||||
connectWith: "#qunit-fixture .c",
|
||||
change: function() {
|
||||
changeCount++;
|
||||
}
|
||||
});
|
||||
|
||||
element = $( "#qunit-fixture li:eq(0)" );
|
||||
|
||||
// move the first li to the right of the second li in the first ul
|
||||
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" );
|
||||
|
||||
// move the first li ( which is now in the second spot )
|
||||
// through the first spot in the second ul to the second spot in the second ul
|
||||
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({
|
||||
axis: "y",
|
||||
tolerance: "pointer",
|
||||
connectWith: ".connected"
|
||||
});
|
||||
|
||||
$( "<ul class='connected'><li>Item 7</li><li>Item 8</li></ul>" )
|
||||
.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() {
|
||||
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.");
|
||||
});
|
||||
|
||||
test("{ forcePlaceholderSize: false }, default", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
test("{ forcePlaceholderSize: true }", function() {
|
||||
ok(false, "missing test - untested code is broken code.");
|
||||
});
|
||||
|
||||
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.");
|
||||
});
|
||||
*/
|
||||
|
||||
test( "{ placeholder: false } img", function() {
|
||||
expect( 3 );
|
||||
|
||||
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() {
|
||||
expect( 1 );
|
||||
|
||||
var element = $( "#sortable" ).sortable({
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
}
|
||||
});
|
||||
|
||||
element.find( "li" ).eq( 0 ).simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ placholder: String } tr", function() {
|
||||
expect( 4 );
|
||||
|
||||
var originalWidths,
|
||||
element = $( "#sortable-table tbody" ).sortable({
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
var currentWidths = otherRow.children().map(function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
deepEqual( currentWidths, originalWidths, "table cells maintian size" );
|
||||
equal( ui.placeholder.children().length, dragRow.children().length,
|
||||
"placeholder has correct number of cells" );
|
||||
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() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
dragRow.simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
|
||||
test( "{ placholder: String } tbody", function() {
|
||||
expect( 6 );
|
||||
|
||||
var originalWidths,
|
||||
element = $( "#sortable-table" ).sortable({
|
||||
placeholder: "test",
|
||||
start: function( event, ui ) {
|
||||
var currentWidths = otherBody.children().map(function() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
ok( ui.placeholder.hasClass( "test" ), "placeholder has class" );
|
||||
deepEqual( currentWidths, originalWidths, "table cells maintain size" );
|
||||
equal( ui.placeholder.children().length, 1,
|
||||
"placeholder has one child" );
|
||||
equal( ui.placeholder.children( "tr" ).length, 1,
|
||||
"placeholder's child is tr" );
|
||||
equal( ui.placeholder.find( "> tr" ).children().length,
|
||||
dragBody.find( "> tr:first" ).children().length,
|
||||
"placeholder's tr has correct number of cells" );
|
||||
equal( ui.placeholder.find( "> tr" ).children().html(),
|
||||
$( "<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() {
|
||||
return $( this ).width();
|
||||
}).get();
|
||||
dragBody.simulate( "drag", {
|
||||
dy: 1
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
test("{ revert: false }, default", function() {
|
||||
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.");
|
||||
});
|
||||
*/
|
||||
})(jQuery);
|
9
jquery-ui/tests/unit/sortable/sortable_test_helpers.js
vendored
Normal file
9
jquery-ui/tests/unit/sortable/sortable_test_helpers.js
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
TestHelpers.sortable = {
|
||||
sort: function( handle, dx, dy, index, msg ) {
|
||||
$( handle ).simulate( "drag", {
|
||||
dx: dx,
|
||||
dy: dy
|
||||
});
|
||||
equal( $( handle ).parent().children().index( handle ), index, msg );
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue