mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Tests: Lint.
This commit is contained in:
parent
58a120bb4b
commit
0a5a9090f8
21
grunt.js
21
grunt.js
@ -350,27 +350,46 @@ grunt.initConfig({
|
||||
accordion_state: true,
|
||||
asyncTest: true,
|
||||
commonWidgetTests: true,
|
||||
container: true,
|
||||
deepEqual: true,
|
||||
d1: true,
|
||||
d2: true,
|
||||
dlg: true,
|
||||
domEqual: true,
|
||||
drag: true,
|
||||
dragged: true,
|
||||
el: true,
|
||||
equal: true,
|
||||
expect: true,
|
||||
Globalize: true,
|
||||
heightAfter: true,
|
||||
isNotOpen: true,
|
||||
isOpen: true,
|
||||
menu_click: true,
|
||||
menu_log: true,
|
||||
modal: true,
|
||||
module: true,
|
||||
moved: true,
|
||||
notEqual: true,
|
||||
offsetAfter: true,
|
||||
offsetBefore: true,
|
||||
ok: true,
|
||||
QUnit: true,
|
||||
restoreScroll: true,
|
||||
shouldBeDroppable: true,
|
||||
shouldmove: true,
|
||||
shouldNotBeDroppable: true,
|
||||
shouldnotmove: true,
|
||||
shouldnotresize: true,
|
||||
shouldresize: true,
|
||||
spinner_simulateKeyDownUp: true,
|
||||
start: true,
|
||||
strictEqual: true,
|
||||
stop: true,
|
||||
tabs_state: true,
|
||||
tabs_disabled: true,
|
||||
test: true
|
||||
test: true,
|
||||
widthAfter: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -40,8 +40,8 @@ function drag(handle, dx, dy) {
|
||||
|
||||
function moved(dx, dy, msg) {
|
||||
msg = msg ? msg + "." : "";
|
||||
var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) };
|
||||
var expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
|
||||
var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) },
|
||||
expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
|
||||
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
|
||||
}
|
||||
|
||||
@ -59,8 +59,8 @@ function shouldnotmove(why) {
|
||||
|
||||
function resized(dw, dh, msg) {
|
||||
msg = msg ? msg + "." : "";
|
||||
var actual = { width: widthAfter, height: heightAfter };
|
||||
var expected = { width: widthBefore + dw, height: heightBefore + dh };
|
||||
var actual = { width: widthAfter, height: heightAfter },
|
||||
expected = { width: widthBefore + dw, height: heightBefore + dh };
|
||||
deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,8 @@ test("dragStart", function() {
|
||||
|
||||
test("drag", function() {
|
||||
expect(9);
|
||||
var hasDragged = false;
|
||||
var handle,
|
||||
hasDragged = false;
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
drag: function(ev, ui) {
|
||||
@ -83,7 +84,7 @@ test("drag", function() {
|
||||
ok(ui.position !== undefined, "ui.position in callback");
|
||||
ok(ui.offset !== undefined, "ui.offset in callback");
|
||||
});
|
||||
var handle = $(".ui-dialog-titlebar", dlg());
|
||||
handle = $(".ui-dialog-titlebar", dlg());
|
||||
drag(handle, 50, 50);
|
||||
el.remove();
|
||||
});
|
||||
@ -138,7 +139,8 @@ test("resizeStart", function() {
|
||||
|
||||
test("resize", function() {
|
||||
expect(13);
|
||||
var hasResized = false;
|
||||
var handle,
|
||||
hasResized = false;
|
||||
|
||||
el = $('<div></div>').dialog({
|
||||
resize: function(ev, ui) {
|
||||
@ -162,7 +164,7 @@ test("resize", function() {
|
||||
ok(ui.position !== undefined, "ui.position in callback");
|
||||
ok(ui.size !== undefined, "ui.size in callback");
|
||||
});
|
||||
var handle = $(".ui-resizable-se", dlg());
|
||||
handle = $(".ui-resizable-se", dlg());
|
||||
drag(handle, 50, 50);
|
||||
el.remove();
|
||||
});
|
||||
|
@ -98,14 +98,17 @@ test("isOpen", function() {
|
||||
});
|
||||
|
||||
test("moveToTop", function() {
|
||||
var expected = $('<div></div>').dialog(),
|
||||
var d1, d2, dlg1, dlg2,
|
||||
expected = $('<div></div>').dialog(),
|
||||
actual = expected.dialog('moveToTop');
|
||||
equal(actual, expected, 'moveToTop is chainable');
|
||||
|
||||
var d1 = $('<div></div>').dialog(), dlg1 = d1.parents('.ui-dialog');
|
||||
d1 = $('<div></div>').dialog();
|
||||
dlg1 = d1.parents('.ui-dialog');
|
||||
d1.dialog('close');
|
||||
d1.dialog('open');
|
||||
var d2 = $('<div></div>').dialog(), dlg2 = d2.parents('.ui-dialog');
|
||||
d2 = $('<div></div>').dialog();
|
||||
dlg2 = d2.parents('.ui-dialog');
|
||||
d2.dialog('close');
|
||||
d2.dialog('open');
|
||||
ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called');
|
||||
|
@ -20,7 +20,8 @@ test("autoOpen", function() {
|
||||
test("buttons", function() {
|
||||
expect(21);
|
||||
|
||||
var buttons = {
|
||||
var btn, i, newButtons,
|
||||
buttons = {
|
||||
"Ok": function(ev, ui) {
|
||||
ok(true, "button click fires callback");
|
||||
equal(this, el[0], "context of callback");
|
||||
@ -34,10 +35,10 @@ test("buttons", function() {
|
||||
};
|
||||
|
||||
el = $('<div></div>').dialog({ buttons: buttons });
|
||||
var btn = $("button", dlg());
|
||||
btn = $("button", dlg());
|
||||
equal(btn.length, 2, "number of buttons");
|
||||
|
||||
var i = 0;
|
||||
i = 0;
|
||||
$.each(buttons, function(key, val) {
|
||||
equal(btn.eq(i).text(), key, "text of button " + (i+1));
|
||||
i++;
|
||||
@ -48,7 +49,7 @@ test("buttons", function() {
|
||||
|
||||
btn.trigger("click");
|
||||
|
||||
var newButtons = {
|
||||
newButtons = {
|
||||
"Close": function(ev, ui) {
|
||||
ok(true, "button click fires callback");
|
||||
equal(this, el[0], "context of callback");
|
||||
@ -275,54 +276,54 @@ test("minWidth", function() {
|
||||
});
|
||||
|
||||
test("position, default center on window", function() {
|
||||
var el = $('<div></div>').dialog();
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog(),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
||||
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("position, top on window", function() {
|
||||
var el = $('<div></div>').dialog({ position: "top" });
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog({ position: "top" }),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
|
||||
deepEqual(offset.top, $(window).scrollTop());
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("position, left on window", function() {
|
||||
var el = $('<div></div>').dialog({ position: "left" });
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog({ position: "left" }),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, 0);
|
||||
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("position, right bottom on window", function() {
|
||||
var el = $('<div></div>').dialog({ position: "right bottom" });
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog({ position: "right bottom" }),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("position, right bottom on window w/array", function() {
|
||||
var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog({ position: ["right", "bottom"] }),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("position, offset from top left w/array", function() {
|
||||
var el = $('<div></div>').dialog({ position: [10, 10] });
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
var el = $('<div></div>').dialog({ position: [10, 10] }),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
deepEqual(offset.left, 10 + $(window).scrollLeft());
|
||||
deepEqual(offset.top, 10 + $(window).scrollTop());
|
||||
el.remove();
|
||||
@ -330,14 +331,13 @@ test("position, offset from top left w/array", function() {
|
||||
|
||||
test("position, right bottom at right bottom via ui.position args", function() {
|
||||
var el = $('<div></div>').dialog({
|
||||
position: {
|
||||
my: "right bottom",
|
||||
at: "right bottom"
|
||||
}
|
||||
});
|
||||
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
position: {
|
||||
my: "right bottom",
|
||||
at: "right bottom"
|
||||
}
|
||||
}),
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
|
||||
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
|
||||
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
|
||||
@ -346,23 +346,23 @@ test("position, right bottom at right bottom via ui.position args", function() {
|
||||
|
||||
test("position, at another element", function() {
|
||||
var parent = $('<div></div>').css({
|
||||
position: 'absolute',
|
||||
top: 400,
|
||||
left: 600,
|
||||
height: 10,
|
||||
width: 10
|
||||
}).appendTo('body');
|
||||
position: 'absolute',
|
||||
top: 400,
|
||||
left: 600,
|
||||
height: 10,
|
||||
width: 10
|
||||
}).appendTo('body'),
|
||||
|
||||
var el = $('<div></div>').dialog({
|
||||
position: {
|
||||
my: "left top",
|
||||
at: "left top",
|
||||
of: parent
|
||||
}
|
||||
});
|
||||
el = $('<div></div>').dialog({
|
||||
position: {
|
||||
my: "left top",
|
||||
at: "left top",
|
||||
of: parent
|
||||
}
|
||||
}),
|
||||
|
||||
var dialog = el.dialog('widget');
|
||||
var offset = dialog.offset();
|
||||
dialog = el.dialog('widget'),
|
||||
offset = dialog.offset();
|
||||
|
||||
deepEqual(offset.left, 600);
|
||||
deepEqual(offset.top, 400);
|
||||
@ -373,7 +373,7 @@ test("position, at another element", function() {
|
||||
of: parent
|
||||
});
|
||||
|
||||
var offset = dialog.offset();
|
||||
offset = dialog.offset();
|
||||
|
||||
deepEqual(offset.left, 610);
|
||||
deepEqual(offset.top, 410);
|
||||
|
@ -12,12 +12,6 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
|
||||
inputs = el.find( "input" ),
|
||||
widget = el.dialog( "widget" );
|
||||
|
||||
inputs.eq( 1 ).focus();
|
||||
equal( document.activeElement, inputs[1], "Focus set on second input" );
|
||||
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
|
||||
|
||||
setTimeout( checkTab, 2 );
|
||||
|
||||
function checkTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
|
||||
|
||||
@ -32,14 +26,21 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
|
||||
el.remove();
|
||||
start();
|
||||
}
|
||||
|
||||
inputs.eq( 1 ).focus();
|
||||
equal( document.activeElement, inputs[1], "Focus set on second input" );
|
||||
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
|
||||
|
||||
setTimeout( checkTab, 2 );
|
||||
});
|
||||
|
||||
test("#4826: setting resizable false toggles resizable on dialog", function() {
|
||||
expect(6);
|
||||
var i;
|
||||
|
||||
el = $('<div></div>').dialog({ resizable: false });
|
||||
shouldnotresize("[default]");
|
||||
for (var i=0; i<2; i++) {
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('open');
|
||||
shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
@ -47,7 +48,7 @@ test("#4826: setting resizable false toggles resizable on dialog", function() {
|
||||
|
||||
el = $('<div></div>').dialog({ resizable: true });
|
||||
shouldresize("[default]");
|
||||
for (var i=0; i<2; i++) {
|
||||
for (i=0; i<2; i++) {
|
||||
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
|
||||
shouldnotresize('set option resizable false toggle ('+ (i+1) +')');
|
||||
}
|
||||
@ -108,7 +109,7 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
|
||||
test("#6645: Missing element not found check in overlay", function(){
|
||||
expect(2);
|
||||
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
|
||||
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
|
||||
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
|
||||
equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
|
||||
d2.dialog('close');
|
||||
equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
|
||||
@ -119,7 +120,7 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){
|
||||
expect(8);
|
||||
// test with close function removing dialog
|
||||
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
|
||||
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
|
||||
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
|
||||
ok(d1.dialog("isOpen"), 'first dialog is open');
|
||||
ok(d2.dialog("isOpen"), 'second dialog is open');
|
||||
d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
var el, offsetBefore, offsetAfter, dragged;
|
||||
|
||||
var drag = function(handle, dx, dy) {
|
||||
function drag(handle, dx, dy) {
|
||||
var element = el.data("draggable").element;
|
||||
offsetBefore = el.offset();
|
||||
$(handle).simulate("drag", {
|
||||
@ -15,10 +15,10 @@ var drag = function(handle, dx, dy) {
|
||||
offsetAfter = el.offset();
|
||||
}
|
||||
|
||||
var moved = function (dx, dy, msg) {
|
||||
function moved(dx, dy, msg) {
|
||||
msg = msg ? msg + "." : "";
|
||||
var actual = { left: offsetAfter.left, top: offsetAfter.top };
|
||||
var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
|
||||
var actual = { left: offsetAfter.left, top: offsetAfter.top },
|
||||
expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
|
||||
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
|
||||
}
|
||||
|
||||
@ -35,15 +35,15 @@ function restoreScroll(what) {
|
||||
module("draggable");
|
||||
|
||||
test("element types", function() {
|
||||
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
|
||||
+ ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
|
||||
+ ',acronym,code,samp,kbd,var,img,object,hr'
|
||||
+ ',input,button,label,select,iframe').split(',');
|
||||
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
|
||||
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
|
||||
',acronym,code,samp,kbd,var,img,object,hr' +
|
||||
',input,button,label,select,iframe').split(',');
|
||||
|
||||
$.each(typeNames, function(i) {
|
||||
var typeName = typeNames[i];
|
||||
el = $(document.createElement(typeName)).appendTo('body');
|
||||
(typeName == 'table' && el.append("<tr><td>content</td></tr>"));
|
||||
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
|
||||
el.draggable({ cancel: '' });
|
||||
drag(el, 50, 50);
|
||||
moved(50, 50, "<" + typeName + ">");
|
||||
|
@ -17,15 +17,16 @@ function setScroll(what) {
|
||||
}
|
||||
}
|
||||
|
||||
var border = function(el, side) { return parseInt(el.css('border-' + side + '-width')); }
|
||||
|
||||
var margin = function(el, side) { return parseInt(el.css('margin-' + side)); }
|
||||
function border(el, side) {
|
||||
return parseInt(el.css('border-' + side + '-width'), 10);
|
||||
}
|
||||
function margin(el, side) {
|
||||
return parseInt(el.css('margin-' + side), 10);
|
||||
}
|
||||
|
||||
module("draggable: options");
|
||||
|
||||
test("{ addClasses: true }, default", function() {
|
||||
equal(draggable_defaults.addClasses, true);
|
||||
|
||||
el = $("<div></div>").draggable({ addClasses: true });
|
||||
ok(el.is(".ui-draggable"), "'ui-draggable' class added");
|
||||
|
||||
@ -40,8 +41,6 @@ test("{ addClasses: false }", function() {
|
||||
});
|
||||
|
||||
test("{ appendTo: 'parent' }, default", function() {
|
||||
equal(draggable_defaults.appendTo, "parent");
|
||||
|
||||
el = $("#draggable2").draggable({ appendTo: 'parent' });
|
||||
drag(el, 50, 50);
|
||||
moved(50, 50);
|
||||
@ -73,8 +72,6 @@ test("{ appendTo: Selector }", function() {
|
||||
});
|
||||
|
||||
test("{ axis: false }, default", function() {
|
||||
equal(draggable_defaults.axis, false);
|
||||
|
||||
el = $("#draggable2").draggable({ axis: false });
|
||||
drag(el, 50, 50);
|
||||
moved(50, 50);
|
||||
@ -106,12 +103,10 @@ test("{ axis: ? }, unexpected", function() {
|
||||
drag(el, 50, 50);
|
||||
moved(50, 50, "axis: " + key);
|
||||
el.draggable("destroy");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
test("{ cancel: ':input,option' }, default", function() {
|
||||
equal(draggable_defaults.cancel, ":input,option");
|
||||
|
||||
$('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main');
|
||||
|
||||
el = $("#draggable-option-cancel-default").draggable({ cancel: ":input,option" });
|
||||
@ -155,12 +150,10 @@ test("{ cancel: ? }, unexpected", function() {
|
||||
var expected = [50, 50];
|
||||
moved(expected[0], expected[1], "cancel: " + key);
|
||||
el.draggable("destroy");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
test("{ containment: false }, default", function() {
|
||||
equal(draggable_defaults.containment, false);
|
||||
|
||||
ok(false, 'missing test - untested code is broken code');
|
||||
});
|
||||
|
||||
@ -170,23 +163,25 @@ test("{ containment: Element }", function() {
|
||||
|
||||
test("{ containment: 'parent' }, relative", function() {
|
||||
el = $("#draggable1").draggable({ containment: 'parent' });
|
||||
var p = el.parent(), po = p.offset();
|
||||
var p = el.parent(),
|
||||
po = p.offset(),
|
||||
expected = {
|
||||
left: po.left + border(p, 'left') + margin(el, 'left'),
|
||||
top: po.top + border(p, 'top') + margin(el, 'top')
|
||||
};
|
||||
drag(el, -100, -100);
|
||||
var expected = {
|
||||
left: po.left + border(p, 'left') + margin(el, 'left'),
|
||||
top: po.top + border(p, 'top') + margin(el, 'top')
|
||||
}
|
||||
deepEqual(offsetAfter, expected, 'compare offset to parent');
|
||||
});
|
||||
|
||||
test("{ containment: 'parent' }, absolute", function() {
|
||||
el = $("#draggable2").draggable({ containment: 'parent' });
|
||||
var p = el.parent(), po = p.offset();
|
||||
var p = el.parent(),
|
||||
po = p.offset(),
|
||||
expected = {
|
||||
left: po.left + border(p, 'left') + margin(el, 'left'),
|
||||
top: po.top + border(p, 'top') + margin(el, 'top')
|
||||
};
|
||||
drag(el, -100, -100);
|
||||
var expected = {
|
||||
left: po.left + border(p, 'left') + margin(el, 'left'),
|
||||
top: po.top + border(p, 'top') + margin(el, 'top')
|
||||
}
|
||||
deepEqual(offsetAfter, expected, 'compare offset to parent');
|
||||
});
|
||||
|
||||
@ -207,11 +202,9 @@ test("{ containment: [x1, y1, x2, y2] }", function() {
|
||||
});
|
||||
|
||||
test("{ cursor: 'auto' }, default", function() {
|
||||
equal(draggable_defaults.cursor, 'auto');
|
||||
|
||||
function getCursor() { return $("#draggable2").css("cursor"); }
|
||||
|
||||
expect(3);
|
||||
expect(2);
|
||||
|
||||
var expected = "auto", actual, before, after;
|
||||
|
||||
@ -256,8 +249,6 @@ test("{ cursor: 'move' }", function() {
|
||||
});
|
||||
|
||||
test("{ cursorAt: false}, default", function() {
|
||||
equal(draggable_defaults.cursorAt, false);
|
||||
|
||||
ok(false, 'missing test - untested code is broken code');
|
||||
});
|
||||
|
||||
@ -611,8 +602,8 @@ test("{ helper: 'original' }, fixed, with scroll offset on root and parent", fun
|
||||
|
||||
test("{ helper: 'clone' }, absolute", function() {
|
||||
|
||||
var helperOffset = null;
|
||||
var origOffset = $("#draggable1").offset();
|
||||
var helperOffset = null,
|
||||
origOffset = $("#draggable1").offset();
|
||||
|
||||
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
|
||||
helperOffset = ui.helper.offset();
|
||||
@ -626,8 +617,8 @@ test("{ helper: 'clone' }, absolute", function() {
|
||||
test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
|
||||
|
||||
setScroll();
|
||||
var helperOffset = null;
|
||||
var origOffset = null;
|
||||
var helperOffset = null,
|
||||
origOffset = null;
|
||||
|
||||
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
|
||||
helperOffset = ui.helper.offset();
|
||||
@ -655,8 +646,8 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() {
|
||||
test("{ helper: 'clone' }, absolute with scroll offset on root", function() {
|
||||
|
||||
setScroll('root');
|
||||
var helperOffset = null;
|
||||
var origOffset = null;
|
||||
var helperOffset = null,
|
||||
origOffset = null;
|
||||
|
||||
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
|
||||
helperOffset = ui.helper.offset();
|
||||
@ -685,25 +676,25 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func
|
||||
|
||||
setScroll('root');
|
||||
setScroll();
|
||||
var helperOffset = null;
|
||||
var origOffset = null;
|
||||
var helperOffset = null,
|
||||
origOffset = null;
|
||||
|
||||
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
|
||||
helperOffset = ui.helper.offset();
|
||||
} });
|
||||
|
||||
$("#main").css('position', 'relative');
|
||||
origOffset = $("#draggable1").offset()
|
||||
origOffset = $("#draggable1").offset();
|
||||
drag(el, 1, 1);
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
|
||||
|
||||
$("#main").css('position', 'static');
|
||||
origOffset = $("#draggable1").offset()
|
||||
origOffset = $("#draggable1").offset();
|
||||
drag(el, 1, 1);
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
|
||||
|
||||
$("#main").css('position', 'absolute');
|
||||
origOffset = $("#draggable1").offset()
|
||||
origOffset = $("#draggable1").offset();
|
||||
drag(el, 1, 1);
|
||||
deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
|
||||
|
||||
@ -734,9 +725,9 @@ test("{ zIndex: 10 }", function() {
|
||||
|
||||
expect(1);
|
||||
|
||||
var expected = 10, actual;
|
||||
|
||||
var zIndex = null;
|
||||
var actual,
|
||||
expected = 10,
|
||||
zIndex = null;
|
||||
el = $("#draggable2").draggable({
|
||||
zIndex: expected,
|
||||
start: function(event, ui) {
|
||||
|
@ -17,15 +17,15 @@ function shouldNotBeDroppable() {
|
||||
module("droppable: core");
|
||||
|
||||
test("element types", function() {
|
||||
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
|
||||
+ ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
|
||||
+ ',acronym,code,samp,kbd,var,img,object,hr'
|
||||
+ ',input,button,label,select,iframe').split(',');
|
||||
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
|
||||
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
|
||||
',acronym,code,samp,kbd,var,img,object,hr' +
|
||||
',input,button,label,select,iframe').split(',');
|
||||
|
||||
$.each(typeNames, function(i) {
|
||||
var typeName = typeNames[i];
|
||||
el = $(document.createElement(typeName)).appendTo('body');
|
||||
(typeName == 'table' && el.append("<tr><td>content</td></tr>"));
|
||||
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
|
||||
el.droppable();
|
||||
shouldBeDroppable();
|
||||
el.droppable("destroy");
|
||||
|
@ -1,16 +1,12 @@
|
||||
/*
|
||||
* droppable_defaults.js
|
||||
*/
|
||||
|
||||
var droppable_defaults = {
|
||||
accept: '*',
|
||||
activeClass: false,
|
||||
addClasses: true,
|
||||
disabled: false,
|
||||
greedy: false,
|
||||
hoverClass: false,
|
||||
scope: "default",
|
||||
tolerance: "intersect"
|
||||
};
|
||||
|
||||
commonWidgetTests('droppable', { defaults: droppable_defaults });
|
||||
commonWidgetTests( "droppable", {
|
||||
defaults: {
|
||||
accept: "*",
|
||||
activeClass: false,
|
||||
addClasses: true,
|
||||
disabled: false,
|
||||
greedy: false,
|
||||
hoverClass: false,
|
||||
scope: "default",
|
||||
tolerance: "intersect"
|
||||
}
|
||||
});
|
||||
|
@ -6,8 +6,6 @@
|
||||
module("droppable: options");
|
||||
|
||||
test("{ accept '*' }, default ", function() {
|
||||
equal(droppable_defaults.accept, '*');
|
||||
|
||||
ok(false, 'missing test - untested code is broken code');
|
||||
});
|
||||
|
||||
@ -24,8 +22,6 @@ test("activeClass", function() {
|
||||
});
|
||||
|
||||
test("{ addClasses: true }, default", function() {
|
||||
equal(droppable_defaults.addClasses, true);
|
||||
|
||||
el = $("<div></div>").droppable({ addClasses: true });
|
||||
ok(el.is(".ui-droppable"), "'ui-droppable' class added");
|
||||
el.droppable("destroy");
|
||||
|
Loading…
Reference in New Issue
Block a user