From a88d64514001867b908776e6bfcfac7f1011970d Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 2 Apr 2013 09:08:17 -0400 Subject: Draggable: Stop erroneously overriding scroll offsets for root nodes. Fixes #6258 - Draggable: not following mouse when scrolled and using overflow-y: scroll. --- tests/unit/draggable/draggable_core.js | 35 ++++++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 13 ++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index f22d483a6..0d693e4ff 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -94,4 +94,39 @@ test( "#8269: Removing draggable element on drop", function() { }); }); +test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() { + expect( 2 ); + + var element = $( "#draggable1" ).draggable({ + stop: function( event, ui ) { + equal( ui.position.left, 1, "left position is correct despite overflow on HTML" ); + equal( ui.position.top, 1, "top position is correct despite overflow on HTML" ); + $( "html" ) + .css( "overflow-y", oldOverflowY ) + .css( "overflow-x", oldOverflowX ) + .scrollTop( 0 ) + .scrollLeft( 0 ); + } + }), + contentToForceScroll = $( "
" ).css({ + height: "10000px", + width: "10000px" + }), + oldOverflowY = $( "html" ).css( "overflow-y" ), + oldOverflowX = $( "html" ).css( "overflow-x" ); + + contentToForceScroll.appendTo( "#qunit-fixture" ); + $( "html" ) + .css( "overflow-y", "scroll" ) + .css( "overflow-x", "scroll" ) + .scrollTop( 300 ) + .scrollLeft( 300 ); + + element.simulate( "drag", { + dx: 1, + dy: 1, + moves: 1 + }); +}); + })( jQuery ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 0c58aa4b8..4814cb851 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -440,7 +440,7 @@ $.widget("ui.draggable", $.ui.mouse, { } var mod = d === "absolute" ? 1 : -1, - scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); + scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent; //Cache the scroll if (!this.offset.scroll) { @@ -452,13 +452,13 @@ $.widget("ui.draggable", $.ui.mouse, { pos.top + // The absolute mouse position this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod ) ), left: ( pos.left + // The absolute mouse position this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod ) ) }; @@ -468,8 +468,7 @@ $.widget("ui.draggable", $.ui.mouse, { var containment, co, top, left, o = this.options, - scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, - scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName), + scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent, pageX = event.pageX, pageY = event.pageY; @@ -530,14 +529,14 @@ $.widget("ui.draggable", $.ui.mouse, { this.offset.click.top - // Click offset (relative to the element) this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )) + ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) ), left: ( pageX - // The absolute mouse position this.offset.click.left - // Click offset (relative to the element) this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left )) + ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) ) }; -- cgit v1.2.3 From 49c7b7200ef944ffc93487e79e763dfe97b4ff4a Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Wed, 3 Apr 2013 12:26:39 -0400 Subject: Draggable: Don't cache parent offset if the parent position is fixed. Fixes #5009 - Draggable: scroll not working with parent's position fixed --- tests/unit/draggable/draggable_core.js | 30 ++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 9 +++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 0d693e4ff..9ef18c4b2 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -129,4 +129,34 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f }); }); +test( "#5009: scroll not working with parent's position fixed", function() { + expect( 2 ); + + var startValue = 300, + element = $( "#draggable1" ).wrap( "
" ).draggable({ + drag: function() { + startValue += 100; + $( document ).scrollTop( startValue ).scrollLeft( startValue ); + }, + stop: function( event, ui ) { + equal( ui.position.left, 10, "left position is correct despite overflow on HTML" ); + equal( ui.position.top, 10, "top position is correct despite overflow on HTML" ); + $( document ).scrollTop( 0 ).scrollLeft( 0 ); + } + }), + contentToForceScroll = $( "
" ).css({ + height: "20000px", + width: "20000px" + }); + + $( "#qunit-fixture" ).append( contentToForceScroll ); + $( "#wrapper" ).css( "position", "fixed" ); + + element.simulate( "drag", { + dx: 10, + dy: 10, + moves: 3 + }); +}); + })( jQuery ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 4814cb851..64cf339e0 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -125,8 +125,10 @@ $.widget("ui.draggable", $.ui.mouse, { this._cacheMargins(); //Store the helper's css position - this.cssPosition = this.helper.css("position"); + this.cssPosition = this.helper.css( "position" ); this.scrollParent = this.helper.scrollParent(); + this.offsetParent = this.helper.offsetParent(); + this.offsetParentCssPosition = this.offsetParent.css( "position" ); //The element's absolute position on the page minus margins this.offset = this.positionAbs = this.element.offset(); @@ -184,6 +186,10 @@ $.widget("ui.draggable", $.ui.mouse, { }, _mouseDrag: function(event, noPropagation) { + // reset any necessary cached properties (see #5009) + if ( this.offsetParentCssPosition === "fixed" ) { + this.offset.parent = this._getParentOffset(); + } //Compute the helpers position this.position = this._generatePosition(event); @@ -320,7 +326,6 @@ $.widget("ui.draggable", $.ui.mouse, { _getParentOffset: function() { //Get the offsetParent and cache its position - this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); // This is a special case where we need to modify a offset calculated on start, since the following happened: -- cgit v1.2.3 From 504b100a1a9213186968c654dd915b92bb9ee15b Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 3 Apr 2013 16:06:15 -0400 Subject: Datepicker: Fixed date format for Serbian locales. Fixes #7347 - Datepicker: Wrong date format for Serbian localization. --- ui/i18n/jquery.ui.datepicker-sr-SR.js | 2 +- ui/i18n/jquery.ui.datepicker-sr.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-sr-SR.js b/ui/i18n/jquery.ui.datepicker-sr-SR.js index 6d5d04211..810d21daa 100644 --- a/ui/i18n/jquery.ui.datepicker-sr-SR.js +++ b/ui/i18n/jquery.ui.datepicker-sr-SR.js @@ -14,7 +14,7 @@ jQuery(function($){ dayNamesShort: ['Ned','Pon','Uto','Sre','Čet','Pet','Sub'], dayNamesMin: ['Ne','Po','Ut','Sr','Če','Pe','Su'], weekHeader: 'Sed', - dateFormat: 'dd/mm/yy', + dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, diff --git a/ui/i18n/jquery.ui.datepicker-sr.js b/ui/i18n/jquery.ui.datepicker-sr.js index d4e1d9af0..1349a26cf 100644 --- a/ui/i18n/jquery.ui.datepicker-sr.js +++ b/ui/i18n/jquery.ui.datepicker-sr.js @@ -14,7 +14,7 @@ jQuery(function($){ dayNamesShort: ['Нед','Пон','Уто','Сре','Чет','Пет','Суб'], dayNamesMin: ['Не','По','Ут','Ср','Че','Пе','Су'], weekHeader: 'Сед', - dateFormat: 'dd/mm/yy', + dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, -- cgit v1.2.3 From cb42ba6fd6307a8425a1af89329869fcc613cefe Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 3 Apr 2013 16:12:50 -0400 Subject: Datepicker: Remove unnecessary global variable now that we don't use inline event handlers anymore. --- ui/jquery.ui.datepicker.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 5892e2ddc..990c181a6 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -16,7 +16,6 @@ $.extend($.ui, { datepicker: { version: "@VERSION" } }); var PROP_NAME = "datepicker", - dpuuid = new Date().getTime(), instActive; function getZindex( elem ) { @@ -1580,27 +1579,27 @@ $.extend(Datepicker.prototype, { inst.dpDiv.find("[data-handler]").map(function () { var handler = { prev: function () { - window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M"); + $.datepicker._adjustDate(id, -stepMonths, "M"); }, next: function () { - window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M"); + $.datepicker._adjustDate(id, +stepMonths, "M"); }, hide: function () { - window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker(); + $.datepicker._hideDatepicker(); }, today: function () { - window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id); + $.datepicker._gotoToday(id); }, selectDay: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); + $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this); return false; }, selectMonth: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M"); + $.datepicker._selectMonthYear(id, this, "M"); return false; }, selectYear: function () { - window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y"); + $.datepicker._selectMonthYear(id, this, "Y"); return false; } }; @@ -2065,8 +2064,4 @@ $.datepicker.initialized = false; $.datepicker.uuid = new Date().getTime(); $.datepicker.version = "@VERSION"; -// Workaround for #4055 -// Add another global to avoid noConflict issues with inline event handlers -window["DP_jQuery_" + dpuuid] = $; - })(jQuery); -- cgit v1.2.3 From e11cfce8013ebb32853ffb6972ea36e785fb8016 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 3 Apr 2013 16:19:39 -0400 Subject: Datepicker: Remove unused _getBorders() method. --- ui/jquery.ui.datepicker.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 990c181a6..976534c94 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -823,18 +823,6 @@ $.extend(Datepicker.prototype, { } }, - /* Retrieve the size of left and top borders for an element. - * @param elem (jQuery object) the element of interest - * @return (number[2]) the left and top borders - */ - _getBorders: function(elem) { - var convert = function(value) { - return {thin: 1, medium: 2, thick: 3}[value] || value; - }; - return [parseFloat(convert(elem.css("border-left-width"))), - parseFloat(convert(elem.css("border-top-width")))]; - }, - /* Check positioning to remain on screen. */ _checkOffset: function(inst, offset, isFixed) { var dpWidth = inst.dpDiv.outerWidth(), -- cgit v1.2.3 From 16deadfb90c8c6a2d01c4e882b63d3b2bcf724f3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 5 Apr 2013 16:41:07 -0400 Subject: Mailmap: Change Corey Frang's email address. --- .mailmap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index f83fbe970..4158c202c 100644 --- a/.mailmap +++ b/.mailmap @@ -11,7 +11,7 @@ Ben Hollis Benjamin Scott Boyle Bert ter Heide Chairat Sunthornwiphat -Corey Frang +Corey Frang Courtland Allen Dan Streetman Diego Tres -- cgit v1.2.3 From 6a3bf605ba74ef891bdbe39e8f3d2a0ba6bf33c9 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 6 Apr 2013 22:59:56 -0400 Subject: Draggable Tests: fix copypasta'd assertion messages. --- tests/unit/draggable/draggable_core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 9ef18c4b2..88b9c3f23 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -139,8 +139,8 @@ test( "#5009: scroll not working with parent's position fixed", function() { $( document ).scrollTop( startValue ).scrollLeft( startValue ); }, stop: function( event, ui ) { - equal( ui.position.left, 10, "left position is correct despite overflow on HTML" ); - equal( ui.position.top, 10, "top position is correct despite overflow on HTML" ); + equal( ui.position.left, 10, "left position is correct when parent position is fixed" ); + equal( ui.position.top, 10, "top position is correct when parent position is fixed" ); $( document ).scrollTop( 0 ).scrollLeft( 0 ); } }), -- cgit v1.2.3 From 3c1a3ca252a24f63ab7f4ac819cc7744eaf57c77 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 12:10:59 -0400 Subject: Draggable Tests: fix old Safari and old Opera tests with jQuery < 1.8 tests by accounting for a bug in $.contains on disconnected Elements. --- tests/unit/draggable/draggable_options.js | 12 +++++++++--- tests/unit/draggable/draggable_test_helpers.js | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 6a0cd593b..635d318e7 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1289,9 +1289,15 @@ test( "#8459: element can snap to an element that was removed during drag", func moves: 1 }); - // 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" ); + // Support: Opera 12.10, Safari 5.1, jQuery <1.8 + if ( TestHelpers.draggable.unreliableContains ) { + ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); + ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); + } else { + // 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() { diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 44e37c559..246175604 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -1,6 +1,11 @@ TestHelpers.draggable = { // todo: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, + // Support: Opera 12.10, Safari 5.1, jQuery <1.8 + unreliableContains: function(){ + var element = $( "
" ); + return $.contains( element[ 0 ].ownerDocument, element[ 0 ] ); + }(), testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) { var offsetAfter, actual, expected, offsetBefore = el.offset(); -- cgit v1.2.3 From d4d9e14161d0f2cd64a441e4703c801b35fbc158 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 12:17:19 -0400 Subject: Draggable Tests: fix more old Safari and old Opera tests with jQuery < 1.8 tests by accounting for a bug in $.contains on disconnected Elements. --- tests/unit/draggable/draggable_core.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 88b9c3f23..53703843d 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -87,11 +87,16 @@ test( "#8269: Removing draggable element on drop", function() { } }); - element.simulate( "drag", { - handle: "corner", - x: dropOffset.left, - y: dropOffset.top - }); + // Support: Opera 12.10, Safari 5.1, jQuery <1.8 + if ( TestHelpers.draggable.unreliableContains ) { + ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); + } else { + element.simulate( "drag", { + handle: "corner", + x: dropOffset.left, + y: dropOffset.top + }); + } }); test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() { -- cgit v1.2.3 From 58d9130ba3f7f6560582c41066ca0678c036d8e3 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 12:31:21 -0400 Subject: Draggable Tests: style guide conformance for TestHelpers --- tests/unit/draggable/draggable_test_helpers.js | 56 ++++++++++++-------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 246175604..0263f694c 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -1,12 +1,12 @@ TestHelpers.draggable = { - // todo: remove the unreliable offset hacks + // TODO: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, // Support: Opera 12.10, Safari 5.1, jQuery <1.8 unreliableContains: function(){ var element = $( "
" ); return $.contains( element[ 0 ].ownerDocument, element[ 0 ] ); }(), - testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) { + testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) { var offsetAfter, actual, expected, offsetBefore = el.offset(); @@ -20,64 +20,60 @@ TestHelpers.draggable = { expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY }; msg = msg ? msg + "." : ""; - deepEqual(actual, expected, "dragged[" + dx + ", " + dy + "] " + msg); + deepEqual( actual, expected, "dragged[" + dx + ", " + dy + "] " + msg ); }, - shouldMove: function(el, why) { - TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, why); + shouldMove: function( el, why ) { + TestHelpers.draggable.testDrag( el, el, 50, 50, 50, 50, why ); }, - shouldNotMove: function(el, why) { - TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0, why); + shouldNotMove: function( el, why ) { + TestHelpers.draggable.testDrag( el, el, 50, 50, 0, 0, why ); }, - testScroll: function(el, position ) { - var oldPosition = $("#main").css("position"); - $("#main").css("position", position); - TestHelpers.draggable.shouldMove(el, position+" parent"); - $("#main").css("position", oldPosition); + testScroll: function( el, position ) { + var oldPosition = $( "#main" ).css( "position" ); + $( "#main" ).css( "position", position); + TestHelpers.draggable.shouldMove( el, position + " parent" ); + $( "#main" ).css( "position", oldPosition ); }, restoreScroll: function( what ) { if( what ) { - $(document).scrollTop(0); $(document).scrollLeft(0); + $( document ).scrollTop( 0 ).scrollLeft( 0 ); } else { - $("#main").scrollTop(0); $("#main").scrollLeft(0); + $( "#main" ).scrollTop( 0 ).scrollLeft( 0 ); } }, setScroll: function( what ) { - if(what) { - // todo: currently, the draggable interaction doesn't properly account for scrolled pages, + if( what ) { + // TODO: currently, the draggable interaction doesn't properly account for scrolled pages, // uncomment the line below to make the tests fail that should when the page is scrolled - // $(document).scrollTop(100); $(document).scrollLeft(100); + // $( document ).scrollTop( 100 ).scrollLeft( 100 ); } else { - $("#main").scrollTop(100); $("#main").scrollLeft(100); + $( "#main" ).scrollTop( 100 ).scrollLeft( 100 ); } }, - border: function(el, side) { - return parseInt(el.css("border-" + side + "-width"), 10) || 0; + border: function( el, side ) { + return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0; }, - margin: function(el, side) { - return parseInt(el.css("margin-" + side), 10) || 0; + margin: function( el, side ) { + return parseInt( el.css( "margin-" + side ), 10 ) || 0; }, move: function( el, x, y ) { - $( el ).simulate( "drag", { dx: x, dy: y }); - }, trackMouseCss : function( el ) { el.bind( "drag", function() { - el.data( "last_dragged_cursor", $("body").css("cursor") ); + el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) ); }); }, trackAppendedParent : function( el ) { - - // appendTo ignored without being clone + // TODO: appendTo is currently ignored if helper is original (see #7044) el.draggable( "option", "helper", "clone" ); + // Get what parent is at time of drag el.bind( "drag", function(e,ui) { - // Get what parent is at time of drag - el.data( "last_dragged_parent", ui.helper.parent()[0] ); + el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] ); }); - } }; \ No newline at end of file -- cgit v1.2.3 From 1c1b64fcf017471970c3903a2bc89cc7d108aaa3 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 14:16:31 -0400 Subject: Datepicker Tests: Fix IE tests by accounting for async nature of focus/blur and by correctly not double focusing a programmatically focused date picker. A partial fix was implemented to resolve #6694, and this commit completes the fix so we can programmatically focus a date picker without focus being fired twice. --- tests/unit/datepicker/datepicker_options.js | 146 +++++++++++------------ tests/unit/datepicker/datepicker_test_helpers.js | 7 ++ ui/jquery.ui.datepicker.js | 15 ++- 3 files changed, 89 insertions(+), 79 deletions(-) diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 1efd854a9..c1dcfb2b7 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -87,56 +87,53 @@ test("change", function() { equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); }); -asyncTest("invocation", function() { +asyncTest( "invocation", function() { expect( 29 ); var button, image, - inp = TestHelpers.datepicker.init("#inp"), - dp = $("#ui-datepicker-div"), - body = $("body"); + inp = TestHelpers.datepicker.init( "#inp" ), + dp = $( "#ui-datepicker-div" ), + body = $( "body" ); function step1() { // On focus - button = inp.siblings("button"); - ok(button.length === 0, "Focus - button absent"); - image = inp.siblings("img"); - ok(image.length === 0, "Focus - image absent"); - inp[0].focus(); - setTimeout(function() { - ok(dp.is(":visible"), "Focus - rendered on focus"); - inp.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - ok(!dp.is(":visible"), "Focus - hidden on exit"); - inp[0].blur(); - setTimeout(function() { - inp[0].focus(); - setTimeout(function() { - ok(dp.is(":visible"), "Focus - rendered on focus"); - body.simulate("mousedown", {}); - ok(!dp.is(":visible"), "Focus - hidden on external click"); - inp.datepicker("hide").datepicker("destroy"); + button = inp.siblings( "button" ); + ok( button.length === 0, "Focus - button absent" ); + image = inp.siblings( "img" ); + ok( image.length === 0, "Focus - image absent" ); + + inp.one( "focus", function() { + ok( dp.is( ":visible" ), "Focus - rendered on focus" ); + inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + ok( !dp.is( ":visible" ), "Focus - hidden on exit" ); - step2(); - }); + TestHelpers.datepicker.onBlurThenFocus( inp, function() { + ok( dp.is( ":visible" ), "Focus - rendered on focus" ); + body.simulate( "mousedown", {} ); + ok( !dp.is( ":visible" ), "Focus - hidden on external click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); + + step2(); }); - }); + })[ 0 ].focus(); } function step2() { // On button - inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonText: "Popup"}); - ok(!dp.is(":visible"), "Button - initially hidden"); - button = inp.siblings("button"); - image = inp.siblings("img"); - ok(button.length === 1, "Button - button present"); - ok(image.length === 0, "Button - image absent"); - equal(button.text(), "Popup", "Button - button text"); - inp[0].focus(); - setTimeout(function() { - ok(!dp.is(":visible"), "Button - not rendered on focus"); + inp = TestHelpers.datepicker.init( "#inp", { showOn: "button", buttonText: "Popup" } ); + ok( !dp.is( ":visible" ), "Button - initially hidden" ); + button = inp.siblings( "button" ); + image = inp.siblings( "img" ); + ok( button.length === 1, "Button - button present" ); + ok( image.length === 0, "Button - image absent" ); + equal( button.text(), "Popup", "Button - button text" ); + + TestHelpers.datepicker.onBlurThenFocus( inp, function() { + ok( !dp.is( ":visible" ), "Button - not rendered on focus" ); button.click(); - ok(dp.is(":visible"), "Button - rendered on button click"); + ok( dp.is( ":visible" ), "Button - rendered on button click" ); button.click(); - ok(!dp.is(":visible"), "Button - hidden on second button click"); - inp.datepicker("hide").datepicker("destroy"); + ok( !dp.is( ":visible" ), "Button - hidden on second button click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); step3(); }); @@ -144,23 +141,27 @@ asyncTest("invocation", function() { function step3() { // On image button - inp = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true, - buttonImage: "images/calendar.gif", buttonText: "Cal"}); - ok(!dp.is(":visible"), "Image button - initially hidden"); - button = inp.siblings("button"); - ok(button.length === 0, "Image button - button absent"); - image = inp.siblings("img"); - ok(image.length === 1, "Image button - image present"); - equal(image.attr("src"), "images/calendar.gif", "Image button - image source"); - equal(image.attr("title"), "Cal", "Image button - image text"); - inp[0].focus(); - setTimeout(function() { - ok(!dp.is(":visible"), "Image button - not rendered on focus"); + inp = TestHelpers.datepicker.init( "#inp", { + showOn: "button", + buttonImageOnly: true, + buttonImage: "images/calendar.gif", + buttonText: "Cal" + }); + ok( !dp.is( ":visible" ), "Image button - initially hidden" ); + button = inp.siblings( "button" ); + ok( button.length === 0, "Image button - button absent" ); + image = inp.siblings( "img" ); + ok( image.length === 1, "Image button - image present" ); + equal( image.attr( "src" ), "images/calendar.gif", "Image button - image source" ); + equal( image.attr( "title" ), "Cal", "Image button - image text" ); + + TestHelpers.datepicker.onBlurThenFocus( inp, function() { + ok( !dp.is( ":visible" ), "Image button - not rendered on focus" ); image.click(); - ok(dp.is(":visible"), "Image button - rendered on image click"); + ok( dp.is( ":visible" ), "Image button - rendered on image click" ); image.click(); - ok(!dp.is(":visible"), "Image button - hidden on second image click"); - inp.datepicker("hide").datepicker("destroy"); + ok( !dp.is( ":visible" ), "Image button - hidden on second image click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); step4(); }); @@ -168,29 +169,26 @@ asyncTest("invocation", function() { function step4() { // On both - inp = TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImage: "images/calendar.gif"}); - ok(!dp.is(":visible"), "Both - initially hidden"); - button = inp.siblings("button"); - ok(button.length === 1, "Both - button present"); - image = inp.siblings("img"); - ok(image.length === 0, "Both - image absent"); - image = button.children("img"); - ok(image.length === 1, "Both - button image present"); - inp[0].blur(); - setTimeout(function() { - inp[0].focus(); - setTimeout(function() { - ok(dp.is(":visible"), "Both - rendered on focus"); - body.simulate("mousedown", {}); - ok(!dp.is(":visible"), "Both - hidden on external click"); - button.click(); - ok(dp.is(":visible"), "Both - rendered on button click"); - button.click(); - ok(!dp.is(":visible"), "Both - hidden on second button click"); - inp.datepicker("hide").datepicker("destroy"); + inp = TestHelpers.datepicker.init( "#inp", { showOn: "both", buttonImage: "images/calendar.gif"} ); + ok( !dp.is( ":visible" ), "Both - initially hidden" ); + button = inp.siblings( "button" ); + ok( button.length === 1, "Both - button present" ); + image = inp.siblings( "img" ); + ok( image.length === 0, "Both - image absent" ); + image = button.children( "img" ); + ok( image.length === 1, "Both - button image present" ); - start(); - }); + TestHelpers.datepicker.onBlurThenFocus( inp, function() { + ok( dp.is( ":visible" ), "Both - rendered on focus" ); + body.simulate( "mousedown", {} ); + ok( !dp.is( ":visible" ), "Both - hidden on external click" ); + button.click(); + ok( dp.is( ":visible" ), "Both - rendered on button click" ); + button.click(); + ok( !dp.is( ":visible" ), "Both - hidden on second button click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); + + start(); }); } diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index a9605edff..504bcc767 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -18,5 +18,12 @@ TestHelpers.datepicker = { $.datepicker.setDefaults($.datepicker.regional[""]); return $(id).datepicker($.extend({showAnim: ""}, options || {})); }, + onBlurThenFocus: function( element, callback ) { + element.one( "blur", function(){ + element.one( "focus", function(){ + callback(); + })[ 0 ].focus(); + })[ 0 ].blur(); + }, PROP_NAME: "datepicker" }; \ No newline at end of file diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 976534c94..b433cb79b 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -774,9 +774,10 @@ $.extend(Datepicker.prototype, { inst.dpDiv[showAnim || "show"](showAnim ? duration : null); } - if (inst.input.is(":visible") && !inst.input.is(":disabled")) { + if ( $.datepicker._shouldFocusInput( inst ) ) { inst.input.focus(); } + $.datepicker._curInst = inst; } }, @@ -803,10 +804,7 @@ $.extend(Datepicker.prototype, { inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + "Class"]("ui-datepicker-rtl"); - // #6694 - don't focus the input if it's already focused - // this breaks the change event in IE - if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && - inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) { + if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) { inst.input.focus(); } @@ -823,6 +821,13 @@ $.extend(Datepicker.prototype, { } }, + // #6694 - don't focus the input if it's already focused + // this breaks the change event in IE + // Support: IE and jQuery <1.9 + _shouldFocusInput: function( inst ) { + return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" ); + }, + /* Check positioning to remain on screen. */ _checkOffset: function(inst, offset, isFixed) { var dpWidth = inst.dpDiv.outerWidth(), -- cgit v1.2.3 From 2f7a4c669d1e39079bc34b61fdf5713f02d2b739 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 14:40:26 -0400 Subject: Datepicker Tests: fix IE7 test failures by ensuring the datepicker is hidden before showing it. --- tests/unit/datepicker/datepicker_options.js | 50 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index c1dcfb2b7..64bbc8829 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -1050,38 +1050,40 @@ test("Ticket 6827: formatDate day of year calculation is wrong during day lights equal(time, "089"); }); -test("Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function(){ +test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function() { expect( 3 ); - var inp = TestHelpers.datepicker.init("#inp",{ - beforeShow: function(){ - return false; - } - }), - dp = $("#ui-datepicker-div"); - inp.datepicker("show"); - equal(dp.css("display"), "none","beforeShow returns false"); - inp.datepicker("destroy"); - inp = TestHelpers.datepicker.init("#inp",{ - beforeShow: function(){ + var inp, dp; + + inp = TestHelpers.datepicker.init( "#inp", { + beforeShow: function() { } }); - dp = $("#ui-datepicker-div"); - inp.datepicker("show"); - equal(dp.css("display"), "block","beforeShow returns nothing"); - inp.datepicker("hide"); - inp.datepicker("destroy"); + dp = $( "#ui-datepicker-div" ); + inp.datepicker( "show" ); + equal( dp.css( "display" ), "block", "beforeShow returns nothing" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); - inp = TestHelpers.datepicker.init("#inp",{ - beforeShow: function(){ + inp = TestHelpers.datepicker.init( "#inp", { + beforeShow: function() { return true; } }); - dp = $("#ui-datepicker-div"); - inp.datepicker("show"); - equal(dp.css("display"), "block","beforeShow returns true"); - inp.datepicker("hide"); - inp.datepicker("destroy"); + dp = $( "#ui-datepicker-div" ); + inp.datepicker( "show" ); + equal( dp.css( "display" ), "block", "beforeShow returns true" ); + inp.datepicker( "hide" ); + inp.datepicker( "destroy" ); + + inp = TestHelpers.datepicker.init( "#inp", { + beforeShow: function() { + return false; + } + }); + dp = $( "#ui-datepicker-div" ); + inp.datepicker( "show" ); + equal( dp.css( "display" ), "none","beforeShow returns false" ); + inp.datepicker( "destroy" ); }); })(jQuery); -- cgit v1.2.3 From ab84e037ed919015e24ac3d7e61960290a6062af Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 7 Apr 2013 15:15:04 -0400 Subject: Datepicker Tests: use simulated events for focus and blur. --- tests/unit/datepicker/datepicker_options.js | 2 +- tests/unit/datepicker/datepicker_test_helpers.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 64bbc8829..93ffc8136 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -114,7 +114,7 @@ asyncTest( "invocation", function() { step2(); }); - })[ 0 ].focus(); + }).simulate( "focus" ); } function step2() { diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index 504bcc767..884735def 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -22,8 +22,8 @@ TestHelpers.datepicker = { element.one( "blur", function(){ element.one( "focus", function(){ callback(); - })[ 0 ].focus(); - })[ 0 ].blur(); + }).simulate( "focus" ); + }).simulate( "blur" ); }, PROP_NAME: "datepicker" }; \ No newline at end of file -- cgit v1.2.3 From b8efbd6c07ebcab2f2165033fcea9ded1b9a07a2 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 8 Apr 2013 14:43:37 -0400 Subject: Build: Change single quotes to double quotes. --- Gruntfile.js | 2 +- build/tasks/build.js | 2 +- build/tasks/testswarm.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index fae88635c..24f84b715 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,7 +73,7 @@ var }, main: { options: { - keepSpecialComments: '*' + keepSpecialComments: "*" }, src: "dist/jquery-ui.css", dest: "dist/jquery-ui.min.css" diff --git a/build/tasks/build.js b/build/tasks/build.js index 978bee004..09243cfb6 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -140,7 +140,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { cmd: "zip", args: [ "-r", dest, this.data.src ], opts: { - cwd: 'dist' + cwd: "dist" } }, function( err ) { if ( err ) { diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 01fb178f9..e204936cf 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -53,7 +53,7 @@ function submit( commit, runs, configFile, version, done ) { } ) .addjob( { - name: 'jQuery UI ' + version + '#' + commit.substr( 0, 10 ) + '', + name: "jQuery UI " + version + "#" + commit.substr( 0, 10 ) + "", runs: runs, runMax: config.runMax, browserSets: config.browserSets -- cgit v1.2.3 From d7ea0e5e519da8be0eed08a0db07f752114b752a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 8 Apr 2013 14:45:09 -0400 Subject: Draggable tests: Wrap IIFE in parens. --- tests/unit/draggable/draggable_test_helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index 0263f694c..b36505556 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -2,10 +2,10 @@ TestHelpers.draggable = { // TODO: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, // Support: Opera 12.10, Safari 5.1, jQuery <1.8 - unreliableContains: function(){ + unreliableContains: (function(){ var element = $( "
" ); return $.contains( element[ 0 ].ownerDocument, element[ 0 ] ); - }(), + })(), testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) { var offsetAfter, actual, expected, offsetBefore = el.offset(); -- cgit v1.2.3 From 8f9310609a976cb531597586cdb5a62af31f0576 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 8 Apr 2013 15:02:12 -0400 Subject: Updated .jshintrc settings. --- .jshintrc | 11 ++++++++--- tests/.jshintrc | 16 ++++++++++------ ui/.jshintrc | 12 ++++++++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.jshintrc b/.jshintrc index d6966c51d..d34c42da5 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,12 +1,17 @@ { + "boss": true, "curly": true, - "eqnull": true, "eqeqeq": true, + "eqnull": true, "expr": true, + "immed": true, "noarg": true, - "node": true, "onevar": true, + "quotmark": "double", + "smarttabs": true, "trailing": true, "undef": true, - "unused": true + "unused": true, + + "node": true } diff --git a/tests/.jshintrc b/tests/.jshintrc index b987c5df6..26f47fcee 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -1,18 +1,22 @@ { - "browser": true, + "boss": true, "curly": true, - "eqnull": true, "eqeqeq": true, + "eqnull": true, "expr": true, - "evil": true, - "jquery": true, - "latedef": true, + "immed": true, "noarg": true, "onevar": true, "quotmark": "double", + "smarttabs": true, "trailing": true, "undef": true, "unused": true, + + "browser": true, + "evil": true, + "jquery": true, + "globals": { "asyncTest": false, "closeEnough": false, @@ -34,4 +38,4 @@ "TestHelpers": true, "JSHINT": false } -} \ No newline at end of file +} diff --git a/ui/.jshintrc b/ui/.jshintrc index 578ee94a1..a5d36e1d3 100644 --- a/ui/.jshintrc +++ b/ui/.jshintrc @@ -1,17 +1,21 @@ { - "browser": true, + "boss": true, "curly": true, - "eqnull": true, "eqeqeq": true, + "eqnull": true, "expr": true, - "jquery": true, - "latedef": true, + "immed": true, "noarg": true, "onevar": true, "quotmark": "double", + "smarttabs": true, "trailing": true, "undef": true, "unused": true, + + "browser": true, + "jquery": true, + "globals": { "Globalize": false } -- cgit v1.2.3 From cdff8de18ff6b52b773e1dc017fea2475f01ee08 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 8 Apr 2013 15:02:54 -0400 Subject: Upgrade grunt-contrib-jshint to 0.4.1. --- build/release/release.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/release/release.js b/build/release/release.js index 2eab5283f..159345b99 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -/*global cat:true cd:true echo:true exec:true exit:true*/ +/* global cat:true, cd:true, echo:true, exec:true, exit:true */ // Usage: // stable release: node release.js diff --git a/package.json b/package.json index f348f88cd..4a66f0d73 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "dependencies": {}, "devDependencies": { "grunt": "0.4.1", - "grunt-contrib-jshint": "0.1.1", + "grunt-contrib-jshint": "0.4.1", "grunt-contrib-uglify": "0.1.1", "grunt-contrib-concat": "0.1.3", "grunt-contrib-qunit": "0.2.0", -- cgit v1.2.3 From 5b9e6a44d8b7c3b1c67e71b448951153bec15c95 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 9 Apr 2013 14:22:37 -0400 Subject: Tests: Renamed TestSwarm jobs. --- build/tasks/testswarm.js | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index e204936cf..2db312048 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -33,37 +33,40 @@ var versions = { "Widget": "widget/widget.html" }; -function submit( commit, runs, configFile, version, done ) { +function submit( commit, runs, configFile, extra, done ) { var testName, testswarm = require( "testswarm" ), - config = grunt.file.readJSON( configFile ).jqueryui; - version = version ? ( version + " " ) : ""; + config = grunt.file.readJSON( configFile ).jqueryui, + commitUrl = "https://github.com/jquery/jquery-ui/commit/" + commit; + + if ( extra ) { + extra = " " + extra; + } + for ( testName in runs ) { - runs[ testName] = config.testUrl + commit + "/tests/unit/" + runs[ testName ]; + runs[ testName ] = config.testUrl + commit + "/tests/unit/" + runs[ testName ]; } - testswarm.createClient( { + testswarm.createClient({ url: config.swarmUrl, pollInterval: 10000, timeout: 1000 * 60 * 45 - } ) + }) .addReporter( testswarm.reporters.cli ) - .auth( { + .auth({ id: config.authUsername, token: config.authToken - } ) - .addjob( - { - name: "jQuery UI " + version + "#" + commit.substr( 0, 10 ) + "", - runs: runs, - runMax: config.runMax, - browserSets: config.browserSets - }, function( err, passed ) { - if ( err ) { - grunt.log.error( err ); - } - done( passed ); + }) + .addjob({ + name: "jQuery UI #" + commit.substr( 0, 10 ) + "" + extra, + runs: runs, + runMax: config.runMax, + browserSets: config.browserSets + }, function( error, passed ) { + if ( error ) { + grunt.log.error( error ); } - ); + done( passed ); + }); } grunt.registerTask( "testswarm", function( commit, configFile ) { @@ -82,7 +85,7 @@ grunt.registerTask( "testswarm-multi-jquery", function( commit, configFile, mino allTests[ test + "-" + version ] = tests[ test ] + "?nojshint=true&jquery=" + version; } }); - submit( commit, allTests, configFile, minor + " core", this.async() ); + submit( commit, allTests, configFile, "core " + minor, this.async() ); }); }; -- cgit v1.2.3 From 2de31fdbf498a6c20d196a96d007ea0f069644c5 Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Sun, 7 Apr 2013 12:57:15 -0400 Subject: Button: On form reset only call refresh on current button widgets. Fixed #9213: Button: timeout in formResetHandler causing refresh to be called on non-widgets --- tests/unit/button/button_core.js | 24 ++++++++++++++++++++++++ ui/jquery.ui.button.js | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index dbc079818..16c7ca450 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -153,6 +153,30 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); }); +asyncTest( "Resetting a button's form should refresh the visual state of the button widget to match.", function() { + expect( 2 ); + var form = $( "
" + + "" + + "" + + "
" ), + button = form.find( "button" ).button(), + checkbox = form.find( "input[type=checkbox]" ).button(); + + checkbox.prop( "checked", false ).button( "refresh" ); + ok( !checkbox.button( "widget" ).hasClass( "ui-state-active" ) ); + + form.get( 0 ).reset(); + + // #9213: If a button has been removed, refresh should not be called on it when + // its corresponding form is reset. + button.remove(); + + setTimeout(function() { + ok( checkbox.button( "widget" ).hasClass( "ui-state-active" )); + start(); + }); +}); + asyncTest( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { expect( 2 ); var check = $( "#check" ).button(), diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 5e64f5164..dd6892275 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -19,9 +19,9 @@ var lastActive, startXPos, startYPos, clickDragged, stateClasses = "ui-state-hover ui-state-active ", typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", formResetHandler = function() { - var buttons = $( this ).find( ":ui-button" ); + var form = $( this ); setTimeout(function() { - buttons.button( "refresh" ); + form.find( ":ui-button" ).button( "refresh" ); }, 1 ); }, radioGroup = function( radio ) { -- cgit v1.2.3 From 0d0b05ec7cf702b8782b19c993eeb30398a090f4 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 11 Apr 2013 14:03:51 -0400 Subject: Button: Remove ui-state-focus class when becoming disabled. Fixes #9169 - Button: Disabled button maintains ui-state-focus in IE & Firefox on Windows. --- tests/unit/button/button.html | 2 ++ tests/unit/button/button_core.js | 13 +++++++++++++ ui/jquery.ui.button.js | 27 +++++++++++++++------------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index eeb568686..223581ef7 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -71,6 +71,8 @@
+ +
diff --git a/tests/unit/button/button_core.js b/tests/unit/button/button_core.js index 16c7ca450..55dda68b3 100644 --- a/tests/unit/button/button_core.js +++ b/tests/unit/button/button_core.js @@ -196,4 +196,17 @@ test( "#7534 - Button label selector works for ids with \":\"", function() { ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); }); +asyncTest( "#9169 - Disabled button maintains ui-state-focus", function() { + expect( 2 ); + var element = $( "#button1" ).button(); + element[ 0 ].focus(); + setTimeout(function() { + ok( element.hasClass( "ui-state-focus" ), "button has ui-state-focus" ); + element.button( "disable" ); + ok( !element.hasClass( "ui-state-focus" ), + "button does not have ui-state-focus when disabled" ); + start(); + }); +}); + })(jQuery); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index dd6892275..ae3b86ae9 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -16,7 +16,6 @@ var lastActive, startXPos, startYPos, clickDragged, baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", - stateClasses = "ui-state-hover ui-state-active ", typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", formResetHandler = function() { var form = $( this ); @@ -71,8 +70,7 @@ $.widget( "ui.button", { var that = this, options = this.options, toggleButton = this.type === "checkbox" || this.type === "radio", - activeClass = !toggleButton ? "ui-state-active" : "", - focusClass = "ui-state-focus"; + activeClass = !toggleButton ? "ui-state-active" : ""; if ( options.label === null ) { options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html()); @@ -104,14 +102,16 @@ $.widget( "ui.button", { } }); - this.element - .bind( "focus" + this.eventNamespace, function() { - // no need to check disabled, focus won't be triggered anyway - that.buttonElement.addClass( focusClass ); - }) - .bind( "blur" + this.eventNamespace, function() { - that.buttonElement.removeClass( focusClass ); - }); + // Can't use _focusable() because the element that receives focus + // and the element that gets the ui-state-focus class are different + this._on({ + focus: function() { + this.buttonElement.addClass( "ui-state-focus" ); + }, + blur: function() { + this.buttonElement.removeClass( "ui-state-focus" ); + } + }); if ( toggleButton ) { this.element.bind( "change" + this.eventNamespace, function() { @@ -257,7 +257,7 @@ $.widget( "ui.button", { this.element .removeClass( "ui-helper-hidden-accessible" ); this.buttonElement - .removeClass( baseClasses + " " + stateClasses + " " + typeClasses ) + .removeClass( baseClasses + " ui-state-active " + typeClasses ) .removeAttr( "role" ) .removeAttr( "aria-pressed" ) .html( this.buttonElement.find(".ui-button-text").html() ); @@ -272,6 +272,9 @@ $.widget( "ui.button", { if ( key === "disabled" ) { this.widget().toggleClass( "ui-state-disabled", !!value ); this.element.prop( "disabled", !!value ); + if ( value ) { + this.buttonElement.removeClass( "ui-state-focus" ); + } return; } this._resetButton(); -- cgit v1.2.3 From 530d1b7c8c86fbe328c6df439ad9afef779fa435 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Thu, 11 Apr 2013 20:48:05 -0400 Subject: Datepicker Tests: ensure Focus tests work all the way back to jQuery 1.6 in all browsers without having to rely on timeouts. --- tests/unit/datepicker/datepicker_options.js | 98 +++++++++++++++--------- tests/unit/datepicker/datepicker_test_helpers.js | 16 ++-- 2 files changed, 70 insertions(+), 44 deletions(-) diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 93ffc8136..a5d66314c 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -88,38 +88,51 @@ test("change", function() { }); asyncTest( "invocation", function() { - expect( 29 ); var button, image, - inp = TestHelpers.datepicker.init( "#inp" ), - dp = $( "#ui-datepicker-div" ), + isOldIE = $.ui.ie && ( !document.documentMode || document.documentMode < 9 ), body = $( "body" ); - function step1() { - // On focus + expect( isOldIE ? 25 : 29 ); + + function step0() { + var input = $( "" ).appendTo( "#qunit-fixture" ), + inp = TestHelpers.datepicker.init( input ), + dp = $( "#ui-datepicker-div" ); + button = inp.siblings( "button" ); ok( button.length === 0, "Focus - button absent" ); image = inp.siblings( "img" ); ok( image.length === 0, "Focus - image absent" ); - inp.one( "focus", function() { + TestHelpers.datepicker.onFocus( inp, function() { ok( dp.is( ":visible" ), "Focus - rendered on focus" ); inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); ok( !dp.is( ":visible" ), "Focus - hidden on exit" ); + step1(); + }); + } - TestHelpers.datepicker.onBlurThenFocus( inp, function() { - ok( dp.is( ":visible" ), "Focus - rendered on focus" ); - body.simulate( "mousedown", {} ); - ok( !dp.is( ":visible" ), "Focus - hidden on external click" ); - inp.datepicker( "hide" ).datepicker( "destroy" ); + function step1() { - step2(); - }); - }).simulate( "focus" ); + var input = $( "" ).appendTo( "#qunit-fixture" ), + inp = TestHelpers.datepicker.init( input ), + dp = $( "#ui-datepicker-div" ); + + TestHelpers.datepicker.onFocus( inp, function() { + ok( dp.is( ":visible" ), "Focus - rendered on focus" ); + body.simulate( "mousedown", {} ); + ok( !dp.is( ":visible" ), "Focus - hidden on external click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); + + step2(); + }); } function step2() { - // On button - inp = TestHelpers.datepicker.init( "#inp", { showOn: "button", buttonText: "Popup" } ); + var input = $( "" ).appendTo( "#qunit-fixture" ), + inp = TestHelpers.datepicker.init( input, { showOn: "button", buttonText: "Popup" } ), + dp = $( "#ui-datepicker-div" ); + ok( !dp.is( ":visible" ), "Button - initially hidden" ); button = inp.siblings( "button" ); image = inp.siblings( "img" ); @@ -127,7 +140,7 @@ asyncTest( "invocation", function() { ok( image.length === 0, "Button - image absent" ); equal( button.text(), "Popup", "Button - button text" ); - TestHelpers.datepicker.onBlurThenFocus( inp, function() { + TestHelpers.datepicker.onFocus( inp, function() { ok( !dp.is( ":visible" ), "Button - not rendered on focus" ); button.click(); ok( dp.is( ":visible" ), "Button - rendered on button click" ); @@ -140,13 +153,15 @@ asyncTest( "invocation", function() { } function step3() { - // On image button - inp = TestHelpers.datepicker.init( "#inp", { - showOn: "button", - buttonImageOnly: true, - buttonImage: "images/calendar.gif", - buttonText: "Cal" - }); + var input = $( "" ).appendTo( "#qunit-fixture" ), + inp = TestHelpers.datepicker.init( input, { + showOn: "button", + buttonImageOnly: true, + buttonImage: "images/calendar.gif", + buttonText: "Cal" + }), + dp = $( "#ui-datepicker-div" ); + ok( !dp.is( ":visible" ), "Image button - initially hidden" ); button = inp.siblings( "button" ); ok( button.length === 0, "Image button - button absent" ); @@ -155,7 +170,7 @@ asyncTest( "invocation", function() { equal( image.attr( "src" ), "images/calendar.gif", "Image button - image source" ); equal( image.attr( "title" ), "Cal", "Image button - image text" ); - TestHelpers.datepicker.onBlurThenFocus( inp, function() { + TestHelpers.datepicker.onFocus( inp, function() { ok( !dp.is( ":visible" ), "Image button - not rendered on focus" ); image.click(); ok( dp.is( ":visible" ), "Image button - rendered on image click" ); @@ -168,8 +183,10 @@ asyncTest( "invocation", function() { } function step4() { - // On both - inp = TestHelpers.datepicker.init( "#inp", { showOn: "both", buttonImage: "images/calendar.gif"} ); + var input = $( "" ).appendTo( "#qunit-fixture" ), + inp = TestHelpers.datepicker.init( input, { showOn: "both", buttonImage: "images/calendar.gif"} ), + dp = $( "#ui-datepicker-div" ); + ok( !dp.is( ":visible" ), "Both - initially hidden" ); button = inp.siblings( "button" ); ok( button.length === 1, "Both - button present" ); @@ -178,21 +195,26 @@ asyncTest( "invocation", function() { image = button.children( "img" ); ok( image.length === 1, "Both - button image present" ); - TestHelpers.datepicker.onBlurThenFocus( inp, function() { - ok( dp.is( ":visible" ), "Both - rendered on focus" ); - body.simulate( "mousedown", {} ); - ok( !dp.is( ":visible" ), "Both - hidden on external click" ); - button.click(); - ok( dp.is( ":visible" ), "Both - rendered on button click" ); - button.click(); - ok( !dp.is( ":visible" ), "Both - hidden on second button click" ); - inp.datepicker( "hide" ).datepicker( "destroy" ); + // TODO: occasionally this test flakily fails to focus in IE8 in browserstack + if ( !isOldIE ) { + TestHelpers.datepicker.onFocus( inp, function() { + ok( dp.is( ":visible" ), "Both - rendered on focus" ); + body.simulate( "mousedown", {} ); + ok( !dp.is( ":visible" ), "Both - hidden on external click" ); + button.click(); + ok( dp.is( ":visible" ), "Both - rendered on button click" ); + button.click(); + ok( !dp.is( ":visible" ), "Both - hidden on second button click" ); + inp.datepicker( "hide" ).datepicker( "destroy" ); + start(); + }); + } else { start(); - }); + } } - step1(); + step0(); }); test("otherMonths", function() { diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index 884735def..b683f5137 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -18,12 +18,16 @@ TestHelpers.datepicker = { $.datepicker.setDefaults($.datepicker.regional[""]); return $(id).datepicker($.extend({showAnim: ""}, options || {})); }, - onBlurThenFocus: function( element, callback ) { - element.one( "blur", function(){ - element.one( "focus", function(){ - callback(); - }).simulate( "focus" ); - }).simulate( "blur" ); + onFocus: function( element, onFocus ) { + var fn = function( event ){ + if( !event.originalEvent ) { + return; + } + element.unbind( "focus", fn ); + onFocus(); + }; + + element.bind( "focus", fn )[ 0 ].focus(); }, PROP_NAME: "datepicker" }; \ No newline at end of file -- cgit v1.2.3 From 445ffd0acc95e8c4adb4d63b12815e9bcac1c198 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 11 Apr 2013 20:54:36 -0400 Subject: Autocomplete demo: Use custom namespace for combobox. --- demos/autocomplete/combobox.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 22f34aa17..2b5e511be 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -14,11 +14,11 @@