2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* sortable_events.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("sortable: events");
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
test("start", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
var hash;
|
|
|
|
$("#sortable")
|
|
|
|
.sortable({ start: function(e, ui) { hash = ui; } })
|
|
|
|
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
|
|
|
|
|
|
|
ok(hash, 'start event triggered');
|
|
|
|
ok(hash.helper, 'UI hash includes: helper');
|
|
|
|
ok(hash.placeholder, 'UI hash includes: placeholder');
|
|
|
|
ok(hash.position && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("sort", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
var hash;
|
|
|
|
$("#sortable")
|
|
|
|
.sortable({ sort: function(e, ui) { hash = ui; } })
|
|
|
|
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
|
|
|
|
|
|
|
ok(hash, 'sort event triggered');
|
|
|
|
ok(hash.helper, 'UI hash includes: helper');
|
|
|
|
ok(hash.placeholder, 'UI hash includes: placeholder');
|
|
|
|
ok(hash.position && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("change", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
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", { dx: 0, dy: 20 });
|
|
|
|
|
|
|
|
ok(hash, 'change event triggered');
|
|
|
|
ok(hash.helper, 'UI hash includes: helper');
|
|
|
|
ok(hash.placeholder, 'UI hash includes: placeholder');
|
|
|
|
ok(hash.position && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("beforeStop", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
var hash;
|
|
|
|
$("#sortable")
|
|
|
|
.sortable({ beforeStop: function(e, ui) { hash = ui; } })
|
|
|
|
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
|
|
|
|
|
|
|
ok(hash, 'beforeStop event triggered');
|
|
|
|
ok(hash.helper, 'UI hash includes: helper');
|
|
|
|
ok(hash.placeholder, 'UI hash includes: placeholder');
|
|
|
|
ok(hash.position && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("stop", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
var hash;
|
|
|
|
$("#sortable")
|
|
|
|
.sortable({ stop: function(e, ui) { hash = ui; } })
|
|
|
|
.find('li:eq(0)').simulate("drag", { dx: 0, 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 && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("update", function() {
|
2009-02-06 07:39:52 +00:00
|
|
|
|
|
|
|
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", { dx: 0, dy: 20 });
|
|
|
|
|
|
|
|
ok(hash, 'update event triggered');
|
|
|
|
ok(!hash.helper, 'UI hash should not include: helper');
|
|
|
|
ok(hash.placeholder, 'UI hash includes: placeholder');
|
|
|
|
ok(hash.position && (hash.position.top && hash.position.left), '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');
|
|
|
|
|
2009-02-03 00:33:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("out", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate", function() {
|
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("deactivate", function() {
|
2009-02-02 14:36:08 +00:00
|
|
|
ok(false, "missing test - untested code is broken code.");
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|