2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* selectable_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("selectable: methods");
|
|
|
|
|
2009-02-04 04:53:09 +00:00
|
|
|
test("init", function() {
|
2012-10-31 01:50:08 +00:00
|
|
|
expect( 5 );
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
$("<div></div>").appendTo('body').selectable().remove();
|
|
|
|
ok(true, '.selectable() called on element');
|
|
|
|
|
|
|
|
$([]).selectable().remove();
|
|
|
|
ok(true, '.selectable() called on empty collection');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().remove();
|
|
|
|
ok(true, '.selectable() called on disconnected DOMElement');
|
|
|
|
|
2012-10-31 01:50:08 +00:00
|
|
|
var el = $("<div></div>").selectable();
|
2012-10-23 14:36:42 +00:00
|
|
|
el.selectable("option", "foo");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.remove();
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$("<div></div>").selectable().selectable("option", "foo", "bar").remove();
|
2009-02-04 04:53:09 +00:00
|
|
|
ok(true, 'arbitrary option setter after init');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
2012-10-31 01:50:08 +00:00
|
|
|
expect( 4 );
|
|
|
|
|
2009-02-04 04:53:09 +00:00
|
|
|
$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on element');
|
|
|
|
|
|
|
|
$([]).selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on empty collection');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on disconnected DOMElement');
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').selectable(),
|
|
|
|
actual = expected.selectable('destroy');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'destroy is chainable');
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(3);
|
2012-04-19 02:46:39 +00:00
|
|
|
var expected, actual,
|
2012-10-31 01:50:08 +00:00
|
|
|
fired = false,
|
|
|
|
el = $("#selectable1");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
el.selectable({
|
|
|
|
disabled: true,
|
|
|
|
start: function() { fired = true; }
|
|
|
|
});
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, false, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("enable");
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, true, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("destroy");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
expected = $('<div></div>').selectable();
|
|
|
|
actual = expected.selectable('enable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'enable is chainable');
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(3);
|
2012-04-19 02:46:39 +00:00
|
|
|
var expected, actual,
|
2012-10-31 01:50:08 +00:00
|
|
|
fired = false,
|
|
|
|
el = $("#selectable1");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
el.selectable({
|
|
|
|
disabled: false,
|
|
|
|
start: function() { fired = true; }
|
|
|
|
});
|
2012-12-09 02:27:37 +00:00
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, true, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("disable");
|
|
|
|
fired = false;
|
2012-12-09 02:27:37 +00:00
|
|
|
|
|
|
|
el.simulate( "drag", {
|
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, false, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("destroy");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
expected = $('<div></div>').selectable();
|
|
|
|
actual = expected.selectable('disable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'disable is chainable');
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|