From ff11b69a67e0176c851ff3bdec997c7a75d47a42 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 21 Mar 2013 15:54:50 -0400 Subject: Autocomplete: Insert the live region before the input. Fixes #9172 - Autocomplete: .replaceWith() fails to replace. --- tests/unit/autocomplete/autocomplete_core.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index a9fc1143c..6f1195910 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -188,4 +188,14 @@ test( "ARIA", function() { "Live region for multiple values" ); }); +test( ".replaceWith() (#9172)", function() { + expect( 1 ); + + var element = $( "#autocomplete" ).autocomplete(), + replacement = "
test
", + parent = element.parent(); + element.replaceWith( replacement ); + equal( parent.html(), replacement ); +}); + }( jQuery ) ); -- cgit v1.2.3 From f306a826a4d3b4c36c3f86cb5feeee23bb0db4c3 Mon Sep 17 00:00:00 2001 From: Jason Moon Date: Thu, 21 Mar 2013 09:56:39 -0500 Subject: Sortable: update placeholder when axis is x or y for connected lists. Fixed #8301 - Placeholder doesn't move when using connectWith option --- tests/unit/sortable/sortable_options.js | 28 ++++++++++++++++++++++++++++ ui/jquery.ui.sortable.js | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index 8dcf0e82f..a499c01c1 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -151,6 +151,34 @@ test( "#8792: issues with floated items in connected lists", function() { equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" ); }); +test( "#8301: single axis with connected list", function() { + expect( 1 ); + + var element = $( "#sortable" ).sortable({ + axis: "y", + tolerance: "pointer", + connectWith: ".connected" + }); + + $( "" ) + .sortable({ + axis: "y", + tolerance: "pointer", + connectWith: "#sortable", + receive: function() { + ok( true, "connected list received item" ); + } + }) + .insertAfter( element ); + + element.find( "li" ).eq( 0 ).simulate( "drag", { + handle: "corner", + dx: -1, + dy: 114, + moves: 1 + }); +}); + /* test("{ connectWith: false }, default", function() { ok(false, "missing test - untested code is broken code."); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 642d5d947..d16407216 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -535,7 +535,9 @@ $.widget("ui.sortable", $.ui.mouse, { b = t + item.height, dyClick = this.offset.click.top, dxClick = this.offset.click.left, - isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; + isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ), + isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ), + isOverElement = isOverElementHeight && isOverElementWidth; if ( this.options.tolerance === "pointer" || this.options.forcePointerForContainers || -- cgit v1.2.3 From dc5254aa0703f9f7fd9d290c3078a5e9267160d9 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 23 Mar 2013 04:12:52 +0200 Subject: Draggable: Handle containment set to false after init, and style improvements. Fixes #8962 - Containment doesn't properly update --- tests/unit/draggable/draggable_options.js | 7 +-- ui/jquery.ui.draggable.js | 93 ++++++++++++++++++------------- 2 files changed, 58 insertions(+), 42 deletions(-) (limited to 'tests') diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index f4fca0b2e..bf47b4354 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -378,7 +378,7 @@ test( "containment, account for border", function() { }); test( "containment, default, switching after initialization", function() { - expect( 2 ); + expect( 3 ); var element = $( "#draggable1" ).draggable({ containment: false }); @@ -393,9 +393,8 @@ test( "containment, default, switching after initialization", function() { TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0 ); - // TODO: Switching back to false does not update to false - // element.draggable( "option", "containment", false ); - // TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); + element.draggable( "option", "containment", false ); + TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100 ); }); test( "{ cursor: 'auto' }, default", function() { diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index e5fc069b9..0c58aa4b8 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -156,9 +156,7 @@ $.widget("ui.draggable", $.ui.mouse, { (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); //Set a containment if given in the options - if(o.containment) { - this._setContainment(); - } + this._setContainment(); //Trigger event + callbacks if(this._trigger("start", event) === false) { @@ -383,40 +381,56 @@ $.widget("ui.draggable", $.ui.mouse, { var over, c, ce, o = this.options; - if(o.containment === "parent") { - o.containment = this.helper[0].parentNode; + if ( !o.containment ) { + this.containment = null; + return; } - if(o.containment === "document" || o.containment === "window") { + + if ( o.containment === "window" ) { this.containment = [ - o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left, - o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top, - (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left, - (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top + $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left, + $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top, + $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left, + $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top ]; + return; } - if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) { - c = $(o.containment); - ce = c[0]; - - if(!ce) { - return; - } - - over = ($(ce).css("overflow") !== "hidden"); - + if ( o.containment === "document") { this.containment = [ - (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), - (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), - (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, - (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom + 0, + 0, + $( document ).width() - this.helperProportions.width - this.margins.left, + ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top ]; - this.relative_container = c; + return; + } - } else if(o.containment.constructor === Array) { + if ( o.containment.constructor === Array ) { this.containment = o.containment; + return; + } + + if ( o.containment === "parent" ) { + o.containment = this.helper[ 0 ].parentNode; } + c = $( o.containment ); + ce = c[ 0 ]; + + if( !ce ) { + return; + } + + over = c.css( "overflow" ) !== "hidden"; + + this.containment = [ + ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ), + ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) , + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right, + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom + ]; + this.relative_container = c; }, _convertPositionTo: function(d, pos) { @@ -469,18 +483,21 @@ $.widget("ui.draggable", $.ui.mouse, { * Constrain the position to a mix of grid, containment. */ - if(this.originalPosition) { //If we are not dragging yet, we won't check for options - if(this.containment) { - if (this.relative_container){ - co = this.relative_container.offset(); - containment = [ this.containment[0] + co.left, - this.containment[1] + co.top, - this.containment[2] + co.left, - this.containment[3] + co.top ]; - } - else { - containment = this.containment; - } + // If we are not dragging yet, we won't check for options + if ( this.originalPosition ) { + if ( this.containment ) { + if ( this.relative_container ){ + co = this.relative_container.offset(); + containment = [ + this.containment[ 0 ] + co.left, + this.containment[ 1 ] + co.top, + this.containment[ 2 ] + co.left, + this.containment[ 3 ] + co.top + ]; + } + else { + containment = this.containment; + } if(event.pageX - this.offset.click.left < containment[0]) { pageX = containment[0] + this.offset.click.left; -- cgit v1.2.3 From e9faec96ed0152a4943efa838b9025d63e3e3093 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 26 Mar 2013 09:18:00 -0400 Subject: Draggable Tests: Test that removing an element on drop doesn't cause a draggable error. Fixes #9159 - Draggable Tests: Write test case for #8269 --- tests/unit/draggable/draggable_core.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 2090f2fd9..ab63c3703 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -85,4 +85,24 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() { equal( target.width(), 200, "compare width" ); }); +test( "#8269: Removing draggable element on drop", function() { + expect( 1 ); + + var element = $( "#draggable1" ).wrap( "
" ).draggable(), + dropOffset = $( "#droppable" ).offset(); + + $( "#droppable" ).droppable({ + drop: function() { + $( "#wrapper" ).remove(); + ok( true, "element removed from DOM on drop" ); + } + }); + + element.simulate( "drag", { + handle: "corner", + x: dropOffset.left, + y: dropOffset.top + }); +}); + })( jQuery ); -- cgit v1.2.3 From 38f93c4ac19d85649e08f666086c1234ff7360f3 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 26 Mar 2013 09:18:58 -0400 Subject: Draggable Tests: Minor style fixes and removing unnecessary setup and teardown for core tests. --- tests/unit/draggable/draggable_core.js | 21 +++++---------------- tests/unit/draggable/draggable_options.js | 4 ++-- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index ab63c3703..f22d483a6 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -4,18 +4,7 @@ (function( $ ) { -var relativeElement, absoluteElement; - -module( "draggable: core", { - setup: function() { - relativeElement = $("
Relative
").appendTo("#qunit-fixture"); - absoluteElement = $("
Absolute
").appendTo("#qunit-fixture"); - }, - teardown: function() { - relativeElement.remove(); - absoluteElement.remove(); - } -}); +module( "draggable: core" ); test( "element types", function() { var typeNames = ( @@ -55,18 +44,18 @@ test( "element types", function() { test( "No options, relative", function() { expect( 1 ); - TestHelpers.draggable.shouldMove( relativeElement.draggable() ); + TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable() ); }); test( "No options, absolute", function() { expect( 1 ); - TestHelpers.draggable.shouldMove( absoluteElement.draggable() ); + TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable() ); }); test( "resizable handle with complex markup (#8756 / #8757)", function() { expect( 2 ); - relativeElement + $( "#draggable1" ) .append( $("
") .addClass("ui-resizable-handle ui-resizable-w") @@ -74,7 +63,7 @@ test( "resizable handle with complex markup (#8756 / #8757)", function() { ); var handle = $(".ui-resizable-w div"), - target = relativeElement.draggable().resizable({ handles: "all" }); + target = $( "#draggable1" ).draggable().resizable({ handles: "all" }); // todo: fix resizable so it doesn't require a mouseover handle.simulate("mouseover").simulate( "drag", { dx: -50 } ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index bf47b4354..8e1fde0bd 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1056,11 +1056,11 @@ test( "scope", function() { $( "#droppable" ).droppable({ scope: "tasks" }); - TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 0, 0, "revert: valid reverts when dropped on a droppable in scope" ); $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); - TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable" ); + TestHelpers.draggable.testDrag( element, element, 100, 100, 100, 100, "revert: valid reverts when dropped on a droppable out of scope" ); }); test( "scroll, scrollSensitivity, and scrollSpeed", function() { -- cgit v1.2.3 From a4fabd2bb4016dace930bdbb87fd82b09950b4c8 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 26 Mar 2013 14:43:35 -0400 Subject: Whitespace. --- tests/unit/button/button_methods.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js index c53444005..467938f00 100644 --- a/tests/unit/button/button_methods.js +++ b/tests/unit/button/button_methods.js @@ -15,7 +15,7 @@ test("destroy", function() { test( "refresh: Ensure disabled state is preserved correctly.", function() { expect( 8 ); - + var element = $( "" ); element.button({ disabled: true }).button( "refresh" ); ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" ); //See #8237 -- cgit v1.2.3 From a9e1755cb96c54ed3ead77f3eb375544fbf2b4b3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 26 Mar 2013 14:44:32 -0400 Subject: Build: Use globals instead of predef for JSHint. --- tests/.jshintrc | 42 +++++++++++++++++++++--------------------- ui/.jshintrc | 6 +++--- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/tests/.jshintrc b/tests/.jshintrc index c196d86ef..b987c5df6 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -13,25 +13,25 @@ "trailing": true, "undef": true, "unused": true, - "predef": [ - "asyncTest", - "closeEnough", - "deepEqual", - "domEqual", - "equal", - "expect", - "Globalize", - "module", - "notEqual", - "notDeepEqual", - "notStrictEqual", - "ok", - "QUnit", - "start", - "strictEqual", - "stop", - "test", - "TestHelpers", - "JSHINT" - ] + "globals": { + "asyncTest": false, + "closeEnough": false, + "deepEqual": false, + "domEqual": false, + "equal": false, + "expect": false, + "Globalize": false, + "module": false, + "notEqual": false, + "notDeepEqual": false, + "notStrictEqual": false, + "ok": false, + "QUnit": true, + "start": false, + "strictEqual": false, + "stop": false, + "test": false, + "TestHelpers": true, + "JSHINT": false + } } \ No newline at end of file diff --git a/ui/.jshintrc b/ui/.jshintrc index c7589525f..578ee94a1 100644 --- a/ui/.jshintrc +++ b/ui/.jshintrc @@ -12,7 +12,7 @@ "trailing": true, "undef": true, "unused": true, - "predef": [ - "Globalize" - ] + "globals": { + "Globalize": false + } } -- cgit v1.2.3 From 2c43548ac629467596ee64d0c614a0cef3169852 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 27 Mar 2013 09:40:53 -0400 Subject: Tests: Handle globals in .jshintrc. --- tests/unit/testsuite.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index d2403beeb..ddc59ed08 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -77,16 +77,22 @@ TestHelpers.testJshint = function( module ) { dataType: "text" }) ).done(function( hintArgs, srcArgs ) { - var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ), - errors = $.map( JSHINT.errors, function( error ) { - // JSHINT may report null if there are too many errors - if ( !error ) { - return; - } - - return "[L" + error.line + ":C" + error.character + "] " + - error.reason + "\n" + error.evidence + "\n"; - }).join( "\n" ); + var globals, passed, errors, + jshintrc = hintArgs[ 0 ], + source = srcArgs[ 0 ]; + + globals = jshintrc.globals || {}; + delete jshintrc.globals; + passed = JSHINT( source, jshintrc, globals ), + errors = $.map( JSHINT.errors, function( error ) { + // JSHINT may report null if there are too many errors + if ( !error ) { + return; + } + + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + }).join( "\n" ); ok( passed, errors ); start(); }) -- cgit v1.2.3 From 5a8596cdf3baa4d835e588cda9060a0537236c71 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 27 Mar 2013 15:23:59 -0400 Subject: Accordion: Maintain collapsed state on refresh. Fixes #9189 - Accordion: refresh() method incorrectly opens collapsed accordion. --- tests/unit/accordion/accordion_methods.js | 11 ++++++++++- ui/jquery.ui.accordion.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 7612479f7..1e809b310 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -35,7 +35,7 @@ test( "enable/disable", function() { }); test( "refresh", function() { - expect( 17 ); + expect( 19 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -109,6 +109,15 @@ test( "refresh", function() { element.find( "div.foo" ).eq( 0 ).remove(); element.accordion( "refresh" ); state( element, 1 ); + + // collapse all panels + element.accordion( "option", { + collapsible: true, + active: false + }); + state( element, 0 ); + element.accordion( "refresh" ); + state( element, 0 ); }); test( "widget", function() { diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index c210a29a9..fc2b6bc57 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -223,7 +223,7 @@ $.widget( "ui.accordion", { options.active = false; this.active = $(); // active false only when collapsible is true - } if ( options.active === false ) { + } else if ( options.active === false ) { this._activate( 0 ); // was active, but active panel is gone } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { -- cgit v1.2.3 From 875139ef8fe97d049fc1231e8465b6dc7699e5dd Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 11:49:54 -0400 Subject: Selectable Tests: Fix test failures in IE7 by accounting simulated events properly. --- tests/unit/selectable/selectable_events.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js index f933d3890..ae35fa3ce 100644 --- a/tests/unit/selectable/selectable_events.js +++ b/tests/unit/selectable/selectable_events.js @@ -38,27 +38,30 @@ test( "stop", function() { test( "mousedown: initial position of helper", function() { expect( 2 ); - var contentToForceScroll, helper, - element = $("#selectable1").selectable(); + var helperOffset, + element = $( "#selectable1" ).selectable(), + contentToForceScroll = $( "
" ).css({ + height: "10000px", + width: "10000px" + }); - contentToForceScroll = $("
").css({ - height: "10000px", - width: "10000px" - }); + contentToForceScroll.appendTo( "body" ); + $( window ).scrollTop( 100 ).scrollLeft( 100 ); - contentToForceScroll.appendTo("body"); - $( window ).scrollTop( 1 ).scrollLeft( 1 ); element.simulate( "mousedown", { clientX: 10, clientY: 10 }); - helper = $(".ui-selectable-helper"); - equal( helper.css("top"), "11px", "Scroll top should be accounted for." ); - equal( helper.css("left"), "11px", "Scroll left should be accounted for." ); + // we do a GTE comparison here because IE7 erroneously subtracts + // 2 pixels from a simulated mousedown for clientX/Y + // Support: IE7 + helperOffset = $( ".ui-selectable-helper" ).offset(); + ok( helperOffset.top >= 99, "Scroll top should be accounted for." ); + ok( helperOffset.left >= 99, "Scroll left should be accounted for." ); // Cleanup - element.simulate("mouseup"); + element.simulate( "mouseup" ); contentToForceScroll.remove(); $( window ).scrollTop( 0 ).scrollLeft( 0 ); }); -- cgit v1.2.3 From 384f1812542127e10ea55ba56412a19e5f2b7dda Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 11:55:24 -0400 Subject: Sortable Tests: Fix IE7 test failures due to incorrectly expecting relative urls in img srcs. --- tests/unit/sortable/sortable_options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index a499c01c1..9a072332d 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -330,7 +330,7 @@ test( "{ placeholder: false } img", function() { var element = $( "#sortable-images" ).sortable({ start: function( event, ui ) { - equal( ui.placeholder.attr( "src" ), "../images/jqueryui_32x32.png", "placeholder img has correct src" ); + ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" ); equal( ui.placeholder.height(), 32, "placeholder has correct height" ); equal( ui.placeholder.width(), 32, "placeholder has correct width" ); } -- cgit v1.2.3 From bbb53df27d357376c7941251b027cdb7f1f453d5 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 12:06:28 -0400 Subject: Sortable Tests: Fix IE7 Test fails by being more generous with dragging near borders. --- tests/unit/sortable/sortable_options.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index 9a072332d..f0185b078 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -136,15 +136,18 @@ test( "#8792: issues with floated items in connected lists", function() { element = $( "#qunit-fixture li:eq(0)" ); + // move the first li to the right of the second li in the first ul element.simulate( "drag", { - dx: 51, + dx: 55, moves: 15 }); equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); + // move the first li ( which is now in the second spot ) + // through the first spot in the second ul to the second spot in the second ul element.simulate( "drag", { - dx: 50, + dx: 100, moves: 15 }); @@ -173,8 +176,7 @@ test( "#8301: single axis with connected list", function() { element.find( "li" ).eq( 0 ).simulate( "drag", { handle: "corner", - dx: -1, - dy: 114, + dy: 120, moves: 1 }); }); -- cgit v1.2.3 From 204a0423be63e0032f72b2ba1830a9b8dcebb9ee Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 12:19:43 -0400 Subject: Draggable Tests: Fix IE8 test failures by accounting for the IE8 testswarm IFRAME positioning bug. --- tests/unit/draggable/draggable_options.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 8e1fde0bd..6a0cd593b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1112,7 +1112,8 @@ test( "#6817: auto scroll goes double distance when dragging", function() { scroll: true, stop: function( e, ui ) { equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" ); - equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" ); } }), scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), @@ -1137,7 +1138,7 @@ test( "#6817: auto scroll goes double distance when dragging", function() { }); test( "snap, snapMode, and snapTolerance", function() { - expect( 9 ); + expect( 10 ); var newX, newY, snapTolerance = 15, @@ -1163,7 +1164,9 @@ test( "snap, snapMode, and snapTolerance", function() { moves: 1 }); - deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap outside the snapTolerance" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" ); + closeEnough( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" ); newX += 3; @@ -1257,7 +1260,7 @@ test( "snap, snapMode, and snapTolerance", function() { }); test( "#8459: element can snap to an element that was removed during drag", function() { - expect( 1 ); + expect( 2 ); var newX, newY, snapTolerance = 15, @@ -1286,7 +1289,9 @@ test( "#8459: element can snap to an element that was removed during drag", func moves: 1 }); - deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal + closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" ); + closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" ); }); test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { -- cgit v1.2.3 From e12879a441b972fea01697580c05c4ce698578e6 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 12:28:40 -0400 Subject: Position Tests: Fix FF and IE10 test failures by accounting for subpixel offsets. --- tests/unit/position/position_core.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index cefd7929c..e03d4c111 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -221,7 +221,9 @@ test( "of", function() { }); test( "offsets", function() { - expect( 7 ); + expect( 9 ); + + var offset; $( "#elx" ).position({ my: "left top", @@ -261,7 +263,9 @@ test( "offsets", function() { of: "#parentx", collision: "none" }); - deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "decimal percentage offsets in my" ); + offset = $( "#elx" ).offset(); + equal( Math.round( offset.top ), 65, "decimal percentage offsets in my" ); + equal( Math.round( offset.left ), 37, "decimal percentage offsets in my" ); $( "#elx" ).position({ my: "left+10.4 top-10.6", @@ -269,7 +273,9 @@ test( "offsets", function() { of: "#parentx", collision: "none" }); - deepEqual( $( "#elx" ).offset(), { top: 49, left: 50 }, "decimal offsets in my" ); + offset = $( "#elx" ).offset(); + equal( Math.round( offset.top ), 49, "decimal offsets in my" ); + equal( Math.round( offset.left ), 50, "decimal offsets in my" ); $( "#elx" ).position({ my: "left+right top-left", -- cgit v1.2.3 From 70717273a8aaddda27918e3497ab72ae20357867 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 12:32:33 -0400 Subject: Autocomplete Tests: Fix oldIE test failures by accounting for casing differences in .html() return values. --- tests/unit/autocomplete/autocomplete_core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index 6f1195910..2961cb09a 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -195,7 +195,7 @@ test( ".replaceWith() (#9172)", function() { replacement = "
test
", parent = element.parent(); element.replaceWith( replacement ); - equal( parent.html(), replacement ); + equal( parent.html().toLowerCase(), replacement ); }); }( jQuery ) ); -- cgit v1.2.3 From efe8da8e6e9b50547fe9a632b267c7f8479b6686 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 31 Mar 2013 12:55:57 -0400 Subject: Spinner Tests: Fix IE test failures by accounting for the async nature of focus/blur. --- tests/unit/spinner/spinner_core.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index bea5f9122..f9bd7c2e4 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -94,6 +94,9 @@ asyncTest( "blur input while spinning with UP", function() { function step2() { value = element.val(); ok( value > 11, "repeating while key is down" ); + setTimeout( function() { + value = element.val(); + }); element[0].blur(); setTimeout( step3, 250 ); } -- cgit v1.2.3 From 5217b975f32aeca0bf12ca76f24084f319b46ebe Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 1 Apr 2013 08:59:52 -0400 Subject: Spinner Tests: Fix IE test failures by removing timing dependencies from focus/blur tests. --- tests/unit/spinner/spinner_core.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index f9bd7c2e4..03088fecd 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -94,11 +94,11 @@ asyncTest( "blur input while spinning with UP", function() { function step2() { value = element.val(); ok( value > 11, "repeating while key is down" ); - setTimeout( function() { + + element.bind( "blur", function() { value = element.val(); - }); - element[0].blur(); - setTimeout( step3, 250 ); + setTimeout( step3, 750 ); + })[ 0 ].blur(); } function step3() { -- cgit v1.2.3 From 09b3533910e887377fc87126608db1ded06f38f6 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 2 Apr 2013 10:42:21 -0400 Subject: Sortable: Copy the cell structure when sorting a table row. Fixes #9185 - Sortable: Placeholder breaks table-layout: fixed. --- tests/unit/sortable/sortable.html | 3 +++ tests/unit/sortable/sortable_options.js | 38 ++++++++++++++++++++++----------- ui/jquery.ui.sortable.js | 11 +++++----- 3 files changed, 34 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index 7db14d482..8e0bac501 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -44,6 +44,9 @@ border-width: 0; height:19px; } + #sortable-table { + width: 100%; + } diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index f0185b078..f2beb4dbc 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -359,19 +359,31 @@ test( "{ placeholder: String }", function() { }); test( "{ placholder: String } tr", function() { - expect( 3 ); - - var element = $( "#sortable-table tbody" ).sortable({ - placeholder: "test", - start: function( event, ui ) { - ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); - equal( ui.placeholder.children().length, 1, "placeholder tr contains a td" ); - equal( ui.placeholder.children().html(), $( " " ).html(), - "placeholder td has content for forced dimensions" ); - } - }); - - element.find( "tr" ).eq( 0 ).simulate( "drag", { + expect( 4 ); + + var originalWidths, + element = $( "#sortable-table tbody" ).sortable({ + placeholder: "test", + start: function( event, ui ) { + var currentWidths = otherRow.children().map(function() { + return $( this ).width(); + }).get(); + ok( ui.placeholder.hasClass( "test" ), "placeholder has class" ); + deepEqual( currentWidths, originalWidths, "table cells maintian size" ); + equal( ui.placeholder.children().length, dragRow.children().length, + "placeholder has correct number of cells" ); + equal( ui.placeholder.children().html(), $( " " ).html(), + "placeholder td has content for forced dimensions" ); + } + }), + rows = element.children( "tr" ), + dragRow = rows.eq( 0 ), + otherRow = rows.eq( 1 ); + + originalWidths = otherRow.children().map(function() { + return $( this ).width(); + }).get(); + dragRow.simulate( "drag", { dy: 1 }); }); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index d16407216..7b145159e 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -752,15 +752,16 @@ $.widget("ui.sortable", $.ui.mouse, { element: function() { var nodeName = that.currentItem[0].nodeName.toLowerCase(), - element = $( that.document[0].createElement( nodeName ) ) + element = $( "<" + nodeName + ">", that.document[0] ) .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") .removeClass("ui-sortable-helper"); if ( nodeName === "tr" ) { - // Use a high colspan to force the td to expand the full - // width of the table (browsers are smart enough to - // handle this properly) - element.append( " " ); + that.currentItem.children().each(function() { + $( " ", that.document[0] ) + .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) + .appendTo( element ); + }); } else if ( nodeName === "img" ) { element.attr( "src", that.currentItem.attr( "src" ) ); } -- cgit v1.2.3