From 13505e5945e5532c3d56424d50ad109c665d205f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 30 Nov 2012 13:08:56 +0100 Subject: Dialog: Ensure all animations finish and clean up themselve when destroying dialog. Fixes #5860 - Dialog: Destroying a dialog during animated close leaves .ui-effects-wrapper in DOM. --- tests/unit/dialog/dialog.html | 2 ++ tests/unit/dialog/dialog_options.js | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 5413e7cc1..cdc846478 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -23,6 +23,8 @@ "ui/jquery.ui.draggable.js", "ui/jquery.ui.resizable.js", "ui/jquery.ui.button.js", + "ui/jquery.ui.effect.js", + "ui/jquery.ui.effect-clip.js", "ui/jquery.ui.dialog.js" ] }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index f01a1a2a8..fd7d91827 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -212,6 +212,15 @@ test("height", function() { el.remove(); }); +asyncTest( "hide, #5860 - don't leave effects wrapper behind", function() { + expect( 1 ); + $( "#dialog1" ).dialog({ hide: "clip" }).dialog( "close" ).dialog( "destroy" ); + setTimeout(function() { + equal( $( ".ui-effects-wrapper" ).length, 0 ); + start(); + }, 500); +}); + test("maxHeight", function() { expect(3); -- cgit v1.2.3 From d687a1b10d1e176a6a8dd4420f1ea3a890640da0 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 4 Dec 2012 00:35:33 +0100 Subject: Dialog: Cleanup style properties on _destroy. Reenables style check in domEqual, while removing commented and unnecessary old code. Fixes #8119 - Dialog: Destroying a dialog leaves style, scrollleft, and scrolltop leftovers. --- tests/unit/dialog/dialog_methods.js | 2 ++ tests/unit/testsuite.js | 32 ++------------------------------ ui/jquery.ui.dialog.js | 5 +++++ 3 files changed, 9 insertions(+), 30 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index e5275c7a4..3753144f3 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -35,6 +35,8 @@ test("init", function() { test("destroy", function() { expect( 6 ); + // expect dialogs to be hidden before and after + $( "#dialog1, #form-dialog" ).hide(); domEqual( "#dialog1", function() { var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 18337fe4e..808e6c6ea 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -210,36 +210,10 @@ window.domEqual = function( selector, modifier, message ) { "nodeName", "role", "tabIndex", - "title" + "title", + "style" ]; -/* - function getElementStyles( elem ) { - var key, len, - style = elem.ownerDocument.defaultView ? - elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : - elem.currentStyle, - styles = {}; - - if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { - len = style.length; - while ( len-- ) { - key = style[ len ]; - if ( typeof style[ key ] === "string" ) { - styles[ $.camelCase( key ) ] = style[ key ]; - } - } - // support: Opera, IE <9 - } else { - for ( key in style ) { - if ( typeof style[ key ] === "string" ) { - styles[ key ] = style[ key ]; - } - } - } - return styles; - } -*/ function extract( elem ) { if ( !elem || !elem.length ) { QUnit.push( false, actual, expected, @@ -257,8 +231,6 @@ window.domEqual = function( selector, modifier, message ) { var value = elem.attr( attr ); result[ attr ] = value !== undefined ? value : ""; }); - // TODO: Enable when we can figure out what's happening with accordion - //result.style = getElementStyles( elem[ 0 ] ); result.events = $._data( elem[ 0 ], "events" ); result.data = $.extend( {}, elem.data() ); delete result.data[ $.expando ]; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 4a8b9964f..382008e08 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -127,6 +127,11 @@ $.widget("ui.dialog", { this.element .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) + .css({ + "width": "", + "min-height": "", + "height": "" + }) .hide() // without detaching first, the following becomes really slow .detach(); -- cgit v1.2.3 From 1e8baf568365f8edc833439315f76e5efe1ba9b6 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 4 Dec 2012 01:08:34 +0100 Subject: Dialog: Remove the instance-storing for the overlay, just create one whenever it is needed. Heavily simplifies the code, while the memorly leak should be hardly an issue anymore, since fixed positioning restricts the overlay size to the window dimensions. Fixes #6058 - Dialog overlays are not properly reused when multiple instances of a Dialog exist. --- tests/unit/dialog/dialog_tickets.js | 11 ----------- ui/jquery.ui.dialog.js | 27 +++++++-------------------- 2 files changed, 7 insertions(+), 31 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js index 655f1e445..389a243b3 100644 --- a/tests/unit/dialog/dialog_tickets.js +++ b/tests/unit/dialog/dialog_tickets.js @@ -107,17 +107,6 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() { d1.remove(); }); -test("#6645: Missing element not found check in overlay", function(){ - expect(2); - var d1 = $('
Dialog 1
').dialog({modal: true}), - d2 = $('
Dialog 2
').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'); - d1.add(d2).remove(); -}); - // TODO merge this with the main destroy test test("#4980: Destroy should place element back in original DOM position", function(){ expect( 2 ); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 382008e08..77392cb19 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -661,13 +661,13 @@ $.widget("ui.dialog", { if ( !this.options.modal ) { return; } - if ( $.ui.dialog.overlay.instances.length === 0 ) { + if ( $.ui.dialog.overlayInstances === 0 ) { // prevent use of anchors and inputs // we use a setTimeout in case the overlay is created from an // event that we're going to be cancelling (see #2804) setTimeout(function() { // handle $(el).dialog().dialog('close') (see #4065) - if ( $.ui.dialog.overlay.instances.length ) { + if ( $.ui.dialog.overlayInstances ) { $( document ).bind( "focusin.dialog-overlay", function( event ) { if ( !$( event.target ).closest( ".ui-dialog").length ) { event.preventDefault(); @@ -678,40 +678,27 @@ $.widget("ui.dialog", { }, 1 ); } - // reuse old instances due to IE memory leak with alpha transparency (see #5185) - var $el = this.overlay = ( $.ui.dialog.overlay.oldInstances.pop() || $( "
" ).addClass( "ui-widget-overlay ui-front" ) ); - + var $el = this.overlay = $( "
" ).addClass( "ui-widget-overlay ui-front" ); $el.appendTo( this.document[ 0 ].body ); - this._on( $el, { mousedown: "_keepFocus" }); - - $.ui.dialog.overlay.instances.push( $el ); + $.ui.dialog.overlayInstances += 1; }, _destroyOverlay: function() { if ( !this.options.modal ) { return; } - var indexOf = $.inArray( this.overlay, $.ui.dialog.overlay.instances ); - - if ( indexOf !== -1 ) { - $.ui.dialog.overlay.oldInstances.push( $.ui.dialog.overlay.instances.splice( indexOf, 1 )[ 0 ] ); - } - - if ( $.ui.dialog.overlay.instances.length === 0 ) { + $.ui.dialog.overlayInstances -= 1; + if ( $.ui.dialog.overlayInstances === 0 ) { $( [ document, window ] ).unbind( ".dialog-overlay" ); } - this.overlay.remove(); } }); -$.ui.dialog.overlay = { - instances: [], - oldInstances: [] -}; +$.ui.dialog.overlayInstances = 0; // DEPRECATED if ( $.uiBackCompat !== false ) { -- cgit v1.2.3 From 050e71bdd88708ce6e8462a89af4399cffa72cf3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 4 Dec 2012 09:21:33 -0500 Subject: Revert "Dialog: Cleanup style properties on _destroy. Reenables style check in domEqual, while removing commented and unnecessary old code. Fixes #8119 - Dialog: Destroying a dialog leaves style, scrollleft, and scrolltop leftovers." This reverts commit d687a1b10d1e176a6a8dd4420f1ea3a890640da0. --- tests/unit/dialog/dialog_methods.js | 2 -- tests/unit/testsuite.js | 32 ++++++++++++++++++++++++++++++-- ui/jquery.ui.dialog.js | 5 ----- 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 3753144f3..e5275c7a4 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -35,8 +35,6 @@ test("init", function() { test("destroy", function() { expect( 6 ); - // expect dialogs to be hidden before and after - $( "#dialog1, #form-dialog" ).hide(); domEqual( "#dialog1", function() { var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 808e6c6ea..18337fe4e 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -210,10 +210,36 @@ window.domEqual = function( selector, modifier, message ) { "nodeName", "role", "tabIndex", - "title", - "style" + "title" ]; +/* + function getElementStyles( elem ) { + var key, len, + style = elem.ownerDocument.defaultView ? + elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : + elem.currentStyle, + styles = {}; + + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { + len = style.length; + while ( len-- ) { + key = style[ len ]; + if ( typeof style[ key ] === "string" ) { + styles[ $.camelCase( key ) ] = style[ key ]; + } + } + // support: Opera, IE <9 + } else { + for ( key in style ) { + if ( typeof style[ key ] === "string" ) { + styles[ key ] = style[ key ]; + } + } + } + return styles; + } +*/ function extract( elem ) { if ( !elem || !elem.length ) { QUnit.push( false, actual, expected, @@ -231,6 +257,8 @@ window.domEqual = function( selector, modifier, message ) { var value = elem.attr( attr ); result[ attr ] = value !== undefined ? value : ""; }); + // TODO: Enable when we can figure out what's happening with accordion + //result.style = getElementStyles( elem[ 0 ] ); result.events = $._data( elem[ 0 ], "events" ); result.data = $.extend( {}, elem.data() ); delete result.data[ $.expando ]; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 472d686a2..361beeb4c 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -127,11 +127,6 @@ $.widget("ui.dialog", { this.element .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) - .css({ - "width": "", - "min-height": "", - "height": "" - }) .hide() // without detaching first, the following becomes really slow .detach(); -- cgit v1.2.3 From 3c2acc322782cc08e575405f8123029342e33542 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 4 Dec 2012 10:03:05 -0500 Subject: Dialog: Remove width, min-height, height styles on destroy. Fixes #8119 - Dialog: Destroying a dialog leaves some styles changed. --- tests/unit/dialog/dialog_methods.js | 5 +++++ tests/unit/testsuite.js | 7 +++---- ui/jquery.ui.dialog.js | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index e5275c7a4..6eeb50273 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -35,6 +35,11 @@ test("init", function() { test("destroy", function() { expect( 6 ); + + // Dialogs are expected to be hidden on destroy, so make sure they're hidden + // before the test + $( "#dialog1, #form-dialog" ).hide(); + domEqual( "#dialog1", function() { var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 18337fe4e..42fdf4f9e 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -212,7 +212,7 @@ window.domEqual = function( selector, modifier, message ) { "tabIndex", "title" ]; -/* + function getElementStyles( elem ) { var key, len, style = elem.ownerDocument.defaultView ? @@ -239,7 +239,7 @@ window.domEqual = function( selector, modifier, message ) { return styles; } -*/ + function extract( elem ) { if ( !elem || !elem.length ) { QUnit.push( false, actual, expected, @@ -257,8 +257,7 @@ window.domEqual = function( selector, modifier, message ) { var value = elem.attr( attr ); result[ attr ] = value !== undefined ? value : ""; }); - // TODO: Enable when we can figure out what's happening with accordion - //result.style = getElementStyles( elem[ 0 ] ); + result.style = getElementStyles( elem[ 0 ] ); result.events = $._data( elem[ 0 ], "events" ); result.data = $.extend( {}, elem.data() ); delete result.data[ $.expando ]; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 361beeb4c..96c998656 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -127,6 +127,11 @@ $.widget("ui.dialog", { this.element .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) + .css({ + width: "", + minHeight: "", + height: "" + }) .hide() // without detaching first, the following becomes really slow .detach(); -- cgit v1.2.3 From f59f5a8b12d50c87ba6e2fe47a1804a23535b3cf Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 5 Dec 2012 11:53:34 -0500 Subject: Dialog: Restore inline styles for dimensions/display. Fixes #8119 - Dialog: Destroying a dialog leaves some styles changed. --- tests/unit/dialog/dialog_methods.js | 15 +++++++++++---- ui/jquery.ui.dialog.js | 13 +++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 6eeb50273..92fe3d60f 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -34,12 +34,9 @@ test("init", function() { }); test("destroy", function() { - expect( 6 ); + expect( 7 ); - // Dialogs are expected to be hidden on destroy, so make sure they're hidden - // before the test $( "#dialog1, #form-dialog" ).hide(); - domEqual( "#dialog1", function() { var dialog = $( "#dialog1" ).dialog().dialog( "destroy" ); equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); @@ -50,6 +47,16 @@ test("destroy", function() { equal( dialog.parent()[ 0 ], $( "#qunit-fixture" )[ 0 ] ); equal( dialog.index(), 2 ); }); + + // Ensure dimensions are restored (#8119) + $( "#dialog1" ).show().css({ + width: "400px", + minHeight: "100px", + height: "200px" + }); + domEqual( "#dialog1", function() { + $( "#dialog1" ).dialog().dialog( "destroy" ); + }); }); test( "enable/disable disabled", function() { diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 96c998656..eac818fe0 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -84,6 +84,12 @@ $.widget("ui.dialog", { }, _create: function() { + this.originalCss = { + display: this.element[0].style.display, + width: this.element[0].style.width, + minHeight: this.element[0].style.minHeight, + height: this.element[0].style.height + }; this.originalTitle = this.element.attr( "title" ); this.options.title = this.options.title || this.originalTitle; this.oldPosition = { @@ -127,12 +133,7 @@ $.widget("ui.dialog", { this.element .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) - .css({ - width: "", - minHeight: "", - height: "" - }) - .hide() + .css( this.originalCss ) // without detaching first, the following becomes really slow .detach(); -- cgit v1.2.3 From 70b16ef445d8f9947fd414894d97673706ee8c6f Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 7 Dec 2012 14:54:21 -0500 Subject: Dialog: Added appendTo option. Fixes #7948 - Dialog: Allow dialog to be attached to a element other than body. --- tests/unit/dialog/dialog.html | 2 ++ tests/unit/dialog/dialog_common.js | 1 + tests/unit/dialog/dialog_options.js | 41 +++++++++++++++++++++++++++++++++++++ ui/jquery.ui.dialog.js | 15 +++++++++++++- 4 files changed, 58 insertions(+), 1 deletion(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index cdc846478..8f2583ce1 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -61,6 +61,8 @@
+
+
diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 47fff1013..9657a9887 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -1,5 +1,6 @@ TestHelpers.commonWidgetTests( "dialog", { defaults: { + appendTo: "body", autoOpen: true, buttons: {}, closeOnEscape: true, diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index fd7d91827..19e69b29a 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -5,6 +5,47 @@ module("dialog: options"); +test( "appendTo", function() { + expect( 8 ); + var detached = $( "
" ), + element = $( "#dialog1" ).dialog(); + equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: ".wrap" + }); + equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" ); + equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: null + }); + equal( element.dialog( "widget" ).parent()[0], document.body, "null" ); + element.dialog( "destroy" ); + + element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" ); + equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: detached + }); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" ); + element.dialog( "destroy" ); + + element.dialog({ + appendTo: detached[0] + }); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" ); + element.dialog( "destroy" ); + + element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached ); + equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" ); + element.dialog( "destroy" ); +}); + test("autoOpen", function() { expect(2); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b2b8be8c0..939571a68 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -39,6 +39,7 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-fr $.widget("ui.dialog", { version: "@VERSION", options: { + appendTo: "body", autoOpen: true, buttons: {}, closeOnEscape: true, @@ -124,6 +125,14 @@ $.widget("ui.dialog", { } }, + _appendTo: function() { + var element = this.options.appendTo; + if ( element && (element.jquery || element.nodeType) ) { + return $( element ); + } + return this.document.find( element || "body" ).eq( 0 ); + }, + _destroy: function() { var next, oldPosition = this.oldPosition; @@ -276,7 +285,7 @@ $.widget("ui.dialog", { tabIndex: -1, role: "dialog" }) - .appendTo( this.document[ 0 ].body ); + .appendTo( this._appendTo() ); this._on( this.uiDialog, { keydown: function( event ) { @@ -569,6 +578,10 @@ $.widget("ui.dialog", { this._super( key, value ); + if ( key === "appendTo" ) { + this.uiDialog.appendTo( this._appendTo() ); + } + if ( key === "buttons" ) { this._createButtons(); } -- cgit v1.2.3 From d4551bc3b8dfbfd925700dcb9f71e7729b125889 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 7 Dec 2012 16:57:03 -0500 Subject: Dialog: Respect maxHeight when determining size on open. Fixes #4820 - Dialog: Auto height does not respect the maxHeight option. --- tests/unit/dialog/dialog_common.js | 4 ++-- ui/jquery.ui.dialog.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 9657a9887..1a9b4e109 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -10,8 +10,8 @@ TestHelpers.commonWidgetTests( "dialog", { draggable: true, height: 'auto', hide: null, - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 939571a68..2553109ba 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -48,8 +48,8 @@ $.widget("ui.dialog", { draggable: true, hide: null, height: "auto", - maxHeight: false, - maxWidth: false, + maxHeight: null, + maxWidth: null, minHeight: 150, minWidth: 150, modal: false, @@ -89,6 +89,7 @@ $.widget("ui.dialog", { display: this.element[0].style.display, width: this.element[0].style.width, minHeight: this.element[0].style.minHeight, + maxHeight: this.element[0].style.maxHeight, height: this.element[0].style.height }; this.originalTitle = this.element.attr( "title" ); @@ -632,16 +633,16 @@ $.widget("ui.dialog", { }, _size: function() { - // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content // divs will both have width and height set, so we need to reset them - var nonContentHeight, minContentHeight, + var nonContentHeight, minContentHeight, maxContentHeight, options = this.options; // reset content sizing this.element.show().css({ width: "auto", minHeight: 0, + maxHeight: "none", height: 0 }); @@ -657,14 +658,18 @@ $.widget("ui.dialog", { }) .outerHeight(); minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); + maxContentHeight = typeof options.maxHeight === "number" ? + Math.max( 0, options.maxHeight - nonContentHeight ) : + "none"; if ( options.height === "auto" ) { this.element.css({ minHeight: minContentHeight, + maxHeight: maxContentHeight, height: "auto" }); } else { - this.element.height( Math.max( options.height - nonContentHeight, 0 ) ); + this.element.height( Math.max( 0, options.height - nonContentHeight ) ); } if (this.uiDialog.is( ":data(ui-resizable)" ) ) { -- cgit v1.2.3 From e83a89dd7df3009d46ddd9e7e1cabf42e901e397 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Fri, 7 Dec 2012 20:06:29 -0500 Subject: Dev: Remove *_tickets.js test files and move the associated tests to the proper locations. --- tests/unit/button/button_core.js | 56 +++++++++++++++ tests/unit/button/button_options.js | 11 +++ tests/unit/button/button_tickets.js | 75 -------------------- tests/unit/dialog/dialog_core.js | 32 ++++++++- tests/unit/dialog/dialog_events.js | 14 ++++ tests/unit/dialog/dialog_methods.js | 48 +++++++++++++ tests/unit/dialog/dialog_options.js | 22 ++++++ tests/unit/dialog/dialog_tickets.js | 121 -------------------------------- tests/unit/sortable/sortable_events.js | 61 ++++++++++++++++ tests/unit/sortable/sortable_tickets.js | 69 ------------------ 10 files changed, 242 insertions(+), 267 deletions(-) delete mode 100644 tests/unit/button/button_tickets.js delete mode 100644 tests/unit/dialog/dialog_tickets.js delete mode 100644 tests/unit/sortable/sortable_tickets.js (limited to 'tests/unit/dialog') diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 991e4bceb..460201f15 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -113,4 +113,60 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) { }); } +test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { + expect( 5 ); + var group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.filter( "input[type=checkbox]" ).button(); + ok( group.filter( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.filter( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.find( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); + + group = $( "" ); + group.filter( "input[type=checkbox]" ).button(); + ok( group.find( "label" ).is( ".ui-button" ) ); +}); + +test( "#5946 - buttonset should ignore buttons that are not :visible", function() { + expect( 2 ); + $( "#radio01" ).next().andSelf().hide(); + var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); + ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); + ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) ); +}); + +test( "#6262 - buttonset not applying ui-corner to invisible elements", function() { + expect( 3 ); + $( "#radio0" ).hide(); + var set = $( "#radio0" ).buttonset(); + ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) ); + ok( set.find( "label:eq(1)" ).is( ".ui-button" ) ); + ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); +}); + +test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { + expect( 2 ); + var check = $( "#check" ).button(), + label = $( "label[for='check']" ); + ok( !label.is( ".ui-state-focus" ) ); + check.focus(); + ok( label.is( ".ui-state-focus" ) ); +}); + +test( "#7534 - Button label selector works for ids with \":\"", function() { + expect( 1 ); + var group = $( "" ); + group.find( "input" ).button(); + ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); +}); + })(jQuery); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index eeb6e5527..e1931a54e 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -103,4 +103,15 @@ test("icons", function() { $("#button").button("destroy"); }); +test( "#5295 - button does not remove hoverstate if disabled" , function() { + expect( 1 ); + var btn = $("#button").button(); + btn.hover( function() { + btn.button( "disable" ); + }); + btn.trigger( "mouseenter" ); + btn.trigger( "mouseleave" ); + ok( !btn.is( ".ui-state-hover") ); +}); + })(jQuery); diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js deleted file mode 100644 index 1272d368f..000000000 --- a/tests/unit/button/button_tickets.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - * button_tickets.js - */ -(function( $ ) { - -module( "button: tickets" ); - -test( "#5295 - button does not remove hoverstate if disabled" , function() { - expect( 1 ); - var btn = $("#button").button(); - btn.hover( function() { - btn.button( "disable" ); - }); - btn.trigger( "mouseenter" ); - btn.trigger( "mouseleave" ); - ok( !btn.is( ".ui-state-hover") ); -}); - -test( "#5946 - buttonset should ignore buttons that are not :visible", function() { - expect( 2 ); - $( "#radio01" ).next().andSelf().hide(); - var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); - ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); - ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) ); -}); - -test( "#6262 - buttonset not applying ui-corner to invisible elements", function() { - expect( 3 ); - $( "#radio0" ).hide(); - var set = $( "#radio0" ).buttonset(); - ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) ); - ok( set.find( "label:eq(1)" ).is( ".ui-button" ) ); - ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); -}); - -test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { - expect( 2 ); - var check = $( "#check" ).button(), - label = $( "label[for='check']" ); - ok( !label.is( ".ui-state-focus" ) ); - check.focus(); - ok( label.is( ".ui-state-focus" ) ); -}); - -test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { - expect( 5 ); - var group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.filter( "input[type=checkbox]" ).button(); - ok( group.filter( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.filter( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.find( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); - - group = $( "" ); - group.filter( "input[type=checkbox]" ).button(); - ok( group.find( "label" ).is( ".ui-button" ) ); -}); - -test( "#7534 - Button label selector works for ids with \":\"", function() { - expect( 1 ); - var group = $( "" ); - group.find( "input" ).button(); - ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); -}); - -})( jQuery ); diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 9c0e80825..700208dfc 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -80,8 +80,7 @@ test( "focus tabbable", function() { }, 13); }); -// #7960 -test( "resizable handles below modal overlays", function() { +test( "#7960: resizable handles below modal overlays", function() { expect( 1 ); var resizable = $( "
" ).resizable(), @@ -93,4 +92,33 @@ test( "resizable handles below modal overlays", function() { dialog.dialog( "destroy" ); }); +asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { + expect( 3 ); + + var el = $( "
" ).dialog({ modal: true }), + inputs = el.find( "input" ), + widget = el.dialog( "widget" )[ 0 ]; + + function checkTab() { + ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); + + // check shift tab + $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); + setTimeout( checkShiftTab, 2 ); + } + + function checkShiftTab() { + ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); + + 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 ); +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index cbeced0f8..19337ad5d 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -341,4 +341,18 @@ asyncTest("ensure dialog's container doesn't scroll on resize and focus", functi }, 500); }); +test("#5184: isOpen in dialogclose event is true", function() { + expect( 3 ); + + var el = $( "
" ).dialog({ + close: function() { + ok( !el.dialog("isOpen"), "dialog is not open during close" ); + } + }); + ok( el.dialog("isOpen"), "dialog is open after init" ); + el.dialog( "close" ); + ok( !el.dialog("isOpen"), "dialog is not open after close" ); + el.remove(); +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 92fe3d60f..fbb649fbf 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -137,4 +137,52 @@ test("open", function() { ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called'); }); +// TODO merge this with the main destroy test +test("#4980: Destroy should place element back in original DOM position", function(){ + expect( 2 ); + var container = $('
'), + modal = container.find('#modal'); + modal.dialog(); + ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); + modal.dialog('destroy'); + ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); +}); + +test("#6137: dialog('open') causes form elements to reset on IE7", function() { + expect(2); + + var d1 = $('
' + + 'b
').appendTo( "body" ).dialog({autoOpen: false}); + + d1.find('#b').prop( "checked", true ); + equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + + d1.dialog('open'); + equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); + + d1.remove(); +}); + +test("#5531: dialog width should be at least minWidth on creation", function () { + expect( 4 ); + var el = $('
').dialog({ + width: 200, + minWidth: 300 + }); + + equal(el.dialog('option', 'width'), 300, "width is minWidth"); + el.dialog('option', 'width', 200); + equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth"); + el.dialog('option', 'width', 320); + equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth"); + el.remove(); + + el = $('
').dialog({ + minWidth: 300 + }); + ok(el.dialog('option', 'width') >= 300, "width is at least 300"); + el.remove(); + +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 19e69b29a..2ccbed573 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -478,4 +478,26 @@ test("width", function() { el.remove(); }); +test("#4826: setting resizable false toggles resizable on dialog", function() { + expect(6); + var i, + el = $('
').dialog({ resizable: false }); + + TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); + for (i=0; i<2; i++) { + el.dialog('close').dialog('open'); + TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')'); + } + el.remove(); + + el = $('
').dialog({ resizable: true }); + TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); + for (i=0; i<2; i++) { + el.dialog('close').dialog('option', 'resizable', false).dialog('open'); + TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')'); + } + el.remove(); + +}); + })(jQuery); diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js deleted file mode 100644 index 389a243b3..000000000 --- a/tests/unit/dialog/dialog_tickets.js +++ /dev/null @@ -1,121 +0,0 @@ -/* - * dialog_tickets.js - */ -(function($) { - -module( "dialog: tickets" ); - -asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { - expect( 3 ); - - var el = $( "
" ).dialog({ modal: true }), - inputs = el.find( "input" ), - widget = el.dialog( "widget" )[ 0 ]; - - function checkTab() { - ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); - - // check shift tab - $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); - setTimeout( checkShiftTab, 2 ); - } - - function checkShiftTab() { - ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); - - 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 = $('
').dialog({ resizable: false }); - - TestHelpers.dialog.shouldResize(el, 0, 0, "[default]"); - for (i=0; i<2; i++) { - el.dialog('close').dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')'); - } - el.remove(); - - el = $('
').dialog({ resizable: true }); - TestHelpers.dialog.shouldResize(el, 50, 50, "[default]"); - for (i=0; i<2; i++) { - el.dialog('close').dialog('option', 'resizable', false).dialog('open'); - TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')'); - } - el.remove(); - -}); - -test("#5184: isOpen in dialogclose event is true", function() { - expect( 3 ); - - var el = $( "
" ).dialog({ - close: function() { - ok( !el.dialog("isOpen"), "dialog is not open during close" ); - } - }); - ok( el.dialog("isOpen"), "dialog is open after init" ); - el.dialog( "close" ); - ok( !el.dialog("isOpen"), "dialog is not open after close" ); - el.remove(); -}); - -test("#5531: dialog width should be at least minWidth on creation", function () { - expect( 4 ); - var el = $('
').dialog({ - width: 200, - minWidth: 300 - }); - - equal(el.dialog('option', 'width'), 300, "width is minWidth"); - el.dialog('option', 'width', 200); - equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth"); - el.dialog('option', 'width', 320); - equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth"); - el.remove(); - - el = $('
').dialog({ - minWidth: 300 - }); - ok(el.dialog('option', 'width') >= 300, "width is at least 300"); - el.remove(); - -}); - -test("#6137: dialog('open') causes form elements to reset on IE7", function() { - expect(2); - - var d1 = $('
' + - 'b
').appendTo( "body" ).dialog({autoOpen: false}); - - d1.find('#b').prop( "checked", true ); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); - - d1.dialog('open'); - equal(d1.find('input:checked').val(), 'b', "checkbox b is checked"); - - d1.remove(); -}); - -// TODO merge this with the main destroy test -test("#4980: Destroy should place element back in original DOM position", function(){ - expect( 2 ); - var container = $('
'), - modal = container.find('#modal'); - modal.dialog(); - ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); - modal.dialog('destroy'); - ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); -}); - -})(jQuery); diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 556f539e1..4245d64fa 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -128,6 +128,67 @@ test("update", function() { }); +test("#3019: Stop fires too early", function() { + expect(2); + + var helper = null, + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); + + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); + equal(helper, null, "helper should be false"); + +}); + +test('#4752: link event firing on sortable with connect list', function () { + expect( 10 ); + + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + + $('#qunit-fixture ul').sortable({ + connectWith: '#qunit-fixture ul', + change: function () { + fired.change = true; + }, + receive: function () { + fired.receive = true; + }, + remove: function () { + fired.remove = true; + } + }); + + $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { + fired.click = true; + }); + + $('#sortable li:eq(0)').simulate('click'); + ok(!hasFired('change'), 'Click only, change event should not have fired'); + ok(hasFired('click'), 'Click event should have fired'); + + // Drag an item within the first list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); + ok(hasFired('change'), '40px drag, change event should have fired'); + ok(!hasFired('receive'), 'Receive event should not have fired'); + ok(!hasFired('remove'), 'Remove event should not have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); + + // Drag an item from the first list to the second, connected list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); + ok(hasFired('change'), '150px drag, change event should have fired'); + ok(hasFired('receive'), 'Receive event should have fired'); + ok(hasFired('remove'), 'Remove event should have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); +}); + /* test("receive", function() { ok(false, "missing test - untested code is broken code."); diff --git a/tests/unit/sortable/sortable_tickets.js b/tests/unit/sortable/sortable_tickets.js deleted file mode 100644 index eebd8dc21..000000000 --- a/tests/unit/sortable/sortable_tickets.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * sortable_tickets.js - */ -(function($) { - -module("sortable: tickets"); - -test("#3019: Stop fires too early", function() { - expect(2); - - var helper = null, - el = $("#sortable").sortable({ - stop: function(event, ui) { - helper = ui.helper; - } - }); - - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); - equal(helper, null, "helper should be false"); - -}); - -test('#4752: link event firing on sortable with connect list', function () { - expect( 10 ); - - var fired = {}, - hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - - $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); - - $('#qunit-fixture ul').sortable({ - connectWith: '#qunit-fixture ul', - change: function () { - fired.change = true; - }, - receive: function () { - fired.receive = true; - }, - remove: function () { - fired.remove = true; - } - }); - - $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { - fired.click = true; - }); - - $('#sortable li:eq(0)').simulate('click'); - ok(!hasFired('change'), 'Click only, change event should not have fired'); - ok(hasFired('click'), 'Click event should have fired'); - - // Drag an item within the first list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); - ok(hasFired('change'), '40px drag, change event should have fired'); - ok(!hasFired('receive'), 'Receive event should not have fired'); - ok(!hasFired('remove'), 'Remove event should not have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); - - // Drag an item from the first list to the second, connected list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); - ok(hasFired('change'), '150px drag, change event should have fired'); - ok(hasFired('receive'), 'Receive event should have fired'); - ok(hasFired('remove'), 'Remove event should have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); -}); - -})(jQuery); -- cgit v1.2.3 From 5dee8dee309564626393e1871991aa2a0e58dd74 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 8 Dec 2012 13:19:36 -0500 Subject: Dev: Change incorrect references in test suite from #main to #qunit-fixture. --- tests/unit/dialog/dialog_core.js | 3 ++- tests/unit/draggable/draggable_core.js | 2 +- tests/unit/tabs/tabs_core.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 700208dfc..f10087912 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -34,8 +34,9 @@ test( "ARIA", function() { test("widget method", function() { expect( 1 ); - var dialog = $("
").appendTo("#main").dialog(); + var dialog = $("
").appendTo("#qunit-fixture").dialog(); deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]); + dialog.remove(); }); test( "focus tabbable", function() { diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 28a19f380..66628465b 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -17,7 +17,7 @@ test("element types", function() { $.each(typeNames, function(i) { var offsetBefore, offsetAfter, typeName = typeNames[i], - el = $(document.createElement(typeName)).appendTo('#main'); + el = $(document.createElement(typeName)).appendTo('#qunit-fixture'); (typeName === 'table' && el.append("content")); el.draggable({ cancel: '' }); diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index 20364a37d..5f70206dc 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -599,8 +599,8 @@ test( "#3627 - Ajax tab with url containing a fragment identifier fails to load" test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", function() { expect( 2 ); - var element = $( "" ); - element.appendTo( "#main" ); + var element = $(""); + element.appendTo("#qunit-fixture"); element.tabs({ beforeLoad: function() { event.preventDefault(); @@ -608,7 +608,7 @@ test( "#4033 - IE expands hash to full url and misinterprets tab as ajax", funct } }); - equal( element.find( ".ui-tabs-nav li" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" ); + equal( element.find(".ui-tabs-nav li").attr("aria-controls"), "tab", "aria-contorls attribute is correct" ); state( element, 1 ); }); -- cgit v1.2.3 From 9f764467751c1c5bdefa28421807eafc9868b37f Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 8 Dec 2012 21:27:37 -0500 Subject: Dev: remove unnecessary simulated drag delegation in test suite --- tests/unit/dialog/dialog_test_helpers.js | 7 +- tests/unit/draggable/draggable_core.js | 23 ++- tests/unit/draggable/draggable_events.js | 20 ++- tests/unit/draggable/draggable_options.js | 144 ++++++++++++------ tests/unit/draggable/draggable_test_helpers.js | 11 +- tests/unit/resizable/resizable_test_helpers.js | 17 +-- tests/unit/selectable/selectable_events.js | 30 ++-- tests/unit/selectable/selectable_methods.js | 21 ++- tests/unit/selectable/selectable_options.js | 22 ++- tests/unit/selectable/selectable_test_helpers.js | 8 - tests/unit/sortable/sortable_events.js | 180 ++++++++++++++--------- tests/unit/sortable/sortable_test_helpers.js | 10 +- 12 files changed, 300 insertions(+), 193 deletions(-) delete mode 100644 tests/unit/selectable/selectable_test_helpers.js (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index bbf43f48f..ef0b9b6fa 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -3,10 +3,9 @@ TestHelpers.dialog = { var d = el.dialog('widget'); //this mouseover is to work around a limitation in resizable //TODO: fix resizable so handle doesn't require mouseover in order to be used - $(handle, d).simulate("mouseover"); - $(handle, d).simulate("drag", { - dx: dx || 0, - dy: dy || 0 + $( handle, d ).simulate("mouseover").simulate( "drag", { + dx: dx, + dy: dy }); }, testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) { diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 66628465b..2bfccbfa6 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -22,7 +22,10 @@ test("element types", function() { (typeName === 'table' && el.append("content")); el.draggable({ cancel: '' }); offsetBefore = el.offset(); - TestHelpers.draggable.drag(el, 50, 50); + el.simulate( "drag", { + dx: 50, + dy: 50 + }); offsetAfter = el.offset(); // there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">"); @@ -55,21 +58,15 @@ test("resizable handle with complex markup (#8756 / #8757)", function() { .append($('
')) ); - var handle = '.ui-resizable-w div', - target = $('#draggable1').draggable().resizable({ handles: 'all' }), - drag = function(el, dx) { - $(el) - .simulate("mouseover") - .simulate("drag", { - dx: dx || 0, - speed: 'sync' - }); - }; + var handle = $('.ui-resizable-w div'), + target = $('#draggable1').draggable().resizable({ handles: 'all' }); - drag(handle, -50); + // todo: fix resizable so it doesn't require a mouseover + handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); equal( target.width(), 250, "compare width" ); - drag(handle, 50); + // todo: fix resizable so it doesn't require a mouseover + handle.simulate("mouseover").simulate( "drag", { dx: 50 } ); equal( target.width(), 200, "compare width" ); }); diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index 5eab97713..07a53e22e 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -18,7 +18,10 @@ test("callbacks occurrence count", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 3, "drag callback should happen exactly once per mousemove"); @@ -39,7 +42,10 @@ test("stopping the start callback", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 0, "drag callback should not happen at all"); @@ -60,7 +66,10 @@ test("stopping the drag callback", function() { stop: function() { stop++; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); equal(start, 1, "start callback should happen exactly once"); equal(dragc, 1, "drag callback should happen exactly once"); @@ -77,7 +86,10 @@ test("stopping the stop callback", function() { stop: function() { return false; } }); - TestHelpers.draggable.drag(el, 10, 10); + el.simulate( "drag", { + dx: 10, + dy: 10 + }); ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped"); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 3f4592d31..d9a7038f7 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -162,7 +162,11 @@ test("{ containment: 'parent' }, relative", function() { left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') }; - TestHelpers.draggable.drag(el, -100, -100); + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); offsetAfter = el.offset(); deepEqual(offsetAfter, expected, 'compare offset to parent'); }); @@ -178,7 +182,11 @@ test("{ containment: 'parent' }, absolute", function() { left: po.left + TestHelpers.draggable.border(p, 'left') + TestHelpers.draggable.margin(el, 'left'), top: po.top + TestHelpers.draggable.border(p, 'top') + TestHelpers.draggable.margin(el, 'top') }; - TestHelpers.draggable.drag(el, -100, -100); + + el.simulate( "drag", { + dx: -100, + dy: -100 + }); offsetAfter = el.offset(); deepEqual(offsetAfter, expected, 'compare offset to parent'); }); @@ -214,17 +222,20 @@ test("{ cursor: 'auto' }, default", function() { expect(2); - var expected = "auto", actual, before, after; - - $("#draggable2").draggable({ - cursor: expected, - start: function() { - actual = getCursor(); - } - }); + var actual, before, after, + expected = "auto", + el = $("#draggable2").draggable({ + cursor: expected, + start: function() { + actual = getCursor(); + } + }); before = getCursor(); - TestHelpers.draggable.drag("#draggable2", -1, -1); + el.simulate( "drag", { + dx: -1, + dy: -1 + }); after = getCursor(); equal(actual, expected, "start callback: cursor '" + expected + "'"); @@ -238,17 +249,20 @@ test("{ cursor: 'move' }", function() { expect(2); - var expected = "move", actual, before, after; - - $("#draggable2").draggable({ - cursor: expected, - start: function() { - actual = getCursor(); - } - }); + var actual, before, after, + expected = "move", + el = $("#draggable2").draggable({ + cursor: expected, + start: function() { + actual = getCursor(); + } + }); before = getCursor(); - TestHelpers.draggable.drag("#draggable2", -1, -1); + el.simulate( "drag", { + dx: -1, + dy: -1 + }); after = getCursor(); equal(actual, expected, "start callback: cursor '" + expected + "'"); @@ -648,7 +662,10 @@ test("{ helper: 'clone' }, absolute", function() { helperOffset = ui.helper.offset(); } }); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); }); @@ -666,17 +683,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on parent", function() { $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll(); @@ -696,17 +722,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root", function() { $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll('root'); @@ -728,17 +763,26 @@ test("{ helper: 'clone' }, absolute with scroll offset on root and parent", func $("#main").css('position', 'relative'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'static'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); $("#main").css('position', 'absolute'); origOffset = $("#draggable1").offset(); - TestHelpers.draggable.drag(el, 1, 1); + el.simulate( "drag", { + dx: 1, + dy: 1 + }); deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[1, 1] '); TestHelpers.draggable.restoreScroll('root'); @@ -750,17 +794,19 @@ test("{ opacity: 0.5 }", function() { expect(1); - var opacity = null; - - $("#draggable2").draggable({ - opacity: 0.5, - start: function() { - opacity = $(this).css("opacity"); - } + var opacity = null, + el = $("#draggable2").draggable({ + opacity: 0.5, + start: function() { + opacity = $(this).css("opacity"); + } + }); + + el.simulate( "drag", { + dx: -1, + dy: -1 }); - TestHelpers.draggable.drag("#draggable2", -1, -1); - equal(opacity, 0.5, "start callback: opacity is"); }); @@ -770,17 +816,19 @@ test("{ zIndex: 10 }", function() { expect(1); var actual, - expected = 10; - - $("#draggable2").draggable({ - zIndex: expected, - start: function() { - actual = $(this).css("zIndex"); - } + expected = 10, + el = $("#draggable2").draggable({ + zIndex: expected, + start: function() { + actual = $(this).css("zIndex"); + } + }); + + el.simulate( "drag", { + dx: -1, + dy: -1 }); - TestHelpers.draggable.drag("#draggable2", -1, -1); - equal(actual, expected, "start callback: zIndex is"); }); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 7057df1f8..9a6355b2e 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -1,17 +1,14 @@ TestHelpers.draggable = { // todo: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, - drag: function(handle, dx, dy) { - $(handle).simulate("drag", { - dx: dx || 0, - dy: dy || 0 - }); - }, testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) { var offsetAfter, actual, expected, offsetBefore = el.offset(); - TestHelpers.draggable.drag(handle, dx, dy); + $( handle ).simulate( "drag", { + dx: dx, + dy: dy + }); offsetAfter = el.offset(); actual = { left: offsetAfter.left, top: offsetAfter.top }, diff --git a/tests/unit/resizable/resizable_test_helpers.js b/tests/unit/resizable/resizable_test_helpers.js index fe6c84900..88f2bc57b 100644 --- a/tests/unit/resizable/resizable_test_helpers.js +++ b/tests/unit/resizable/resizable_test_helpers.js @@ -1,15 +1,10 @@ TestHelpers.resizable = { - drag: function(el, dx, dy, complete) { - - // speed = sync -> Drag syncrhonously. - // speed = fast|slow -> Drag asyncrhonously - animated. - - //this mouseover is to work around a limitation in resizable - //TODO: fix resizable so handle doesn't require mouseover in order to be used - $(el).simulate("mouseover"); - - return $(el).simulate("drag", { - dx: dx||0, dy: dy||0, speed: 'sync', complete: complete + drag: function( el, dx, dy ) { + // this mouseover is to work around a limitation in resizable + // TODO: fix resizable so handle doesn't require mouseover in order to be used + $( el ).simulate("mouseover").simulate( "drag", { + dx: dx, + dy: dy }); } }; \ No newline at end of file diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js index 331bae146..984fd1862 100644 --- a/tests/unit/selectable/selectable_events.js +++ b/tests/unit/selectable/selectable_events.js @@ -1,32 +1,38 @@ /* * selectable_events.js */ -(function($) { +(function( $ ) { module("selectable: events"); -test("start", function() { - expect(2); +test( "start", function() { + expect( 2 ); var el = $("#selectable1"); el.selectable({ start: function() { - ok(true, "drag fired start callback"); - equal(this, el[0], "context of callback"); + ok( true, "drag fired start callback" ); + equal( this, el[0], "context of callback" ); } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); }); -test("stop", function() { - expect(2); +test( "stop", function() { + expect( 2 ); var el = $("#selectable1"); el.selectable({ start: function() { - ok(true, "drag fired stop callback"); - equal(this, el[0], "context of callback"); + ok( true, "drag fired stop callback" ); + equal( this, el[0], "context of callback" ); } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); }); -})(jQuery); +})( jQuery ); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index aa8924176..d894a13e4 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -53,10 +53,16 @@ test("enable", function() { disabled: true, start: function() { fired = true; } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, false, "start fired"); el.selectable("enable"); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, true, "start fired"); el.selectable("destroy"); @@ -75,11 +81,18 @@ test("disable", function() { disabled: false, start: function() { fired = true; } }); - el.simulate("drag", 20, 20); + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, true, "start fired"); el.selectable("disable"); fired = false; - el.simulate("drag", 20, 20); + + el.simulate( "drag", { + dx: 20, + dy: 20 + }); equal(fired, false, "start fired"); el.selectable("destroy"); diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js index 50e047427..a2455fdca 100644 --- a/tests/unit/selectable/selectable_options.js +++ b/tests/unit/selectable/selectable_options.js @@ -15,7 +15,10 @@ test("autoRefresh", function() { el = $("#selectable1").selectable({ autoRefresh: false, selected: selected }); sel.hide(); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, sel.length); el.selectable("destroy"); @@ -23,11 +26,19 @@ test("autoRefresh", function() { sel.show(); el = $("#selectable1").selectable({ autoRefresh: true, selected: selected }); sel.hide(); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, 0); + sel.show(); - TestHelpers.selectable.drag( sel[ 0 ], 1000, 1000 ); + $( sel[ 0 ] ).simulate( "drag", { + dx: 1000, + dy: 1000 + }); equal(actual, sel.length); + el.selectable("destroy"); sel.show(); }); @@ -42,7 +53,10 @@ test("filter", function() { el = $("#selectable1").selectable({ filter: '.special', selected: selected }); - TestHelpers.selectable.drag(el, 1000, 1000); + el.simulate( "drag", { + dx: 1000, + dy: 1000 + }); ok(sel.length !== 1, "this test assumes more than 1 selectee"); equal(actual, 1); el.selectable("destroy"); diff --git a/tests/unit/selectable/selectable_test_helpers.js b/tests/unit/selectable/selectable_test_helpers.js deleted file mode 100644 index 6f87efbb3..000000000 --- a/tests/unit/selectable/selectable_test_helpers.js +++ /dev/null @@ -1,8 +0,0 @@ -TestHelpers.selectable = { - drag: function( el, dx, dy ) { - $( el ).simulate( "drag", { - dx: dx || 0, - dy: dy || 0 - }); - } -}; \ No newline at end of file diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 4245d64fa..b9ee078f5 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -9,9 +9,13 @@ test("start", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ start: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); + $("#sortable").sortable({ + start: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); ok(hash, 'start event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -30,9 +34,13 @@ test("sort", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ sort: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); + $("#sortable").sortable({ + sort: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 10 + }); ok(hash, 'sort event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -48,15 +56,24 @@ test("change", function() { expect( 8 ); var hash; - $("#sortable") - .sortable({ change: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); + $("#sortable").sortable({ + change: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dx: 1, + dy: 1 + }); ok(!hash, '1px drag, change event should not be triggered'); - $("#sortable") - .sortable({ change: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 }); + $("#sortable").sortable({ + change: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 22 + }); ok(hash, 'change event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -72,9 +89,13 @@ test("beforeStop", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ beforeStop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + $("#sortable").sortable({ + beforeStop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 20 + }); ok(hash, 'beforeStop event triggered'); ok(hash.helper, 'UI hash includes: helper'); @@ -90,9 +111,13 @@ test("stop", function() { expect( 7 ); var hash; - $("#sortable") - .sortable({ stop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + $("#sortable").sortable({ + stop: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 20 + }); ok(hash, 'stop event triggered'); ok(!hash.helper, 'UI should not include: helper'); @@ -108,15 +133,24 @@ test("update", function() { expect( 8 ); var hash; - $("#sortable") - .sortable({ update: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); + $("#sortable").sortable({ + update: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dx: 1, + dy: 1 + }); ok(!hash, '1px drag, update event should not be triggered'); - $("#sortable") - .sortable({ update: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 22 }); + $("#sortable").sortable({ + update: function( e, ui ) { + hash = ui; + } + }).find("li:eq(0)").simulate( "drag", { + dy: 22 + }); ok(hash, 'update event triggered'); ok(!hash.helper, 'UI hash should not include: helper'); @@ -129,14 +163,14 @@ test("update", function() { }); test("#3019: Stop fires too early", function() { - expect(2); + expect(2); var helper = null, - el = $("#sortable").sortable({ - stop: function(event, ui) { - helper = ui.helper; - } - }); + el = $("#sortable").sortable({ + stop: function(event, ui) { + helper = ui.helper; + } + }); TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, 'Dragging the sortable'); equal(helper, null, "helper should be false"); @@ -144,49 +178,49 @@ test("#3019: Stop fires too early", function() { }); test('#4752: link event firing on sortable with connect list', function () { - expect( 10 ); - - var fired = {}, - hasFired = function (type) { return (type in fired) && (true === fired[type]); }; - - $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); - - $('#qunit-fixture ul').sortable({ - connectWith: '#qunit-fixture ul', - change: function () { - fired.change = true; - }, - receive: function () { - fired.receive = true; - }, - remove: function () { - fired.remove = true; - } - }); - - $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { - fired.click = true; - }); - - $('#sortable li:eq(0)').simulate('click'); - ok(!hasFired('change'), 'Click only, change event should not have fired'); - ok(hasFired('click'), 'Click event should have fired'); - - // Drag an item within the first list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); - ok(hasFired('change'), '40px drag, change event should have fired'); - ok(!hasFired('receive'), 'Receive event should not have fired'); - ok(!hasFired('remove'), 'Remove event should not have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); - - // Drag an item from the first list to the second, connected list - fired = {}; - $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); - ok(hasFired('change'), '150px drag, change event should have fired'); - ok(hasFired('receive'), 'Receive event should have fired'); - ok(hasFired('remove'), 'Remove event should have fired'); - ok(!hasFired('click'), 'Click event should not have fired'); + expect( 10 ); + + var fired = {}, + hasFired = function (type) { return (type in fired) && (true === fired[type]); }; + + $('#sortable').clone().attr('id', 'sortable2').insertAfter('#sortable'); + + $('#qunit-fixture ul').sortable({ + connectWith: '#qunit-fixture ul', + change: function () { + fired.change = true; + }, + receive: function () { + fired.receive = true; + }, + remove: function () { + fired.remove = true; + } + }); + + $('#qunit-fixture ul').bind('click.ui-sortable-test', function () { + fired.click = true; + }); + + $('#sortable li:eq(0)').simulate('click'); + ok(!hasFired('change'), 'Click only, change event should not have fired'); + ok(hasFired('click'), 'Click event should have fired'); + + // Drag an item within the first list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 40 }); + ok(hasFired('change'), '40px drag, change event should have fired'); + ok(!hasFired('receive'), 'Receive event should not have fired'); + ok(!hasFired('remove'), 'Remove event should not have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); + + // Drag an item from the first list to the second, connected list + fired = {}; + $('#sortable li:eq(0)').simulate('drag', { dx: 0, dy: 150 }); + ok(hasFired('change'), '150px drag, change event should have fired'); + ok(hasFired('receive'), 'Receive event should have fired'); + ok(hasFired('remove'), 'Remove event should have fired'); + ok(!hasFired('click'), 'Click event should not have fired'); }); /* diff --git a/tests/unit/sortable/sortable_test_helpers.js b/tests/unit/sortable/sortable_test_helpers.js index 7569b5797..12e4829ea 100644 --- a/tests/unit/sortable/sortable_test_helpers.js +++ b/tests/unit/sortable/sortable_test_helpers.js @@ -1,9 +1,9 @@ TestHelpers.sortable = { - sort: function(handle, dx, dy, index, msg) { - $(handle).simulate("drag", { - dx: dx || 0, - dy: dy || 0 + sort: function( handle, dx, dy, index, msg ) { + $( handle ).simulate( "drag", { + dx: dx, + dy: dy }); - equal($(handle).parent().children().index(handle), index, msg); + equal( $( handle ).parent().children().index( handle ), index, msg ); } }; \ No newline at end of file -- cgit v1.2.3 From 0f0ec001aac23acb4b7f8cd8fc5e549b541a685d Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 08:52:54 -0500 Subject: Dialog tests: Updated markup for deprecated tests to match standard tests. --- tests/unit/dialog/dialog_deprecated.html | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html index 2a876ac73..3360e6ef7 100644 --- a/tests/unit/dialog/dialog_deprecated.html +++ b/tests/unit/dialog/dialog_deprecated.html @@ -57,6 +57,8 @@
+
+
-- cgit v1.2.3 From 245a82d5aad6e2b721bfb24c9e118f2d92b8696a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 10 Dec 2012 15:31:56 -0500 Subject: Dialog tests: More async focus handling to deal with IE8. --- tests/unit/dialog/dialog_core.js | 83 ++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 29 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index f10087912..817f76ea9 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -39,7 +39,7 @@ test("widget method", function() { dialog.remove(); }); -test( "focus tabbable", function() { +asyncTest( "focus tabbable", function() { expect( 5 ); var el, options = { @@ -49,36 +49,59 @@ test( "focus tabbable", function() { }] }; - el = $( "
" ).dialog( options ); - equal( document.activeElement, el.find( "input" )[ 1 ], "1. first element inside the dialog matching [autofocus]" ); - el.remove(); + function checkFocus( markup, options, testFn, next ) { + el = $( markup ).dialog( options ); + setTimeout(function() { + testFn(); + el.remove(); + setTimeout( next ); + }); + } - // IE8 fails to focus the input, ends up being the activeElement - // so wait for that stupid browser - stop(); - setTimeout(function() { - el = $( "
" ).dialog( options ); - equal( document.activeElement, el.find( "input" )[ 0 ], "2. tabbable element inside the content element" ); - el.remove(); + function step1() { + checkFocus( "
", options, function() { + equal( document.activeElement, el.find( "input" )[ 1 ], + "1. first element inside the dialog matching [autofocus]" ); + }, step2 ); + } - el = $( "
text
" ).dialog( options ); - equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], "3. tabbable element inside the buttonpane" ); - el.remove(); + function step2() { + checkFocus( "
", options, function() { + equal( document.activeElement, el.find( "input" )[ 0 ], + "2. tabbable element inside the content element" ); + }, step3 ); + } - el = $( "
text
" ).dialog(); - equal( document.activeElement, el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], "4. the close button" ); - el.remove(); + function step3() { + checkFocus( "
text
", options, function() { + equal( document.activeElement, + el.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ], + "3. tabbable element inside the buttonpane" ); + }, step4 ); + } + + function step4() { + checkFocus( "
text
", {}, function() { + equal( document.activeElement, + el.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ], + "4. the close button" ); + }, step5 ); + } + function step5() { el = $( "
text
" ).dialog({ autoOpen: false }); el.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide(); el.dialog( "open" ); - equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); - el.remove(); + setTimeout(function() { + equal( document.activeElement, el.parent()[ 0 ], "5. the dialog itself" ); + el.remove(); + start(); + }); + } - start(); - }, 13); + step1(); }); test( "#7960: resizable handles below modal overlays", function() { @@ -93,10 +116,10 @@ test( "#7960: resizable handles below modal overlays", function() { dialog.dialog( "destroy" ); }); -asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { +asyncTest( "Prevent tabbing out of dialogs", function() { expect( 3 ); - var el = $( "
" ).dialog({ modal: true }), + var el = $( "
" ).dialog(), inputs = el.find( "input" ), widget = el.dialog( "widget" )[ 0 ]; @@ -105,21 +128,23 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { // check shift tab $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); - setTimeout( checkShiftTab, 2 ); + setTimeout( checkShiftTab ); } function checkShiftTab() { ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); el.remove(); - start(); + setTimeout( start ); } - inputs.eq( 1 ).focus(); - equal( document.activeElement, inputs[1], "Focus set on second input" ); - inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); + inputs[1].focus(); + setTimeout(function() { + equal( document.activeElement, inputs[1], "Focus set on second input" ); + inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); - setTimeout( checkTab, 2 ); + setTimeout( checkTab ); + }); }); })(jQuery); -- cgit v1.2.3 From b9f206dbcf7f8b9c190e86f0974ad2003911b668 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 11 Dec 2012 16:23:18 -0500 Subject: Dialog: Cleanup. --- tests/unit/dialog/dialog_common.js | 2 +- ui/jquery.ui.dialog.js | 190 ++++++++++++++++++------------------- 2 files changed, 92 insertions(+), 100 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js index 1a9b4e109..57d7aa0aa 100644 --- a/tests/unit/dialog/dialog_common.js +++ b/tests/unit/dialog/dialog_common.js @@ -2,7 +2,7 @@ TestHelpers.commonWidgetTests( "dialog", { defaults: { appendTo: "body", autoOpen: true, - buttons: {}, + buttons: [], closeOnEscape: true, closeText: 'close', disabled: false, diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 2553109ba..2c7c6b57a 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -19,8 +19,7 @@ */ (function( $, undefined ) { -var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ", - sizeRelatedOptions = { +var sizeRelatedOptions = { buttons: true, height: true, maxHeight: true, @@ -36,12 +35,12 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ui-fr minWidth: true }; -$.widget("ui.dialog", { +$.widget( "ui.dialog", { version: "@VERSION", options: { appendTo: "body", autoOpen: true, - buttons: {}, + buttons: [], closeOnEscape: true, closeText: "close", dialogClass: "", @@ -58,7 +57,7 @@ $.widget("ui.dialog", { at: "center", of: window, collision: "fit", - // ensure that the titlebar is never outside the document + // Ensure the titlebar is always visible using: function( pos ) { var topOffset = $( this ).css( pos ).offset().top; if ( topOffset < 0 ) { @@ -92,12 +91,12 @@ $.widget("ui.dialog", { maxHeight: this.element[0].style.maxHeight, height: this.element[0].style.height }; - this.originalTitle = this.element.attr( "title" ); - this.options.title = this.options.title || this.originalTitle; - this.oldPosition = { + this.originalPosition = { parent: this.element.parent(), index: this.element.parent().children().index( this.element ) }; + this.originalTitle = this.element.attr( "title" ); + this.options.title = this.options.title || this.originalTitle; this._createWrapper(); @@ -136,7 +135,7 @@ $.widget("ui.dialog", { _destroy: function() { var next, - oldPosition = this.oldPosition; + originalPosition = this.originalPosition; this._destroyOverlay(); @@ -144,7 +143,7 @@ $.widget("ui.dialog", { .removeUniqueId() .removeClass( "ui-dialog-content ui-widget-content" ) .css( this.originalCss ) - // without detaching first, the following becomes really slow + // Without detaching first, the following becomes really slow .detach(); this.uiDialog.stop( true, true ).remove(); @@ -153,12 +152,12 @@ $.widget("ui.dialog", { this.element.attr( "title", this.originalTitle ); } - next = oldPosition.parent.children().eq( oldPosition.index ); + next = originalPosition.parent.children().eq( originalPosition.index ); // Don't try to place the dialog next to itself (#8613) if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { next.before( this.element ); } else { - oldPosition.parent.append( this.element ); + originalPosition.parent.append( this.element ); } }, @@ -172,16 +171,11 @@ $.widget("ui.dialog", { close: function( event ) { var that = this; - if ( !this._isOpen ) { - return; - } - - if ( this._trigger( "beforeClose", event ) === false ) { + if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) { return; } this._isOpen = false; - this._destroyOverlay(); if ( !this.opener.filter( ":focusable" ).focus().length ) { @@ -206,7 +200,7 @@ $.widget("ui.dialog", { _moveToTop: function( event, silent ) { var moved = !!this.uiDialog.nextAll( ":visible" ).insertBefore( this.uiDialog ).length; - if ( !silent && moved ) { + if ( moved && !silent ) { this._trigger( "focus", event ); } return moved; @@ -233,29 +227,27 @@ $.widget("ui.dialog", { this._isOpen = true; this._trigger( "open" ); this._trigger( "focus" ); - - return this; }, _focusTabbable: function() { - // set focus to the first match: - // 1. first element inside the dialog matching [autofocus] - // 2. tabbable element inside the content element - // 3. tabbable element inside the buttonpane - // 4. the close button - // 5. the dialog itself + // Set focus to the first match: + // 1. First element inside the dialog matching [autofocus] + // 2. Tabbable element inside the content element + // 3. Tabbable element inside the buttonpane + // 4. The close button + // 5. The dialog itself var hasFocus = this.element.find( "[autofocus]" ); if ( !hasFocus.length ) { hasFocus = this.element.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); - if ( !hasFocus.length ) { - hasFocus = this.uiDialog; - } - } - } + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialogButtonPane.find( ":tabbable" ); + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" ); + } + if ( !hasFocus.length ) { + hasFocus = this.uiDialog; } hasFocus.eq( 0 ).focus(); }, @@ -279,10 +271,11 @@ $.widget("ui.dialog", { _createWrapper: function() { this.uiDialog = $( "
" ) - .addClass( uiDialogClasses + this.options.dialogClass ) + .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " + + this.options.dialogClass ) .hide() .attr({ - // setting tabIndex makes the div focusable + // Setting tabIndex makes the div focusable tabIndex: -1, role: "dialog" }) @@ -307,10 +300,10 @@ $.widget("ui.dialog", { if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) && !event.shiftKey ) { first.focus( 1 ); - return false; + event.preventDefault(); } else if ( ( event.target === first[ 0 ] || event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) { last.focus( 1 ); - return false; + event.preventDefault(); } }, mousedown: function( event ) { @@ -334,7 +327,7 @@ $.widget("ui.dialog", { var uiDialogTitle; this.uiDialogTitlebar = $( "
" ) - .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) + .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" ) .prependTo( this.uiDialog ); this._on( this.uiDialogTitlebar, { mousedown: function( event ) { @@ -359,7 +352,7 @@ $.widget("ui.dialog", { .addClass( "ui-dialog-titlebar-close" ) .appendTo( this.uiDialogTitlebar ); this._on( this.uiDialogTitlebarClose, { - "click": function( event ) { + click: function( event ) { event.preventDefault(); this.close( event ); } @@ -384,12 +377,12 @@ $.widget("ui.dialog", { }, _createButtonPane: function() { - var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "
" ) ) + this.uiDialogButtonPane = $( "
" ) .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ); this.uiButtonSet = $( "
" ) .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); + .appendTo( this.uiDialogButtonPane ); this._createButtons(); }, @@ -402,34 +395,35 @@ $.widget("ui.dialog", { this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); - if ( !$.isEmptyObject( buttons ) ) { - $.each( buttons, function( name, props ) { - var click, buttonOptions; - props = $.isFunction( props ) ? - { click: props, text: name } : - props; - // Default to a non-submitting button - props = $.extend( { type: "button" }, props ); - // Change the context for the click callback to be the main element - click = props.click; - props.click = function() { - click.apply( that.element[0], arguments ); - }; - buttonOptions = { - icons: props.icons, - text: props.showText - }; - delete props.icons; - delete props.showText; - $( "", props ) - .button( buttonOptions ) - .appendTo( that.uiButtonSet ); - }); - this.uiDialog.addClass( "ui-dialog-buttons" ); - this.uiDialogButtonPane.appendTo( this.uiDialog ); - } else { + if ( $.isEmptyObject( buttons ) ) { this.uiDialog.removeClass( "ui-dialog-buttons" ); + return; } + + $.each( buttons, function( name, props ) { + var click, buttonOptions; + props = $.isFunction( props ) ? + { click: props, text: name } : + props; + // Default to a non-submitting button + props = $.extend( { type: "button" }, props ); + // Change the context for the click callback to be the main element + click = props.click; + props.click = function() { + click.apply( that.element[0], arguments ); + }; + buttonOptions = { + icons: props.icons, + text: props.showText + }; + delete props.icons; + delete props.showText; + $( "", props ) + .button( buttonOptions ) + .appendTo( that.uiButtonSet ); + }); + this.uiDialog.addClass( "ui-dialog-buttons" ); + this.uiDialogButtonPane.appendTo( this.uiDialog ); }, _makeDraggable: function() { @@ -448,8 +442,7 @@ $.widget("ui.dialog", { handle: ".ui-dialog-titlebar", containment: "document", start: function( event, ui ) { - $( this ) - .addClass( "ui-dialog-dragging" ); + $( this ).addClass( "ui-dialog-dragging" ); that._trigger( "dragStart", event, filteredUi( ui ) ); }, drag: function( event, ui ) { @@ -460,8 +453,7 @@ $.widget("ui.dialog", { ui.position.left - that.document.scrollLeft(), ui.position.top - that.document.scrollTop() ]; - $( this ) - .removeClass( "ui-dialog-dragging" ); + $( this ).removeClass( "ui-dialog-dragging" ); that._trigger( "dragStop", event, filteredUi( ui ) ); } }); @@ -510,23 +502,19 @@ $.widget("ui.dialog", { that._trigger( "resizeStop", event, filteredUi( ui ) ); } }) - .css( "position", position ) - .find( ".ui-resizable-se" ) - .addClass( "ui-icon ui-icon-grip-diagonal-se" ); + .css( "position", position ); }, _minHeight: function() { var options = this.options; - if ( options.height === "auto" ) { - return options.minHeight; - } else { - return Math.min( options.minHeight, options.height ); - } + return options.height === "auto" ? + options.minHeight : + Math.min( options.minHeight, options.height ); }, _position: function() { - // need to show the dialog to get the actual offset in the position plugin + // Need to show the dialog to get the actual offset in the position plugin var isVisible = this.uiDialog.is( ":visible" ); if ( !isVisible ) { this.uiDialog.show(); @@ -539,8 +527,8 @@ $.widget("ui.dialog", { _setOptions: function( options ) { var that = this, - resizableOptions = {}, - resize = false; + resize = false, + resizableOptions = {}; $.each( options, function( key, value ) { that._setOption( key, value ); @@ -589,7 +577,7 @@ $.widget("ui.dialog", { if ( key === "closeText" ) { this.uiDialogTitlebarClose.button({ - // ensure that we always pass a string + // Ensure that we always pass a string label: "" + value }); } @@ -638,7 +626,7 @@ $.widget("ui.dialog", { var nonContentHeight, minContentHeight, maxContentHeight, options = this.options; - // reset content sizing + // Reset content sizing this.element.show().css({ width: "auto", minHeight: 0, @@ -681,18 +669,20 @@ $.widget("ui.dialog", { if ( !this.options.modal ) { return; } - if ( $.ui.dialog.overlayInstances === 0 ) { - // prevent use of anchors and inputs - // we use a setTimeout in case the overlay is created from an - // event that we're going to be cancelling (see #2804) + + if ( !$.ui.dialog.overlayInstances ) { + // Prevent use of anchors and inputs. + // We use a delay in case the overlay is created from an + // event that we're going to be cancelling. (#2804) this._delay(function() { - // handle $(el).dialog().dialog('close') (see #4065) + // Handle .dialog().dialog("close") (#4065) if ( $.ui.dialog.overlayInstances ) { this._on( this.document, { focusin: function( event ) { if ( !$( event.target ).closest( ".ui-dialog").length ) { event.preventDefault(); - $( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable(); + $( ".ui-dialog:visible:last .ui-dialog-content" ) + .data( "ui-dialog" )._focusTabbable(); } } }); @@ -700,20 +690,22 @@ $.widget("ui.dialog", { }); } - var $el = this.overlay = $( "
" ).addClass( "ui-widget-overlay ui-front" ); - $el.appendTo( this.document[ 0 ].body ); - this._on( $el, { + this.overlay = $( "
" ) + .addClass( "ui-widget-overlay ui-front" ) + .appendTo( this.document[ 0 ].body ); + this._on( this.overlay, { mousedown: "_keepFocus" }); - $.ui.dialog.overlayInstances += 1; + $.ui.dialog.overlayInstances++; }, _destroyOverlay: function() { if ( !this.options.modal ) { return; } - $.ui.dialog.overlayInstances -= 1; - if ( $.ui.dialog.overlayInstances === 0 ) { + + $.ui.dialog.overlayInstances--; + if ( !$.ui.dialog.overlayInstances ) { this._off( this.document, "focusin" ); } this.overlay.remove(); -- cgit v1.2.3 From fec36fd2140a1e88b0a6584f4e9d42a0495d395a Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Wed, 12 Dec 2012 03:16:33 -0500 Subject: Dev: remove todos from datepicker and dialog testsuite --- tests/unit/datepicker/datepicker_options.js | 5 ++--- tests/unit/dialog/dialog_methods.js | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'tests/unit/dialog') diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 7b0907d3a..c5e53b85e 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -594,10 +594,9 @@ test('altField', function() { }); test('autoSize', function() { - expect( 14 ); + expect( 15 ); var inp = TestHelpers.datepicker.init('#inp'); - // todo: figure out why this test fails in Opera 11.6 - //equal(inp.prop('size'), 20, 'Auto size - default'); + equal(inp.prop('size'), 20, 'Auto size - default'); inp.datepicker('option', 'autoSize', true); equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy'); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index fbb649fbf..85d13d157 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -59,6 +59,16 @@ test("destroy", function() { }); }); +test("#4980: Destroy should place element back in original DOM position", function(){ + expect( 2 ); + var container = $('
'), + modal = container.find('#modal'); + modal.dialog(); + ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); + modal.dialog('destroy'); + ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); +}); + test( "enable/disable disabled", function() { expect( 2 ); var el = $( "
" ).dialog(); @@ -137,17 +147,6 @@ test("open", function() { ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called'); }); -// TODO merge this with the main destroy test -test("#4980: Destroy should place element back in original DOM position", function(){ - expect( 2 ); - var container = $('
'), - modal = container.find('#modal'); - modal.dialog(); - ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); - modal.dialog('destroy'); - ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position'); -}); - test("#6137: dialog('open') causes form elements to reset on IE7", function() { expect(2); -- cgit v1.2.3