Dialog Tests: Cleanup el -> element

This commit is contained in:
Kris Borchers 2013-01-30 23:38:20 -06:00
parent e886e4a9c1
commit 2a8494fc81
6 changed files with 382 additions and 382 deletions

View File

@ -10,26 +10,26 @@ test("title id", function() {
expect(1); expect(1);
var titleId, var titleId,
el = $("<div></div>").dialog(); element = $("<div></div>").dialog();
titleId = el.dialog("widget").find(".ui-dialog-title").attr("id"); titleId = element.dialog("widget").find(".ui-dialog-title").attr("id");
ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id"); ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id");
el.remove(); element.remove();
}); });
test( "ARIA", function() { test( "ARIA", function() {
expect( 4 ); expect( 4 );
var el = $( "<div></div>" ).dialog(), var element = $( "<div></div>" ).dialog(),
wrapper = el.dialog( "widget" ); wrapper = element.dialog( "widget" );
equal( wrapper.attr( "role" ), "dialog", "dialog role" ); equal( wrapper.attr( "role" ), "dialog", "dialog role" );
equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) ); equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) );
equal( wrapper.attr( "aria-describedby" ), el.attr( "id" ), "aria-describedby added" ); equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" );
el.remove(); element.remove();
el = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog(); element = $("<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>").dialog();
strictEqual( el.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" ); strictEqual( element.dialog( "widget" ).attr( "aria-describedby" ), undefined, "no aria-describedby added, as already present in markup" );
el.remove(); element.remove();
}); });
test("widget method", function() { test("widget method", function() {
@ -41,7 +41,7 @@ test("widget method", function() {
asyncTest( "focus tabbable", function() { asyncTest( "focus tabbable", function() {
expect( 5 ); expect( 5 );
var el, var element,
options = { options = {
buttons: [{ buttons: [{
text: "Ok", text: "Ok",
@ -50,24 +50,24 @@ asyncTest( "focus tabbable", function() {
}; };
function checkFocus( markup, options, testFn, next ) { function checkFocus( markup, options, testFn, next ) {
el = $( markup ).dialog( options ); element = $( markup ).dialog( options );
setTimeout(function() { setTimeout(function() {
testFn(); testFn();
el.remove(); element.remove();
setTimeout( next ); setTimeout( next );
}); });
} }
function step1() { function step1() {
checkFocus( "<div><input><input autofocus></div>", options, function() { checkFocus( "<div><input><input autofocus></div>", options, function() {
equal( document.activeElement, el.find( "input" )[ 1 ], equal( document.activeElement, element.find( "input" )[ 1 ],
"1. first element inside the dialog matching [autofocus]" ); "1. first element inside the dialog matching [autofocus]" );
}, step2 ); }, step2 );
} }
function step2() { function step2() {
checkFocus( "<div><input><input></div>", options, function() { checkFocus( "<div><input><input></div>", options, function() {
equal( document.activeElement, el.find( "input" )[ 0 ], equal( document.activeElement, element.find( "input" )[ 0 ],
"2. tabbable element inside the content element" ); "2. tabbable element inside the content element" );
}, step3 ); }, step3 );
} }
@ -75,7 +75,7 @@ asyncTest( "focus tabbable", function() {
function step3() { function step3() {
checkFocus( "<div>text</div>", options, function() { checkFocus( "<div>text</div>", options, function() {
equal( document.activeElement, equal( document.activeElement,
el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
"3. tabbable element inside the buttonpane" ); "3. tabbable element inside the buttonpane" );
}, step4 ); }, step4 );
} }
@ -83,20 +83,20 @@ asyncTest( "focus tabbable", function() {
function step4() { function step4() {
checkFocus( "<div>text</div>", {}, function() { checkFocus( "<div>text</div>", {}, function() {
equal( document.activeElement, equal( document.activeElement,
el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
"4. the close button" ); "4. the close button" );
}, step5 ); }, step5 );
} }
function step5() { function step5() {
el = $( "<div>text</div>" ).dialog({ element = $( "<div>text</div>" ).dialog({
autoOpen: false autoOpen: false
}); });
el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
el.dialog( "open" ); element.dialog( "open" );
setTimeout(function() { setTimeout(function() {
equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); equal( document.activeElement, element.parent()[ 0 ], "5. the dialog itself" );
el.remove(); element.remove();
start(); start();
}); });
} }
@ -119,9 +119,9 @@ test( "#7960: resizable handles below modal overlays", function() {
asyncTest( "Prevent tabbing out of dialogs", function() { asyncTest( "Prevent tabbing out of dialogs", function() {
expect( 3 ); expect( 3 );
var el = $( "<div><input><input></div>" ).dialog(), var element = $( "<div><input><input></div>" ).dialog(),
inputs = el.find( "input" ), inputs = element.find( "input" ),
widget = el.dialog( "widget" )[ 0 ]; widget = element.dialog( "widget" )[ 0 ];
function checkTab() { function checkTab() {
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
@ -134,7 +134,7 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
function checkShiftTab() { function checkShiftTab() {
ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
el.remove(); element.remove();
setTimeout( start ); setTimeout( start );
} }

View File

@ -8,12 +8,12 @@ test( "position, right bottom on window w/array", function() {
// Support: FF, IE7 // Support: FF, IE7
var winWidth = $( window ).width(), var winWidth = $( window ).width(),
winHeight = $( window ).height(), winHeight = $( window ).height(),
el = $("<div></div>").dialog({ position: [ "right", "bottom" ] }), element = $("<div></div>").dialog({ position: [ "right", "bottom" ] }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" ); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" );
closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" );
el.remove(); element.remove();
}); });
test( "position, right bottom on window", function() { test( "position, right bottom on window", function() {
@ -24,40 +24,40 @@ test( "position, right bottom on window", function() {
// Support: FF, IE7 // Support: FF, IE7
var winWidth = $( window ).width(), var winWidth = $( window ).width(),
winHeight = $( window ).height(), winHeight = $( window ).height(),
el = $("<div></div>").dialog({ position: "right bottom" }), element = $("<div></div>").dialog({ position: "right bottom" }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" ); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" );
closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" );
el.remove(); element.remove();
}); });
test("position, offset from top left w/array", function() { test("position, offset from top left w/array", function() {
expect( 2 ); expect( 2 );
var el = $("<div></div>").dialog({ position: [10, 10] }), var element = $("<div></div>").dialog({ position: [10, 10] }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough(offset.left, 10 + $(window).scrollLeft(), 1); closeEnough(offset.left, 10 + $(window).scrollLeft(), 1);
closeEnough(offset.top, 10 + $(window).scrollTop(), 1); closeEnough(offset.top, 10 + $(window).scrollTop(), 1);
el.remove(); element.remove();
}); });
test("position, top on window", function() { test("position, top on window", function() {
expect( 2 ); expect( 2 );
var el = $("<div></div>").dialog({ position: "top" }), var element = $("<div></div>").dialog({ position: "top" }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1); closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1);
closeEnough(offset.top, $(window).scrollTop(), 1); closeEnough(offset.top, $(window).scrollTop(), 1);
el.remove(); element.remove();
}); });
test("position, left on window", function() { test("position, left on window", function() {
expect( 2 ); expect( 2 );
var el = $("<div></div>").dialog({ position: "left" }), var element = $("<div></div>").dialog({ position: "left" }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough(offset.left, 0, 1); closeEnough(offset.left, 0, 1);
closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1); closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1);
el.remove(); element.remove();
}); });

View File

@ -8,115 +8,115 @@ module("dialog: events");
test("open", function() { test("open", function() {
expect(13); expect(13);
var el = $("<div></div>"); var element = $("<div></div>");
el.dialog({ element.dialog({
open: function(ev, ui) { open: function(ev, ui) {
ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, "autoOpen: true fires open callback"); ok(true, "autoOpen: true fires open callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogopen", "event type in callback"); equal(ev.type, "dialogopen", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
} }
}); });
el.remove(); element.remove();
el = $("<div></div>"); element = $("<div></div>");
el.dialog({ element.dialog({
autoOpen: false, autoOpen: false,
open: function(ev, ui) { open: function(ev, ui) {
ok(true, ".dialog('open') fires open callback"); ok(true, ".dialog('open') fires open callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogopen", "event type in callback"); equal(ev.type, "dialogopen", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
} }
}).bind("dialogopen", function(ev, ui) { }).bind("dialogopen", function(ev, ui) {
ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, "dialog('open') fires open event"); ok(true, "dialog('open') fires open event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
deepEqual(ui, {}, "ui hash in event"); deepEqual(ui, {}, "ui hash in event");
}); });
el.dialog("open"); element.dialog("open");
el.remove(); element.remove();
}); });
test( "focus", function() { test( "focus", function() {
expect( 5 ); expect( 5 );
var el, other; var element, other;
el = $("#dialog1").dialog({ element = $("#dialog1").dialog({
autoOpen: false autoOpen: false
}); });
other = $("#dialog2").dialog({ other = $("#dialog2").dialog({
autoOpen: false autoOpen: false
}); });
el.one( "dialogopen", function() { element.one( "dialogopen", function() {
ok( true, "open, just once" ); ok( true, "open, just once" );
}); });
el.one( "dialogfocus", function() { element.one( "dialogfocus", function() {
ok( true, "focus on open" ); ok( true, "focus on open" );
}); });
other.dialog( "open" ); other.dialog( "open" );
el.one( "dialogfocus", function() { element.one( "dialogfocus", function() {
ok( true, "when opening and already open and wasn't on top" ); ok( true, "when opening and already open and wasn't on top" );
}); });
other.dialog( "open" ); other.dialog( "open" );
el.dialog( "open" ); element.dialog( "open" );
el.one( "dialogfocus", function() { element.one( "dialogfocus", function() {
ok( true, "when calling moveToTop and wasn't on top" ); ok( true, "when calling moveToTop and wasn't on top" );
}); });
other.dialog( "moveToTop" ); other.dialog( "moveToTop" );
el.dialog( "moveToTop" ); element.dialog( "moveToTop" );
el.bind( "dialogfocus", function() { element.bind( "dialogfocus", function() {
ok( true, "when mousedown anywhere on the dialog and it wasn't on top" ); ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
}); });
other.dialog( "moveToTop" ); other.dialog( "moveToTop" );
el.trigger( "mousedown" ); element.trigger( "mousedown" );
// triggers just once when already on top // triggers just once when already on top
el.dialog( "open" ); element.dialog( "open" );
el.dialog( "moveToTop" ); element.dialog( "moveToTop" );
el.trigger( "mousedown" ); element.trigger( "mousedown" );
el.add( other ).remove(); element.add( other ).remove();
}); });
test("dragStart", function() { test("dragStart", function() {
expect(9); expect(9);
var handle, var handle,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
dragStart: function(ev, ui) { dragStart: function(ev, ui) {
ok(true, "dragging fires dragStart callback"); ok(true, "dragging fires dragStart callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogdragstart", "event type in callback"); equal(ev.type, "dialogdragstart", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
} }
}).bind("dialogdragstart", function(ev, ui) { }).bind("dialogdragstart", function(ev, ui) {
ok(true, "dragging fires dialogdragstart event"); ok(true, "dragging fires dialogdragstart event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
}); });
handle = $(".ui-dialog-titlebar", el.dialog("widget")); handle = $(".ui-dialog-titlebar", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
test("drag", function() { test("drag", function() {
expect(9); expect(9);
var handle, var handle,
hasDragged = false, hasDragged = false,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
drag: function(ev, ui) { drag: function(ev, ui) {
if (!hasDragged) { if (!hasDragged) {
ok(true, "dragging fires drag callback"); ok(true, "dragging fires drag callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogdrag", "event type in callback"); equal(ev.type, "dialogdrag", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
@ -126,48 +126,48 @@ test("drag", function() {
} }
}).one("dialogdrag", function(ev, ui) { }).one("dialogdrag", function(ev, ui) {
ok(true, "dragging fires dialogdrag event"); ok(true, "dragging fires dialogdrag event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
}); });
handle = $(".ui-dialog-titlebar", el.dialog("widget")); handle = $(".ui-dialog-titlebar", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
test("dragStop", function() { test("dragStop", function() {
expect(9); expect(9);
var handle, var handle,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
dragStop: function(ev, ui) { dragStop: function(ev, ui) {
ok(true, "dragging fires dragStop callback"); ok(true, "dragging fires dragStop callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogdragstop", "event type in callback"); equal(ev.type, "dialogdragstop", "event type in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
} }
}).bind("dialogdragstop", function(ev, ui) { }).bind("dialogdragstop", function(ev, ui) {
ok(true, "dragging fires dialogdragstop event"); ok(true, "dragging fires dialogdragstop event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
}); });
handle = $(".ui-dialog-titlebar", el.dialog("widget")); handle = $(".ui-dialog-titlebar", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
test("resizeStart", function() { test("resizeStart", function() {
expect(13); expect(13);
var handle, var handle,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
resizeStart: function(ev, ui) { resizeStart: function(ev, ui) {
ok(true, "resizing fires resizeStart callback"); ok(true, "resizing fires resizeStart callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogresizestart", "event type in callback"); equal(ev.type, "dialogresizestart", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
@ -176,27 +176,27 @@ test("resizeStart", function() {
} }
}).bind("dialogresizestart", function(ev, ui) { }).bind("dialogresizestart", function(ev, ui) {
ok(true, "resizing fires dialogresizestart event"); ok(true, "resizing fires dialogresizestart event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.size !== undefined, "ui.size in callback");
}); });
handle = $(".ui-resizable-se", el.dialog("widget")); handle = $(".ui-resizable-se", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
test("resize", function() { test("resize", function() {
expect(13); expect(13);
var handle, var handle,
hasResized = false, hasResized = false,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
resize: function(ev, ui) { resize: function(ev, ui) {
if (!hasResized) { if (!hasResized) {
ok(true, "resizing fires resize callback"); ok(true, "resizing fires resize callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogresize", "event type in callback"); equal(ev.type, "dialogresize", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
@ -208,26 +208,26 @@ test("resize", function() {
} }
}).one("dialogresize", function(ev, ui) { }).one("dialogresize", function(ev, ui) {
ok(true, "resizing fires dialogresize event"); ok(true, "resizing fires dialogresize event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.size !== undefined, "ui.size in callback");
}); });
handle = $(".ui-resizable-se", el.dialog("widget")); handle = $(".ui-resizable-se", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
test("resizeStop", function() { test("resizeStop", function() {
expect(13); expect(13);
var handle, var handle,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
resizeStop: function(ev, ui) { resizeStop: function(ev, ui) {
ok(true, "resizing fires resizeStop callback"); ok(true, "resizing fires resizeStop callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogresizestop", "event type in callback"); equal(ev.type, "dialogresizestop", "event type in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
@ -236,107 +236,107 @@ test("resizeStop", function() {
} }
}).bind("dialogresizestop", function(ev, ui) { }).bind("dialogresizestop", function(ev, ui) {
ok(true, "resizing fires dialogresizestop event"); ok(true, "resizing fires dialogresizestop event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.size !== undefined, "ui.size in callback");
}); });
handle = $(".ui-resizable-se", el.dialog("widget")); handle = $(".ui-resizable-se", element.dialog("widget"));
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
el.remove(); element.remove();
}); });
asyncTest("close", function() { asyncTest("close", function() {
expect(14); expect(14);
var el = $("<div></div>").dialog({ var element = $("<div></div>").dialog({
close: function(ev, ui) { close: function(ev, ui) {
ok(true, ".dialog('close') fires close callback"); ok(true, ".dialog('close') fires close callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogclose", "event type in callback"); equal(ev.type, "dialogclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
} }
}).bind("dialogclose", function(ev, ui) { }).bind("dialogclose", function(ev, ui) {
ok(true, ".dialog('close') fires dialogclose event"); ok(true, ".dialog('close') fires dialogclose event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
deepEqual(ui, {}, "ui hash in event"); deepEqual(ui, {}, "ui hash in event");
}); });
el.dialog("close"); element.dialog("close");
el.remove(); element.remove();
// Close event with an effect // Close event with an effect
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
hide: 10, hide: 10,
close: function(ev, ui) { close: function(ev, ui) {
ok(true, ".dialog('close') fires close callback"); ok(true, ".dialog('close') fires close callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogclose", "event type in callback"); equal(ev.type, "dialogclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
start(); start();
} }
}).bind("dialogclose", function(ev, ui) { }).bind("dialogclose", function(ev, ui) {
ok(true, ".dialog('close') fires dialogclose event"); ok(true, ".dialog('close') fires dialogclose event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
deepEqual(ui, {}, "ui hash in event"); deepEqual(ui, {}, "ui hash in event");
}); });
el.dialog("close"); element.dialog("close");
}); });
test("beforeClose", function() { test("beforeClose", function() {
expect(14); expect(14);
var el = $("<div></div>").dialog({ var element = $("<div></div>").dialog({
beforeClose: function(ev, ui) { beforeClose: function(ev, ui) {
ok(true, ".dialog('close') fires beforeClose callback"); ok(true, ".dialog('close') fires beforeClose callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogbeforeclose", "event type in callback"); equal(ev.type, "dialogbeforeclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
return false; return false;
} }
}); });
el.dialog("close"); element.dialog("close");
ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
el.remove(); element.remove();
el = $("<div></div>").dialog(); element = $("<div></div>").dialog();
el.dialog("option", "beforeClose", function(ev, ui) { element.dialog("option", "beforeClose", function(ev, ui) {
ok(true, ".dialog('close') fires beforeClose callback"); ok(true, ".dialog('close') fires beforeClose callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.type, "dialogbeforeclose", "event type in callback"); equal(ev.type, "dialogbeforeclose", "event type in callback");
deepEqual(ui, {}, "ui hash in callback"); deepEqual(ui, {}, "ui hash in callback");
return false; return false;
}); });
el.dialog("close"); element.dialog("close");
ok( el.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing"); ok( element.dialog("widget").is(":visible"), "beforeClose callback should prevent dialog from closing");
el.remove(); element.remove();
el = $("<div></div>").dialog().bind("dialogbeforeclose", function(ev, ui) { element = $("<div></div>").dialog().bind("dialogbeforeclose", function(ev, ui) {
ok(true, ".dialog('close') triggers dialogbeforeclose event"); ok(true, ".dialog('close') triggers dialogbeforeclose event");
equal(this, el[0], "context of event"); equal(this, element[0], "context of event");
deepEqual(ui, {}, "ui hash in event"); deepEqual(ui, {}, "ui hash in event");
return false; return false;
}); });
el.dialog("close"); element.dialog("close");
ok( el.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing"); ok( element.dialog("widget").is(":visible"), "dialogbeforeclose event should prevent dialog from closing");
el.remove(); element.remove();
}); });
// #8789 and #8838 // #8789 and #8838
asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() { asyncTest("ensure dialog's container doesn't scroll on resize and focus", function() {
expect(2); expect(2);
var el = $("#dialog1").dialog(), var element = $("#dialog1").dialog(),
initialScroll = $(window).scrollTop(); initialScroll = $(window).scrollTop();
el.dialog("option", "height", 600); element.dialog("option", "height", 600);
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change"); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after height change");
setTimeout( function(){ setTimeout( function(){
$(".ui-dialog-titlebar-close").simulate("mousedown"); $(".ui-dialog-titlebar-close").simulate("mousedown");
equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog"); equal($(window).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog");
el.dialog("destroy"); element.dialog("destroy");
start(); start();
}, 500); }, 500);
}); });
@ -344,27 +344,27 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi
test("#5184: isOpen in dialogclose event is true", function() { test("#5184: isOpen in dialogclose event is true", function() {
expect( 3 ); expect( 3 );
var el = $( "<div></div>" ).dialog({ var element = $( "<div></div>" ).dialog({
close: function() { close: function() {
ok( !el.dialog("isOpen"), "dialog is not open during close" ); ok( !element.dialog("isOpen"), "dialog is not open during close" );
} }
}); });
ok( el.dialog("isOpen"), "dialog is open after init" ); ok( element.dialog("isOpen"), "dialog is open after init" );
el.dialog( "close" ); element.dialog( "close" );
ok( !el.dialog("isOpen"), "dialog is not open after close" ); ok( !element.dialog("isOpen"), "dialog is not open after close" );
el.remove(); element.remove();
}); });
test("ensure dialog keeps focus when clicking modal overlay", function() { test("ensure dialog keeps focus when clicking modal overlay", function() {
expect( 2 ); expect( 2 );
var el = $( "<div></div>" ).dialog({ var element = $( "<div></div>" ).dialog({
modal: true modal: true
}); });
ok( $(":focus").closest(".ui-dialog").length, "focus is in dialog" ); ok( $(":focus").closest(".ui-dialog").length, "focus is in dialog" );
$(".ui-widget-overlay").simulate("mousedown"); $(".ui-widget-overlay").simulate("mousedown");
ok( $(":focus").closest(".ui-dialog").length, "focus is still in dialog" ); ok( $(":focus").closest(".ui-dialog").length, "focus is still in dialog" );
el.remove(); element.remove();
}); });
})(jQuery); })(jQuery);

View File

@ -24,9 +24,9 @@ test("init", function() {
$("<div></div>").appendTo("body").remove().dialog().remove(); $("<div></div>").appendTo("body").remove().dialog().remove();
ok(true, ".dialog() called on disconnected DOMElement - removed"); ok(true, ".dialog() called on disconnected DOMElement - removed");
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
el.dialog("option", "foo"); element.dialog("option", "foo");
el.remove(); element.remove();
ok(true, "arbitrary option getter after init"); ok(true, "arbitrary option getter after init");
$("<div></div>").dialog().dialog("option", "foo", "bar").remove(); $("<div></div>").dialog().dialog("option", "foo", "bar").remove();
@ -36,7 +36,7 @@ test("init", function() {
test("destroy", function() { test("destroy", function() {
expect( 17 ); expect( 17 );
var el, el2; var element, element2;
$( "#dialog1, #form-dialog" ).hide(); $( "#dialog1, #form-dialog" ).hide();
domEqual( "#dialog1", function() { domEqual( "#dialog1", function() {
@ -65,17 +65,17 @@ test("destroy", function() {
equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" ); equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays"); equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays");
el = $( "#dialog1" ).dialog({ modal: true }), element = $( "#dialog1" ).dialog({ modal: true }),
el2 = $( "#dialog2" ).dialog({ modal: true }); element2 = $( "#dialog2" ).dialog({ modal: true });
equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" ); equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
equal( $.ui.dialog.overlayInstances, 2, "overlayInstances equals the number of open overlays" ); equal( $.ui.dialog.overlayInstances, 2, "overlayInstances equals the number of open overlays" );
el.dialog( "close" ); element.dialog( "close" );
equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after closing one dialog" ); equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after closing one dialog" );
equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" ); equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
el.dialog( "destroy" ); element.dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after destroying one dialog" ); equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after destroying one dialog" );
equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" ); equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
el2.dialog( "destroy" ); element2.dialog( "destroy" );
equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" ); equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" );
equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays" ); equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays" );
}); });
@ -102,40 +102,40 @@ test("#4980: Destroy should place element back in original DOM position", functi
test( "enable/disable disabled", function() { test( "enable/disable disabled", function() {
expect( 2 ); expect( 2 );
var el = $( "<div></div>" ).dialog(); var element = $( "<div></div>" ).dialog();
el.dialog( "disable" ); element.dialog( "disable" );
equal(el.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
ok( !el.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" );
}); });
test("close", function() { test("close", function() {
expect( 3 ); expect( 3 );
var el, var element,
expected = $("<div></div>").dialog(), expected = $("<div></div>").dialog(),
actual = expected.dialog("close"); actual = expected.dialog("close");
equal(actual, expected, "close is chainable"); equal(actual, expected, "close is chainable");
el = $("<div></div>").dialog(); element = $("<div></div>").dialog();
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible before close method called"); ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible before close method called");
el.dialog("close"); element.dialog("close");
ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden after close method called"); ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden after close method called");
}); });
test("isOpen", function() { test("isOpen", function() {
expect(4); expect(4);
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
equal(el.dialog("isOpen"), true, "dialog is open after init"); equal(element.dialog("isOpen"), true, "dialog is open after init");
el.dialog("close"); element.dialog("close");
equal(el.dialog("isOpen"), false, "dialog is closed"); equal(element.dialog("isOpen"), false, "dialog is closed");
el.remove(); element.remove();
el = $("<div></div>").dialog({autoOpen: false}); element = $("<div></div>").dialog({autoOpen: false});
equal(el.dialog("isOpen"), false, "dialog is closed after init"); equal(element.dialog("isOpen"), false, "dialog is closed after init");
el.dialog("open"); element.dialog("open");
equal(el.dialog("isOpen"), true, "dialog is open"); equal(element.dialog("isOpen"), true, "dialog is open");
el.remove(); element.remove();
}); });
test("moveToTop", function() { test("moveToTop", function() {
@ -167,15 +167,15 @@ test("moveToTop", function() {
test("open", function() { test("open", function() {
expect( 3 ); expect( 3 );
var el, var element,
expected = $("<div></div>").dialog(), expected = $("<div></div>").dialog(),
actual = expected.dialog("open"); actual = expected.dialog("open");
equal(actual, expected, "open is chainable"); equal(actual, expected, "open is chainable");
el = $("<div></div>").dialog({ autoOpen: false }); element = $("<div></div>").dialog({ autoOpen: false });
ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog hidden before open method called"); ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog hidden before open method called");
el.dialog("open"); element.dialog("open");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog visible after open method called"); ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog visible after open method called");
}); });
test("#6137: dialog('open') causes form elements to reset on IE7", function() { test("#6137: dialog('open') causes form elements to reset on IE7", function() {
@ -195,23 +195,23 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
test("#5531: dialog width should be at least minWidth on creation", function () { test("#5531: dialog width should be at least minWidth on creation", function () {
expect( 4 ); expect( 4 );
var el = $("<div></div>").dialog({ var element = $("<div></div>").dialog({
width: 200, width: 200,
minWidth: 300 minWidth: 300
}); });
equal(el.dialog("option", "width"), 300, "width is minWidth"); equal(element.dialog("option", "width"), 300, "width is minWidth");
el.dialog("option", "width", 200); element.dialog("option", "width", 200);
equal(el.dialog("option", "width"), 300, "width unchanged when set to < minWidth"); equal(element.dialog("option", "width"), 300, "width unchanged when set to < minWidth");
el.dialog("option", "width", 320); element.dialog("option", "width", 320);
equal(el.dialog("option", "width"), 320, "width changed if set to > minWidth"); equal(element.dialog("option", "width"), 320, "width changed if set to > minWidth");
el.remove(); element.remove();
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
minWidth: 300 minWidth: 300
}); });
ok(el.dialog("option", "width") >= 300, "width is at least 300"); ok(element.dialog("option", "width") >= 300, "width is at least 300");
el.remove(); element.remove();
}); });

View File

@ -69,13 +69,13 @@ test( "appendTo", function() {
test("autoOpen", function() { test("autoOpen", function() {
expect(2); expect(2);
var el = $("<div></div>").dialog({ autoOpen: false }); var element = $("<div></div>").dialog({ autoOpen: false });
ok( !el.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })"); ok( !element.dialog("widget").is(":visible"), ".dialog({ autoOpen: false })");
el.remove(); element.remove();
el = $("<div></div>").dialog({ autoOpen: true }); element = $("<div></div>").dialog({ autoOpen: true });
ok( el.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })"); ok( element.dialog("widget").is(":visible"), ".dialog({ autoOpen: true })");
el.remove(); element.remove();
}); });
test("buttons", function() { test("buttons", function() {
@ -85,18 +85,18 @@ test("buttons", function() {
buttons = { buttons = {
"Ok": function( ev ) { "Ok": function( ev ) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.target, btn[0], "event target"); equal(ev.target, btn[0], "event target");
}, },
"Cancel": function( ev ) { "Cancel": function( ev ) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.target, btn[1], "event target"); equal(ev.target, btn[1], "event target");
} }
}, },
el = $("<div></div>").dialog({ buttons: buttons }); element = $("<div></div>").dialog({ buttons: buttons });
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(btn.length, 2, "number of buttons"); equal(btn.length, 2, "number of buttons");
i = 0; i = 0;
@ -106,23 +106,23 @@ test("buttons", function() {
}); });
ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container"); ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container");
ok(el.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons"); ok(element.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons");
btn.trigger("click"); btn.trigger("click");
newButtons = { newButtons = {
"Close": function( ev ) { "Close": function( ev ) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
equal(this, el[0], "context of callback"); equal(this, element[0], "context of callback");
equal(ev.target, btn[0], "event target"); equal(ev.target, btn[0], "event target");
} }
}; };
deepEqual(el.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter"); deepEqual(element.dialog("option", "buttons"), buttons, ".dialog('option', 'buttons') getter");
el.dialog("option", "buttons", newButtons); element.dialog("option", "buttons", newButtons);
deepEqual(el.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter"); deepEqual(element.dialog("option", "buttons"), newButtons, ".dialog('option', 'buttons', ...) setter");
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(btn.length, 1, "number of buttons after setter"); equal(btn.length, 1, "number of buttons after setter");
btn.trigger("click"); btn.trigger("click");
@ -132,27 +132,27 @@ test("buttons", function() {
i += 1; i += 1;
}); });
el.dialog("option", "buttons", null); element.dialog("option", "buttons", null);
btn = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(btn.length, 0, "all buttons have been removed"); equal(btn.length, 0, "all buttons have been removed");
equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); equal(element.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
equal(el.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons"); equal(element.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons");
el.remove(); element.remove();
}); });
test("buttons - advanced", function() { test("buttons - advanced", function() {
expect( 7 ); expect( 7 );
var buttons, var buttons,
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
buttons: [ buttons: [
{ {
text: "a button", text: "a button",
"class": "additional-class", "class": "additional-class",
id: "my-button-id", id: "my-button-id",
click: function() { click: function() {
equal(this, el[0], "correct context"); equal(this, element[0], "correct context");
}, },
icons: { icons: {
primary: "ui-icon-cancel" primary: "ui-icon-cancel"
@ -162,7 +162,7 @@ test("buttons - advanced", function() {
] ]
}); });
buttons = el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
equal(buttons.length, 1, "correct number of buttons"); equal(buttons.length, 1, "correct number of buttons");
equal(buttons.attr("id"), "my-button-id", "correct id"); equal(buttons.attr("id"), "my-button-id", "correct id");
equal(buttons.text(), "a button", "correct label"); equal(buttons.text(), "a button", "correct label");
@ -171,106 +171,106 @@ test("buttons - advanced", function() {
equal( buttons.button( "option", "text" ), false ); equal( buttons.button( "option", "text" ), false );
buttons.click(); buttons.click();
el.remove(); element.remove();
}); });
test("closeOnEscape", function() { test("closeOnEscape", function() {
expect( 6 ); expect( 6 );
var el = $("<div></div>").dialog({ closeOnEscape: false }); var element = $("<div></div>").dialog({ closeOnEscape: false });
ok(true, "closeOnEscape: false"); ok(true, "closeOnEscape: false");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC");
el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE })
.simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE })
.simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE });
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open after ESC"); ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open after ESC");
el.remove(); element.remove();
el = $("<div></div>").dialog({ closeOnEscape: true }); element = $("<div></div>").dialog({ closeOnEscape: true });
ok(true, "closeOnEscape: true"); ok(true, "closeOnEscape: true");
ok(el.dialog("widget").is(":visible") && !el.dialog("widget").is(":hidden"), "dialog is open before ESC"); ok(element.dialog("widget").is(":visible") && !element.dialog("widget").is(":hidden"), "dialog is open before ESC");
el.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE }) element.simulate("keydown", { keyCode: $.ui.keyCode.ESCAPE })
.simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE }) .simulate("keypress", { keyCode: $.ui.keyCode.ESCAPE })
.simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE }); .simulate("keyup", { keyCode: $.ui.keyCode.ESCAPE });
ok(el.dialog("widget").is(":hidden") && !el.dialog("widget").is(":visible"), "dialog is closed after ESC"); ok(element.dialog("widget").is(":hidden") && !element.dialog("widget").is(":visible"), "dialog is closed after ESC");
}); });
test("closeText", function() { test("closeText", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close", equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "close",
"default close text"); "default close text");
el.remove(); element.remove();
el = $("<div></div>").dialog({ closeText: "foo" }); element = $("<div></div>").dialog({ closeText: "foo" });
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo", equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "foo",
"closeText on init"); "closeText on init");
el.remove(); element.remove();
el = $("<div></div>").dialog().dialog("option", "closeText", "bar"); element = $("<div></div>").dialog().dialog("option", "closeText", "bar");
equal(el.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar", equal(element.dialog("widget").find(".ui-dialog-titlebar-close span").text(), "bar",
"closeText via option method"); "closeText via option method");
el.remove(); element.remove();
}); });
test("dialogClass", function() { test("dialogClass", function() {
expect( 6 ); expect( 6 );
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
equal(el.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added"); equal(element.dialog("widget").is(".foo"), false, "dialogClass not specified. foo class added");
el.remove(); element.remove();
el = $("<div></div>").dialog({ dialogClass: "foo" }); element = $("<div></div>").dialog({ dialogClass: "foo" });
equal(el.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added"); equal(element.dialog("widget").is(".foo"), true, "dialogClass in init. foo class added");
el.dialog( "option", "dialogClass", "foobar" ); element.dialog( "option", "dialogClass", "foobar" );
equal( el.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" ); equal( element.dialog("widget").is(".foo"), false, "dialogClass changed, previous one was removed" );
equal( el.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" ); equal( element.dialog("widget").is(".foobar"), true, "dialogClass changed, new one was added" );
el.remove(); element.remove();
el = $("<div></div>").dialog({ dialogClass: "foo bar" }); element = $("<div></div>").dialog({ dialogClass: "foo bar" });
equal(el.dialog("widget").is(".foo"), true, "dialogClass in init, two classes. foo class added"); equal(element.dialog("widget").is(".foo"), true, "dialogClass in init, two classes. foo class added");
equal(el.dialog("widget").is(".bar"), true, "dialogClass in init, two classes. bar class added"); equal(element.dialog("widget").is(".bar"), true, "dialogClass in init, two classes. bar class added");
el.remove(); element.remove();
}); });
test("draggable", function() { test("draggable", function() {
expect(4); expect(4);
var el = $("<div></div>").dialog({ draggable: false }); var element = $("<div></div>").dialog({ draggable: false });
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); TestHelpers.dialog.testDrag(element, 50, -50, 0, 0);
el.dialog("option", "draggable", true); element.dialog("option", "draggable", true);
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); TestHelpers.dialog.testDrag(element, 50, -50, 50, -50);
el.remove(); element.remove();
el = $("<div></div>").dialog({ draggable: true }); element = $("<div></div>").dialog({ draggable: true });
TestHelpers.dialog.testDrag(el, 50, -50, 50, -50); TestHelpers.dialog.testDrag(element, 50, -50, 50, -50);
el.dialog("option", "draggable", false); element.dialog("option", "draggable", false);
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0); TestHelpers.dialog.testDrag(element, 50, -50, 0, 0);
el.remove(); element.remove();
}); });
test("height", function() { test("height", function() {
expect(4); expect(4);
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
equal(el.dialog("widget").outerHeight(), 150, "default height"); equal(element.dialog("widget").outerHeight(), 150, "default height");
el.remove(); element.remove();
el = $("<div></div>").dialog({ height: 237 }); element = $("<div></div>").dialog({ height: 237 });
equal(el.dialog("widget").outerHeight(), 237, "explicit height"); equal(element.dialog("widget").outerHeight(), 237, "explicit height");
el.remove(); element.remove();
el = $("<div></div>").dialog(); element = $("<div></div>").dialog();
el.dialog("option", "height", 238); element.dialog("option", "height", 238);
equal(el.dialog("widget").outerHeight(), 238, "explicit height set after init"); equal(element.dialog("widget").outerHeight(), 238, "explicit height set after init");
el.remove(); element.remove();
el = $("<div></div>").css("padding", "20px") element = $("<div></div>").css("padding", "20px")
.dialog({ height: 240 }); .dialog({ height: 240 });
equal(el.dialog("widget").outerHeight(), 240, "explicit height with padding"); equal(element.dialog("widget").outerHeight(), 240, "explicit height with padding");
el.remove(); element.remove();
}); });
asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() {
@ -285,77 +285,77 @@ asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() {
test("maxHeight", function() { test("maxHeight", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog({ maxHeight: 200 }); var element = $("<div></div>").dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000);
closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); closeEnough(element.dialog("widget").height(), 200, 1, "maxHeight");
el.remove(); element.remove();
el = $("<div></div>").dialog({ maxHeight: 200 }); element = $("<div></div>").dialog({ maxHeight: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-n", -1000, -1000); TestHelpers.dialog.drag(element, ".ui-resizable-n", -1000, -1000);
closeEnough(el.dialog("widget").height(), 200, 1, "maxHeight"); closeEnough(element.dialog("widget").height(), 200, 1, "maxHeight");
el.remove(); element.remove();
el = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); element = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300);
TestHelpers.dialog.drag(el, ".ui-resizable-s", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-s", 1000, 1000);
closeEnough(el.dialog("widget").height(), 300, 1, "maxHeight"); closeEnough(element.dialog("widget").height(), 300, 1, "maxHeight");
el.remove(); element.remove();
}); });
test("maxWidth", function() { test("maxWidth", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog({ maxWidth: 200 }); var element = $("<div></div>").dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-e", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-e", 1000, 1000);
closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); closeEnough(element.dialog("widget").width(), 200, 1, "maxWidth");
el.remove(); element.remove();
el = $("<div></div>").dialog({ maxWidth: 200 }); element = $("<div></div>").dialog({ maxWidth: 200 });
TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000);
closeEnough(el.dialog("widget").width(), 200, 1, "maxWidth"); closeEnough(element.dialog("widget").width(), 200, 1, "maxWidth");
el.remove(); element.remove();
el = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); element = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300);
TestHelpers.dialog.drag(el, ".ui-resizable-w", -1000, -1000); TestHelpers.dialog.drag(element, ".ui-resizable-w", -1000, -1000);
closeEnough(el.dialog("widget").width(), 300, 1, "maxWidth"); closeEnough(element.dialog("widget").width(), 300, 1, "maxWidth");
el.remove(); element.remove();
}); });
test("minHeight", function() { test("minHeight", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog({ minHeight: 10 }); var element = $("<div></div>").dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-s", -1000, -1000); TestHelpers.dialog.drag(element, ".ui-resizable-s", -1000, -1000);
closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); closeEnough(element.dialog("widget").height(), 10, 1, "minHeight");
el.remove(); element.remove();
el = $("<div></div>").dialog({ minHeight: 10 }); element = $("<div></div>").dialog({ minHeight: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000);
closeEnough(el.dialog("widget").height(), 10, 1, "minHeight"); closeEnough(element.dialog("widget").height(), 10, 1, "minHeight");
el.remove(); element.remove();
el = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); element = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30);
TestHelpers.dialog.drag(el, ".ui-resizable-n", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-n", 1000, 1000);
closeEnough(el.dialog("widget").height(), 30, 1, "minHeight"); closeEnough(element.dialog("widget").height(), 30, 1, "minHeight");
el.remove(); element.remove();
}); });
test("minWidth", function() { test("minWidth", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog({ minWidth: 10 }); var element = $("<div></div>").dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-e", -1000, -1000); TestHelpers.dialog.drag(element, ".ui-resizable-e", -1000, -1000);
closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); closeEnough(element.dialog("widget").width(), 10, 1, "minWidth");
el.remove(); element.remove();
el = $("<div></div>").dialog({ minWidth: 10 }); element = $("<div></div>").dialog({ minWidth: 10 });
TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000);
closeEnough(el.dialog("widget").width(), 10, 1, "minWidth"); closeEnough(element.dialog("widget").width(), 10, 1, "minWidth");
el.remove(); element.remove();
el = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); element = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30);
TestHelpers.dialog.drag(el, ".ui-resizable-w", 1000, 1000); TestHelpers.dialog.drag(element, ".ui-resizable-w", 1000, 1000);
closeEnough(el.dialog("widget").width(), 30, 1, "minWidth"); closeEnough(element.dialog("widget").width(), 30, 1, "minWidth");
el.remove(); element.remove();
}); });
test( "position, default center on window", function() { test( "position, default center on window", function() {
@ -366,12 +366,12 @@ test( "position, default center on window", function() {
// Support: FF, IE7 // Support: FF, IE7
var winWidth = $( window ).width(), var winWidth = $( window ).width(),
winHeight = $( window ).height(), winHeight = $( window ).height(),
el = $("<div></div>").dialog(), element = $("<div></div>").dialog(),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough( offset.left, Math.round( winWidth / 2 - dialog.outerWidth() / 2 ) + $( window ).scrollLeft(), 1, "dialog left position of center on window on initilization" ); closeEnough( offset.left, Math.round( winWidth / 2 - dialog.outerWidth() / 2 ) + $( window ).scrollLeft(), 1, "dialog left position of center on window on initilization" );
closeEnough( offset.top, Math.round( winHeight / 2 - dialog.outerHeight() / 2 ) + $( window ).scrollTop(), 1, "dialog top position of center on window on initilization" ); closeEnough( offset.top, Math.round( winHeight / 2 - dialog.outerHeight() / 2 ) + $( window ).scrollTop(), 1, "dialog top position of center on window on initilization" );
el.remove(); element.remove();
}); });
test( "position, right bottom at right bottom via ui.position args", function() { test( "position, right bottom at right bottom via ui.position args", function() {
@ -382,18 +382,18 @@ test( "position, right bottom at right bottom via ui.position args", function()
// Support: FF, IE7 // Support: FF, IE7
var winWidth = $( window ).width(), var winWidth = $( window ).width(),
winHeight = $( window ).height(), winHeight = $( window ).height(),
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
position: { position: {
my: "right bottom", my: "right bottom",
at: "right bottom" at: "right bottom"
} }
}), }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "dialog left position of right bottom at right bottom on initilization" ); closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "dialog left position of right bottom at right bottom on initilization" );
closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "dialog top position of right bottom at right bottom on initilization" ); closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "dialog top position of right bottom at right bottom on initilization" );
el.remove(); element.remove();
}); });
test( "position, at another element", function() { test( "position, at another element", function() {
@ -406,7 +406,7 @@ test( "position, at another element", function() {
width: 10 width: 10
}).appendTo("body"), }).appendTo("body"),
el = $("<div></div>").dialog({ element = $("<div></div>").dialog({
position: { position: {
my: "left top", my: "left top",
at: "left top", at: "left top",
@ -415,13 +415,13 @@ test( "position, at another element", function() {
} }
}), }),
dialog = el.dialog("widget"), dialog = element.dialog("widget"),
offset = dialog.offset(); offset = dialog.offset();
closeEnough( offset.left, 600, 1, "dialog left position at another element on initilization" ); closeEnough( offset.left, 600, 1, "dialog left position at another element on initilization" );
closeEnough( offset.top, 400, 1, "dialog top position at another element on initilization" ); closeEnough( offset.top, 400, 1, "dialog top position at another element on initilization" );
el.dialog("option", "position", { element.dialog("option", "position", {
my: "left top", my: "left top",
at: "right bottom", at: "right bottom",
of: parent, of: parent,
@ -433,111 +433,111 @@ test( "position, at another element", function() {
closeEnough( offset.left, 610, 1, "dialog left position at another element via setting option" ); closeEnough( offset.left, 610, 1, "dialog left position at another element via setting option" );
closeEnough( offset.top, 410, 1, "dialog top position at another element via setting option" ); closeEnough( offset.top, 410, 1, "dialog top position at another element via setting option" );
el.remove(); element.remove();
parent.remove(); parent.remove();
}); });
test("resizable", function() { test("resizable", function() {
expect(4); expect(4);
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); TestHelpers.dialog.shouldResize(element, 50, 50, "[default]");
el.dialog("option", "resizable", false); element.dialog("option", "resizable", false);
TestHelpers.dialog.shouldResize(el, 0, 0, "disabled after init"); TestHelpers.dialog.shouldResize(element, 0, 0, "disabled after init");
el.remove(); element.remove();
el = $("<div></div>").dialog({ resizable: false }); element = $("<div></div>").dialog({ resizable: false });
TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options"); TestHelpers.dialog.shouldResize(element, 0, 0, "disabled in init options");
el.dialog("option", "resizable", true); element.dialog("option", "resizable", true);
TestHelpers.dialog.shouldResize(el, 50, 50, "enabled after init"); TestHelpers.dialog.shouldResize(element, 50, 50, "enabled after init");
el.remove(); element.remove();
}); });
test( "title", function() { test( "title", function() {
expect( 11 ); expect( 11 );
function titleText() { function titleText() {
return el.dialog("widget").find( ".ui-dialog-title" ).html(); return element.dialog("widget").find( ".ui-dialog-title" ).html();
} }
var el = $( "<div></div>" ).dialog(); var element = $( "<div></div>" ).dialog();
// some browsers return a non-breaking space and some return "&nbsp;" // some browsers return a non-breaking space and some return "&nbsp;"
// so we generate a non-breaking space for comparison // so we generate a non-breaking space for comparison
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" ); equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal( el.dialog( "option", "title" ), null, "option not changed" ); equal( element.dialog( "option", "title" ), null, "option not changed" );
el.remove(); element.remove();
el = $( "<div title='foo'>" ).dialog(); element = $( "<div title='foo'>" ).dialog();
equal( titleText(), "foo", "title in element attribute" ); equal( titleText(), "foo", "title in element attribute" );
equal( el.dialog( "option", "title"), "foo", "option updated from attribute" ); equal( element.dialog( "option", "title"), "foo", "option updated from attribute" );
el.remove(); element.remove();
el = $( "<div></div>" ).dialog({ title: "foo" }); element = $( "<div></div>" ).dialog({ title: "foo" });
equal( titleText(), "foo", "title in init options" ); equal( titleText(), "foo", "title in init options" );
equal( el.dialog("option", "title"), "foo", "opiton set from options hash" ); equal( element.dialog("option", "title"), "foo", "opiton set from options hash" );
el.remove(); element.remove();
el = $( "<div title='foo'>" ).dialog({ title: "bar" }); element = $( "<div title='foo'>" ).dialog({ title: "bar" });
equal( titleText(), "bar", "title in init options should override title in element attribute" ); equal( titleText(), "bar", "title in init options should override title in element attribute" );
equal( el.dialog("option", "title"), "bar", "opiton set from options hash" ); equal( element.dialog("option", "title"), "bar", "opiton set from options hash" );
el.remove(); element.remove();
el = $( "<div></div>" ).dialog().dialog( "option", "title", "foo" ); element = $( "<div></div>" ).dialog().dialog( "option", "title", "foo" );
equal( titleText(), "foo", "title after init" ); equal( titleText(), "foo", "title after init" );
el.remove(); element.remove();
// make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement // make sure attroperties are properly ignored - #5742 - .attr() might return a DOMElement
el = $( "<form><input name='title'></form>" ).dialog(); element = $( "<form><input name='title'></form>" ).dialog();
// some browsers return a non-breaking space and some return "&nbsp;" // some browsers return a non-breaking space and some return "&nbsp;"
// so we get the text to normalize to the actual non-breaking space // so we get the text to normalize to the actual non-breaking space
equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" ); equal( titleText(), $( "<span>&#160;</span>" ).html(), "[default]" );
equal( el.dialog( "option", "title" ), null, "option not changed" ); equal( element.dialog( "option", "title" ), null, "option not changed" );
el.remove(); element.remove();
}); });
test("width", function() { test("width", function() {
expect(3); expect(3);
var el = $("<div></div>").dialog(); var element = $("<div></div>").dialog();
closeEnough(el.dialog("widget").width(), 300, 1, "default width"); closeEnough(element.dialog("widget").width(), 300, 1, "default width");
el.remove(); element.remove();
el = $("<div></div>").dialog({width: 437 }); element = $("<div></div>").dialog({width: 437 });
closeEnough(el.dialog("widget").width(), 437, 1, "explicit width"); closeEnough(element.dialog("widget").width(), 437, 1, "explicit width");
el.dialog("option", "width", 438); element.dialog("option", "width", 438);
closeEnough(el.dialog("widget").width(), 438, 1, "explicit width after init"); closeEnough(element.dialog("widget").width(), 438, 1, "explicit width after init");
el.remove(); element.remove();
}); });
test("#4826: setting resizable false toggles resizable on dialog", function() { test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6); expect(6);
var i, var i,
el = $("<div></div>").dialog({ resizable: false }); element = $("<div></div>").dialog({ resizable: false });
TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); TestHelpers.dialog.shouldResize(element, 0, 0, "[default]");
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
el.dialog("close").dialog("open"); element.dialog("close").dialog("open");
TestHelpers.dialog.shouldResize(el, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); TestHelpers.dialog.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")");
} }
el.remove(); element.remove();
el = $("<div></div>").dialog({ resizable: true }); element = $("<div></div>").dialog({ resizable: true });
TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); TestHelpers.dialog.shouldResize(element, 50, 50, "[default]");
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
el.dialog("close").dialog("option", "resizable", false).dialog("open"); element.dialog("close").dialog("option", "resizable", false).dialog("open");
TestHelpers.dialog.shouldResize(el, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); TestHelpers.dialog.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")");
} }
el.remove(); element.remove();
}); });
asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", function() { asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", function() {
expect( 1 ); expect( 1 );
var el = $( "<div></div>" ).dialog({ var element = $( "<div></div>" ).dialog({
show: "explode", show: "explode",
focus: function() { focus: function() {
ok( true, "dialog opened with animation" ); ok( true, "dialog opened with animation" );
el.remove(); element.remove();
start(); start();
} }
}); });
@ -545,11 +545,11 @@ asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", f
asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() { asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() {
expect( 1 ); expect( 1 );
var el = $( "<div></div>" ).dialog({ var element = $( "<div></div>" ).dialog({
show: "blind", show: "blind",
focus: function() { focus: function() {
equal( el.dialog( "widget" ).find( ":focus" ).length, 1, "dialog maintains focus" ); equal( element.dialog( "widget" ).find( ":focus" ).length, 1, "dialog maintains focus" );
el.remove(); element.remove();
start(); start();
} }
}); });
@ -557,17 +557,17 @@ asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() {
asyncTest( "Open followed by close during show effect", function() { asyncTest( "Open followed by close during show effect", function() {
expect( 1 ); expect( 1 );
var el = $( "<div></div>" ).dialog({ var element = $( "<div></div>" ).dialog({
show: "blind", show: "blind",
close: function() { close: function() {
ok( true, "dialog closed properly during animation" ); ok( true, "dialog closed properly during animation" );
el.remove(); element.remove();
start(); start();
} }
}); });
setTimeout( function() { setTimeout( function() {
el.dialog("close"); element.dialog("close");
}, 100 ); }, 100 );
}); });

View File

@ -1,6 +1,6 @@
TestHelpers.dialog = { TestHelpers.dialog = {
drag: function(el, handle, dx, dy) { drag: function(element, handle, dx, dy) {
var d = el.dialog("widget"); var d = element.dialog("widget");
//this mouseover is to work around a limitation in resizable //this mouseover is to work around a limitation in resizable
//TODO: fix resizable so handle doesn't require mouseover in order to be used //TODO: fix resizable so handle doesn't require mouseover in order to be used
$( handle, d ).simulate("mouseover").simulate( "drag", { $( handle, d ).simulate("mouseover").simulate( "drag", {
@ -8,13 +8,13 @@ TestHelpers.dialog = {
dy: dy dy: dy
}); });
}, },
testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) { testDrag: function(element, dx, dy, expectedDX, expectedDY, msg) {
var actualDX, actualDY, offsetAfter, var actualDX, actualDY, offsetAfter,
d = el.dialog("widget"), d = element.dialog("widget"),
handle = $(".ui-dialog-titlebar", d), handle = $(".ui-dialog-titlebar", d),
offsetBefore = d.offset(); offsetBefore = d.offset();
TestHelpers.dialog.drag(el, handle, dx, dy); TestHelpers.dialog.drag(element, handle, dx, dy);
offsetAfter = d.offset(); offsetAfter = d.offset();
@ -24,14 +24,14 @@ TestHelpers.dialog = {
actualDY = offsetAfter.top - offsetBefore.top; actualDY = offsetAfter.top - offsetBefore.top;
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg); ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg);
}, },
shouldResize: function(el, dw, dh, msg) { shouldResize: function(element, dw, dh, msg) {
var heightAfter, widthAfter, actual, expected, var heightAfter, widthAfter, actual, expected,
d = el.dialog("widget"), d = element.dialog("widget"),
handle = $(".ui-resizable-se", d), handle = $(".ui-resizable-se", d),
heightBefore = d.height(), heightBefore = d.height(),
widthBefore = d.width(); widthBefore = d.width();
TestHelpers.dialog.drag(el, handle, 50, 50); TestHelpers.dialog.drag(element, handle, 50, 50);
heightAfter = d.height(); heightAfter = d.height();
widthAfter = d.width(); widthAfter = d.width();