2009-02-01 00:25:58 +00:00
|
|
|
/*
|
|
|
|
* draggable_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("draggable: methods");
|
|
|
|
|
|
|
|
test("init", function() {
|
2012-10-30 23:12:17 +00:00
|
|
|
expect(5);
|
2009-02-01 00:25:58 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
$("<div></div>").appendTo("body").draggable().remove();
|
|
|
|
ok(true, ".draggable() called on element");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
$([]).draggable();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".draggable() called on empty collection");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
$("<div></div>").draggable();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".draggable() called on disconnected DOMElement");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$("<div></div>").draggable().draggable("option", "foo");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "arbitrary option getter after init");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$("<div></div>").draggable().draggable("option", "foo", "bar");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "arbitrary option setter after init");
|
2009-02-01 00:25:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
2012-10-30 23:12:17 +00:00
|
|
|
expect(4);
|
2012-12-26 13:08:48 +00:00
|
|
|
$("<div></div>").appendTo("body").draggable().draggable("destroy").remove();
|
|
|
|
ok(true, ".draggable('destroy') called on element");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
$([]).draggable().draggable("destroy");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".draggable('destroy') called on empty collection");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
$("<div></div>").draggable().draggable("destroy");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".draggable('destroy') called on disconnected DOMElement");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
var expected = $("<div></div>").draggable(),
|
|
|
|
actual = expected.draggable("destroy");
|
|
|
|
equal(actual, expected, "destroy is chainable");
|
2009-02-01 00:25:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(7);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
|
|
|
var expected, actual, el;
|
|
|
|
|
2009-02-01 00:25:58 +00:00
|
|
|
el = $("#draggable2").draggable({ disabled: true });
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
|
2012-10-30 23:12:17 +00:00
|
|
|
|
2009-02-01 00:25:58 +00:00
|
|
|
el.draggable("enable");
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el, ".draggable('enable')");
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.draggable("option", "disabled"), false, "disabled option getter");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
el.draggable("destroy");
|
|
|
|
el.draggable({ disabled: true });
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
|
2012-10-30 23:12:17 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
el.draggable("option", "disabled", false);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.draggable("option", "disabled"), false, "disabled option setter");
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
expected = $("<div></div>").draggable(),
|
|
|
|
actual = expected.draggable("enable");
|
|
|
|
equal(actual, expected, "enable is chainable");
|
2009-02-01 00:25:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(7);
|
2012-11-03 20:17:16 +00:00
|
|
|
|
|
|
|
var expected, actual, el;
|
|
|
|
|
2009-02-01 00:25:58 +00:00
|
|
|
el = $("#draggable2").draggable({ disabled: false });
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
|
2012-10-30 23:12:17 +00:00
|
|
|
|
2009-02-01 00:25:58 +00:00
|
|
|
el.draggable("disable");
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')");
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.draggable("option", "disabled"), true, "disabled option getter");
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
el.draggable("destroy");
|
|
|
|
|
|
|
|
el.draggable({ disabled: false });
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
|
2012-10-30 23:12:17 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
el.draggable("option", "disabled", true);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.draggable("option", "disabled"), true, "disabled option setter");
|
2012-12-26 13:08:48 +00:00
|
|
|
TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
expected = $("<div></div>").draggable(),
|
|
|
|
actual = expected.draggable("disable");
|
|
|
|
equal(actual, expected, "disable is chainable");
|
2009-02-01 00:25:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|