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
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
$("<div></div>").appendTo("body").selectable().remove();
|
|
|
|
ok(true, ".selectable() called on element");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
$([]).selectable().remove();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".selectable() called on empty collection");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
$("<div></div>").selectable().remove();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".selectable() called on disconnected DOMElement");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
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();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "arbitrary option getter after init");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$("<div></div>").selectable().selectable("option", "foo", "bar").remove();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, "arbitrary option setter after init");
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
2012-10-31 01:50:08 +00:00
|
|
|
expect( 4 );
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
$("<div></div>").appendTo("body").selectable().selectable("destroy").remove();
|
|
|
|
ok(true, ".selectable('destroy') called on element");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
$([]).selectable().selectable("destroy").remove();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".selectable('destroy') called on empty collection");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
$("<div></div>").selectable().selectable("destroy").remove();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(true, ".selectable('destroy') called on disconnected DOMElement");
|
2009-02-04 04:53:09 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
var expected = $("<div></div>").selectable(),
|
|
|
|
actual = expected.selectable("destroy");
|
|
|
|
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-12-26 13:08:48 +00:00
|
|
|
expected = $("<div></div>").selectable();
|
|
|
|
actual = expected.selectable("enable");
|
|
|
|
equal(actual, expected, "enable is chainable");
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
2013-03-14 23:08:21 +00:00
|
|
|
test( "disable", function() {
|
|
|
|
expect( 6 );
|
|
|
|
var chainable,
|
2012-10-31 01:50:08 +00:00
|
|
|
fired = false,
|
2013-03-14 23:08:21 +00:00
|
|
|
element = $( "#selectable1" );
|
2009-02-04 04:53:09 +00:00
|
|
|
|
2013-03-14 23:08:21 +00:00
|
|
|
element.selectable({
|
2009-02-04 04:53:09 +00:00
|
|
|
disabled: false,
|
2013-03-14 23:08:21 +00:00
|
|
|
start: function() {
|
|
|
|
fired = true;
|
|
|
|
}
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
2013-03-14 23:08:21 +00:00
|
|
|
element.simulate( "drag", {
|
2012-12-09 02:27:37 +00:00
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2013-03-14 23:08:21 +00:00
|
|
|
equal( fired, true, "start fired" );
|
|
|
|
|
|
|
|
chainable = element.selectable( "disable" );
|
2009-02-04 04:53:09 +00:00
|
|
|
fired = false;
|
2012-12-09 02:27:37 +00:00
|
|
|
|
2013-03-14 23:08:21 +00:00
|
|
|
element.simulate( "drag", {
|
2012-12-09 02:27:37 +00:00
|
|
|
dx: 20,
|
|
|
|
dy: 20
|
|
|
|
});
|
2013-03-14 23:08:21 +00:00
|
|
|
equal( fired, false, "start fired" );
|
2013-03-12 01:28:51 +00:00
|
|
|
|
2013-03-14 23:08:21 +00:00
|
|
|
ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
|
|
|
|
ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
|
|
|
|
ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" );
|
|
|
|
|
|
|
|
element.selectable( "destroy" );
|
|
|
|
|
|
|
|
equal( chainable, element, "disable is chainable" );
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|