From 6358695df18722d8c7e99437365db42cf4957626 Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Sat, 26 Jan 2013 15:31:27 -0500 Subject: Draggable: Fix border containment. Fixed #5569 - Draggable: Containment incorrectly calculates padding and border --- tests/unit/draggable/draggable_options.js | 31 +++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index ccbe7224a..2e9f85c24 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -346,6 +346,37 @@ test( "{ containment: 'parent' }, absolute", function() { deepEqual( offsetAfter, expected, "compare offset to parent" ); }); +test( "containment, account for border", function() { + expect( 2 ); + + var el = $("#draggable1").appendTo("#main"), + parent = el.parent().css({ + height: "100px", + width: "100px", + borderStyle: "solid", + borderWidth: "5px 10px 15px 20px" + }), + parentBottom = parent.offset().top + parent.outerHeight(), + parentRight = parent.offset().left + parent.outerWidth(), + parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ), + parentBorderRight = TestHelpers.draggable.border( parent, "right" ); + + el.css({ + height: "5px", + width: "5px" + }).draggable({ containment: "parent" }); + + el.simulate( "drag", { + dx: 100, + dy: 100 + }); + + equal( el.offset().top, parentBottom - parentBorderBottom - el.height(), + "The draggable should be on top of its parent's bottom border" ); + equal( el.offset().left, parentRight - parentBorderRight - el.width(), + "The draggable should be to the right of its parent's right border" ); +}); + test( "containment, default, switching after initialization", function() { expect( 2 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 7c1fb3361..56b8fc77d 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -421,8 +421,8 @@ $.widget("ui.draggable", $.ui.mouse, { 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("borderLeftWidth"),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("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom + (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 ]; this.relative_container = c; -- cgit v1.2.3 From cdff72efed495d7a17c551578079619712758793 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 8 Mar 2013 10:08:46 -0500 Subject: Draggable: Account for descendants in handle. --- tests/unit/draggable/draggable.html | 2 +- tests/unit/draggable/draggable_options.js | 28 ++-------------------------- ui/jquery.ui.draggable.js | 14 +++----------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 6380f3e85..3d1d3326e 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -48,7 +48,7 @@
Relative
-
Absolute
+
Absolute
Absolute
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 2e9f85c24..a71bf57cb 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -603,39 +603,15 @@ test( "grid, switching after initialization", function() { }); test( "{ handle: 'span' }", function() { - expect( 2 ); + expect( 3 ); var element = $( "#draggable2" ).draggable({ handle: "span" }); TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" ); + TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" ); TestHelpers.draggable.shouldNotMove( element, "drag element" ); }); -/* -test( "{ handle: Selectors }, matching parent selector", function() { - - expect( 4 ); - - var element = $( "#draggable2" ).draggable({ handle: "span a" }); - - $( "#qunit-fixture" ).append( "" ); - - element.find( "span" ).append( "" ); - - $( "#wrapping a" ).append( element ); - - TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); - - $( "#draggable2" ).draggable( "option", "handle", "span > a" ); - $( "#draggable2" ).find( "a" ).append( "" ); - - TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() ); - -}); -*/ - test( "handle, default, switching after initialization", function() { expect( 6 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 56b8fc77d..5762d3171 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -281,17 +281,9 @@ $.widget("ui.draggable", $.ui.mouse, { }, _getHandle: function(event) { - - var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - - this.element.find( this.options.handle ).each(function() { - if(this === event.target) { - handle = true; - } - }); - - return handle; - + return this.options.handle ? + !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : + true; }, _createHelper: function(event) { -- cgit v1.2.3 From e0b2644d91ffb8b59f9cf6d8ac8b45f94af7dacd Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 8 Mar 2013 10:23:25 -0500 Subject: Removed guard against duplicate loading. Use safe references to original functions when proxying, don't rename originals. --- ui/jquery.ui.core.js | 36 ++++++++++++--------------- ui/jquery.ui.effect.js | 67 ++++++++++++++++++++++++++------------------------ 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index d224f181a..1a13da251 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -13,13 +13,8 @@ var uuid = 0, runiqueId = /^ui-id-\d+$/; -// prevent duplicate loading -// this is only a problem because we proxy existing functions -// and we don't want to double proxy them +// $.ui might exist from components with no dependencies, e.g., $.ui.position $.ui = $.ui || {}; -if ( $.ui.version ) { - return; -} $.extend( $.ui, { version: "@VERSION", @@ -52,20 +47,21 @@ $.extend( $.ui, { // plugins $.fn.extend({ - _focus: $.fn.focus, - focus: function( delay, fn ) { - return typeof delay === "number" ? - this.each(function() { - var elem = this; - setTimeout(function() { - $( elem ).focus(); - if ( fn ) { - fn.call( elem ); - } - }, delay ); - }) : - this._focus.apply( this, arguments ); - }, + focus: (function( orig ) { + return function( delay, fn ) { + return typeof delay === "number" ? + this.each(function() { + var elem = this; + setTimeout(function() { + $( elem ).focus(); + if ( fn ) { + fn.call( elem ); + } + }, delay ); + }) : + orig.apply( this, arguments ); + }; + })( $.fn.focus ), scrollParent: function() { var scrollParent; diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index f3d9929b0..3d65b40c7 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -8,7 +8,7 @@ * * http://api.jqueryui.com/category/effects-core/ */ -;(jQuery.effects || (function($, undefined) { +(function($, undefined) { var dataSpace = "ui-effects-"; @@ -839,39 +839,42 @@ $.effects.animateClass = function( value, duration, easing, callback ) { }; $.fn.extend({ - _addClass: $.fn.addClass, - addClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { add: classNames }, speed, easing, callback ) : - this._addClass( classNames ); - }, - - _removeClass: $.fn.removeClass, - removeClass: function( classNames, speed, easing, callback ) { - return arguments.length > 1 ? - $.effects.animateClass.call( this, - { remove: classNames }, speed, easing, callback ) : - this._removeClass.apply( this, arguments ); - }, - - _toggleClass: $.fn.toggleClass, - toggleClass: function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - // without speed parameter - return this._toggleClass( classNames, force ); + addClass: (function( orig ) { + return function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.call( this, + { add: classNames }, speed, easing, callback ) : + orig.apply( this, arguments ); + }; + })( $.fn.addClass ), + + removeClass: (function( orig ) { + return function( classNames, speed, easing, callback ) { + return arguments.length > 1 ? + $.effects.animateClass.call( this, + { remove: classNames }, speed, easing, callback ) : + orig.apply( this, arguments ); + }; + })( $.fn.removeClass ), + + toggleClass: (function( orig ) { + return function( classNames, force, speed, easing, callback ) { + if ( typeof force === "boolean" || force === undefined ) { + if ( !speed ) { + // without speed parameter + return orig.apply( this, arguments ); + } else { + return $.effects.animateClass.call( this, + (force ? { add: classNames } : { remove: classNames }), + speed, easing, callback ); + } } else { + // without force parameter return $.effects.animateClass.call( this, - (force ? { add: classNames } : { remove: classNames }), - speed, easing, callback ); + { toggle: classNames }, force, speed, easing ); } - } else { - // without force parameter - return $.effects.animateClass.call( this, - { toggle: classNames }, force, speed, easing ); - } - }, + }; + })( $.fn.toggleClass ), switchClass: function( remove, add, speed, easing, callback) { return $.effects.animateClass.call( this, { @@ -1283,4 +1286,4 @@ $.each( baseEasings, function( name, easeIn ) { })(); -})(jQuery)); +})(jQuery); -- cgit v1.2.3 From 89473f6557662d905a63faa3ae3520bf3715a7e8 Mon Sep 17 00:00:00 2001 From: John Chen Date: Sat, 16 Feb 2013 21:32:55 +0800 Subject: Sortable: Skip items that are not at the same line as the cursor when floating. Fixes #8792: Issue with floated items in connected lists. --- ui/jquery.ui.sortable.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 93c6cccc5..22acff7d1 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -21,6 +21,10 @@ function isOverAxis( x, reference, size ) { return ( x > reference ) && ( x < ( reference + size ) ); } +function isFloating(item) { + return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); +} + $.widget("ui.sortable", $.ui.mouse, { version: "@VERSION", widgetEventPrefix: "sort", @@ -73,7 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, { this.refresh(); //Let's determine if the items are being displayed horizontally - this.floating = this.items.length ? o.axis === "x" || (/left|right/).test(this.items[0].item.css("float")) || (/inline|table-cell/).test(this.items[0].item.css("display")) : false; + this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; //Let's determine the parent's offset this.offset = this.element.offset(); @@ -799,7 +803,7 @@ $.widget("ui.sortable", $.ui.mouse, { }, _contactContainers: function(event) { - var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, + var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, innermostContainer = null, innermostIndex = null; @@ -845,8 +849,9 @@ $.widget("ui.sortable", $.ui.mouse, { //When entering a new container, we will find the item with the least distance and append our item near it dist = 10000; itemWithLeastDistance = null; - posProperty = this.containers[innermostIndex].floating ? "left" : "top"; - sizeProperty = this.containers[innermostIndex].floating ? "width" : "height"; + floating = innermostContainer.floating || isFloating(this.currentItem); + posProperty = floating ? "left" : "top"; + sizeProperty = floating ? "width" : "height"; base = this.positionAbs[posProperty] + this.offset.click[posProperty]; for (j = this.items.length - 1; j >= 0; j--) { if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { @@ -855,6 +860,9 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.items[j].item[0] === this.currentItem[0]) { continue; } + if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { + continue; + } cur = this.items[j].item.offset()[posProperty]; nearBottom = false; if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ @@ -873,10 +881,14 @@ $.widget("ui.sortable", $.ui.mouse, { return; } - this.currentContainer = this.containers[innermostIndex]; + if(this.currentContainer === this.containers[innermostIndex]) { + return; + } + itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); this._trigger("change", event, this._uiHash()); this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); + this.currentContainer = this.containers[innermostIndex]; //Update the placeholder this.options.placeholder.update(this.currentContainer, this.placeholder); -- cgit v1.2.3 From 07ce771a13504b851bb9f74c8ce8e960d207384a Mon Sep 17 00:00:00 2001 From: John Chen Date: Sat, 16 Feb 2013 22:35:58 +0800 Subject: Sortable: Skip triggering over event if it's alreay over the continer. Fixes #9041: the over event fires on every pixel movement --- ui/jquery.ui.sortable.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 22acff7d1..0f9b113a4 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -842,8 +842,10 @@ $.widget("ui.sortable", $.ui.mouse, { // move the item into the container if it's not there already if(this.containers.length === 1) { - this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); - this.containers[innermostIndex].containerCache.over = 1; + if (!this.containers[innermostIndex].containerCache.over) { + this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); + this.containers[innermostIndex].containerCache.over = 1; + } } else { //When entering a new container, we will find the item with the least distance and append our item near it -- cgit v1.2.3 From 8b1b34c5c3e8fae056f0880776156dc003b5e2c3 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Fri, 8 Mar 2013 16:38:41 -0500 Subject: Sortable Tests: Add tests to support #9041 and #8792 --- tests/unit/sortable/sortable_events.js | 27 ++++++++++++++++++++++-- tests/unit/sortable/sortable_options.js | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 1b8165acb..46a493b3e 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -231,11 +231,34 @@ test("receive", function() { test("remove", function() { ok(false, "missing test - untested code is broken code."); }); +*/ -test("over", function() { - ok(false, "missing test - untested code is broken code."); +test( "over", function() { + expect( 8 ); + + var hash, + overCount = 0; + + $( "#sortable" ).sortable({ + over: function( e, ui ) { + hash = ui; + overCount++; + } + }).find( "li:eq(0)" ).simulate( "drag", { + dy: 20 + }); + + ok( hash, "stop event triggered" ); + ok( hash.helper, "UI should not include: helper" ); + ok( hash.placeholder, "UI hash includes: placeholder" ); + ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" ); + ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" ); + ok( hash.item, "UI hash includes: item" ); + ok( hash.sender, "UI hash does not include: sender" ); + equal( overCount, 1, "over fires only once" ); }); +/* test("out", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index caba0a777..638573162 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -37,7 +37,44 @@ test("{ cancel: 'input,textarea,button,select,option' }, default", function() { test("{ cancel: Selector }", function() { ok(false, "missing test - untested code is broken code."); }); +*/ + +test( "#8792: issues with floated items in connected lists", function() { + expect( 2 ); + + var element, + changeCount = 0; + + $( "#qunit-fixture" ) + .html( "
  • a
  • a
  • a
  • a
" ) + .find( "ul" ).css({ "float": "left", width: "100px" }).end() + .find( "li" ).css({ "float": "left", width: "50px", height: "50px" }); + + $( "#qunit-fixture .c" ).sortable({ + connectWith: "#qunit-fixture .c", + change: function() { + changeCount++; + } + }); + + element = $( "#qunit-fixture li:eq(0)" ); + element.simulate( "drag", { + dx: 51, + moves: 15 + }); + + equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); + + element.simulate( "drag", { + dx: 50, + moves: 15 + }); + + equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" ); +}); + +/* test("{ connectWith: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); -- cgit v1.2.3 From 57051e8a7323e27fe159e5448b52666f1bdbc409 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 9 Mar 2013 08:12:31 -0500 Subject: Draggable tests: Don't use .on(). --- 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 e1c79c6cc..44e37c559 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -60,7 +60,7 @@ TestHelpers.draggable = { }, trackMouseCss : function( el ) { - el.on( "drag", function() { + el.bind( "drag", function() { el.data( "last_dragged_cursor", $("body").css("cursor") ); }); }, @@ -69,7 +69,7 @@ TestHelpers.draggable = { // appendTo ignored without being clone el.draggable( "option", "helper", "clone" ); - el.on( "drag", function(e,ui) { + el.bind( "drag", function(e,ui) { // Get what parent is at time of drag el.data( "last_dragged_parent", ui.helper.parent()[0] ); }); -- cgit v1.2.3 From 4f95a0f396965e91982f1b5e67da814bb6640ce1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 11 Mar 2013 11:57:21 -0400 Subject: CSS Framework: Add ui-icon-blank class for an icon with no image. Fixes #9150 - CSS Framework: Add ui-icon-blank. This essentially reverts 1fe06f03fac30ce76b87eab8c5a9acc72becd587 and the fix for #5659. --- themes/base/jquery.ui.theme.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/base/jquery.ui.theme.css b/themes/base/jquery.ui.theme.css index c606011f0..fd586d90b 100644 --- a/themes/base/jquery.ui.theme.css +++ b/themes/base/jquery.ui.theme.css @@ -156,7 +156,6 @@ .ui-icon { width: 16px; height: 16px; - background-position: 16px 16px; } .ui-icon, .ui-widget-content .ui-icon { @@ -184,6 +183,7 @@ } /* positioning */ +.ui-icon-blank { background-position: 16px 16px; } .ui-icon-carat-1-n { background-position: 0 0; } .ui-icon-carat-1-ne { background-position: -16px 0; } .ui-icon-carat-1-e { background-position: -32px 0; } -- cgit v1.2.3 From 4d67f4f34908a50ef88f95df4103ee001b777e45 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Mon, 11 Mar 2013 21:28:51 -0400 Subject: Widget: Stop setting ui-state-disabled and aria by default on setting disabled option. Fixes #5973 - Resizable: disabled should not have the ui-state-disabled class or aria attribute aria-disabled Fixes #5974 - Draggable: disabled should not have the ui-state-disabled class or aria attribute aria-disabled Fixes #6039 - Droppable : disabled should not have ui-state-disabled --- tests/unit/accordion/accordion_methods.js | 7 ++++- tests/unit/autocomplete/autocomplete_options.js | 11 +++++--- tests/unit/button/button_options.js | 29 ++++++++++++-------- tests/unit/dialog/dialog_methods.js | 4 ++- tests/unit/draggable/draggable_methods.js | 14 ++++++---- tests/unit/droppable/droppable_methods.js | 29 +++++++++++--------- tests/unit/progressbar/progressbar_methods.js | 10 +++++++ tests/unit/resizable/resizable_methods.js | 17 +++++++++--- tests/unit/selectable/selectable_methods.js | 36 ++++++++++++++----------- tests/unit/slider/slider_methods.js | 3 ++- tests/unit/sortable/sortable_methods.js | 35 ++++++++++++------------ tests/unit/spinner/spinner_methods.js | 4 ++- tests/unit/tabs/tabs_options.js | 18 ++++++++++++- tests/unit/tooltip/tooltip_methods.js | 7 ++++- ui/jquery.ui.accordion.js | 3 +++ ui/jquery.ui.button.js | 10 ++----- ui/jquery.ui.droppable.js | 2 +- ui/jquery.ui.menu.js | 5 ++++ ui/jquery.ui.progressbar.js | 6 ++++- ui/jquery.ui.slider.js | 6 ++++- ui/jquery.ui.sortable.js | 11 -------- ui/jquery.ui.spinner.js | 10 +++---- ui/jquery.ui.widget.js | 3 +-- 23 files changed, 174 insertions(+), 106 deletions(-) diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index b1123b828..7612479f7 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -14,10 +14,15 @@ test( "destroy", function() { }); test( "enable/disable", function() { - expect( 4 ); + expect( 7 ); var element = $( "#list1" ).accordion(); state( element, 1, 0, 0 ); element.accordion( "disable" ); + + ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); + ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" ); + // event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); state( element, 1, 0, 0 ); diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 9f0bd2d43..c98f2c28e 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -88,17 +88,20 @@ asyncTest( "delay", function() { }); asyncTest( "disabled", function() { - expect( 2 ); + expect( 5 ); var element = $( "#autocomplete" ).autocomplete({ source: data, - delay: 0, - disabled: true + delay: 0 }), - menu = element.autocomplete( "widget" ); + menu = element.autocomplete( "disable" ).autocomplete( "widget" ); element.val( "ja" ).keydown(); ok( menu.is( ":hidden" ) ); + ok( !element.is( ".ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( menu.is( ".ui-autocomplete-disabled" ), "element gets ui-autocomplete-disabled" ); + setTimeout(function() { ok( menu.is( ":hidden" ) ); start(); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index e1931a54e..124a8699f 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -3,19 +3,26 @@ */ (function($) { -module("button: options"); +module( "button: options" ); -test("disabled, explicit value", function() { - expect( 4 ); - $("#radio01").button({ disabled: false }); - deepEqual(false, $("#radio01").button("option", "disabled"), - "disabled option set to false"); - deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); +test( "disabled, explicit value", function() { + expect( 9 ); - $("#radio02").button({ disabled: true }); - deepEqual(true, $("#radio02").button("option", "disabled"), - "disabled option set to true"); - deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); + var element = $( "#radio01" ).button({ disabled: false }); + deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); + deepEqual( element.prop( "disabled" ), false, "element is disabled" ); + + ok( !element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + element = $( "#radio02" ).button({ disabled: true }); + + ok( element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); + deepEqual( element.prop( "disabled" ), true, "element is not disabled" ); }); test("disabled, null", function() { diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 6de185513..2bb06ab46 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -101,11 +101,13 @@ test("#4980: Destroy should place element back in original DOM position", functi }); test( "enable/disable disabled", function() { - expect( 2 ); + expect( 4 ); var element = $( "
" ).dialog(); element.dialog( "disable" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); + ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" ); + ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" ); }); test("close", function() { diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 901c261d6..63a19e26d 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -74,16 +74,16 @@ test( "enable", function() { }); test( "disable", function() { - expect( 7 ); + expect( 10 ); - element = $("#draggable2").draggable({ disabled: false }); + element = $( "#draggable2" ).draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - element.draggable("disable"); + element.draggable( "disable" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); - element.draggable("destroy"); + element.draggable( "destroy" ); element.draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); @@ -91,8 +91,12 @@ test( "disable", function() { equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" ); + ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" ); + var expected = element.draggable(), - actual = expected.draggable("disable"); + actual = expected.draggable( "disable" ); equal( actual, expected, "disable is chainable" ); }); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index 2b452a63d..f7682d262 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -63,26 +63,29 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 10 ); - var el, actual, expected; + var actual, expected, + element = $( "#droppable1" ).droppable({ disabled: false }); - el = $("#droppable1").droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("disable"); + element.droppable( "disable" ); TestHelpers.droppable.shouldNotDrop(); - equal(el.droppable("option", "disabled"), true, "disabled option getter"); - el.droppable("destroy"); - el.droppable({ disabled: false }); + equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); + element.droppable( "destroy" ); + element.droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("option", "disabled", true); - equal(el.droppable("option", "disabled"), true, "disabled option setter"); + element.droppable( "option", "disabled", true ); + ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.droppable( "widget" ).hasClass( "ui-droppable-disabled" ), "element gets ui-droppable-disabled" ); + equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.droppable.shouldNotDrop(); - expected = $("
").droppable(), - actual = expected.droppable("disable"); - equal(actual, expected, "disable is chainable"); + expected = $( "
" ).droppable(); + actual = expected.droppable( "disable" ); + equal( actual, expected, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index cf7faf6af..004eacf90 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -7,6 +7,16 @@ test( "destroy", function() { }); }); +test( "disable", function() { + expect( 3 ); + + var element = $( "#progressbar" ).progressbar().progressbar( "disable" ); + + ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" ); + ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" ); +}); + test( "value", function() { expect( 3 ); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index b12f3035a..abb8951f9 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -3,10 +3,19 @@ */ (function($) { -module("resizable: methods"); +module( "resizable: methods" ); -// this is here to make JSHint pass "unused", and we don't want to -// remove the parameter for when we finally implement -$.noop(); +test( "disable", function() { + expect( 5 ); + + var element = $( "#resizable1" ).resizable({ disabled: false }), + chainable = element.resizable( "disable" ); + + ok( !element.resizable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.resizable( "widget" ).hasClass( "ui-resizable-disabled" ), "element gets ui-resizable-disabled" ); + equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); + equal( chainable, element, "disable is chainable" ); +}); })(jQuery); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index 72f9bb28d..179d4ecd6 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -71,34 +71,40 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(3); - var expected, actual, +test( "disable", function() { + expect( 6 ); + var chainable, fired = false, - el = $("#selectable1"); + element = $( "#selectable1" ); - el.selectable({ + element.selectable({ disabled: false, - start: function() { fired = true; } + start: function() { + fired = true; + } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, true, "start fired"); - el.selectable("disable"); + equal( fired, true, "start fired" ); + + chainable = element.selectable( "disable" ); fired = false; - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, false, "start fired"); - el.selectable("destroy"); + equal( fired, false, "start fired" ); - expected = $("
").selectable(); - actual = expected.selectable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" ); + + element.selectable( "destroy" ); + + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 75df230a6..bd9023133 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -49,7 +49,7 @@ test( "enable", function() { }); test( "disable", function() { - expect( 5 ); + expect( 6 ); var element, expected = $( "
" ).slider(), actual = expected.slider( "disable" ); @@ -61,6 +61,7 @@ test( "disable", function() { element.slider( "disable" ); ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); + ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" ); }); test( "value", function() { diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index 07a7bc77d..f3fe240e7 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -64,29 +64,30 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 9 ); - var el, actual, expected; + var chainable, + element = $( "#sortable" ).sortable({ disabled: false }); - el = $("#sortable").sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - el.sortable("disable"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter"); + chainable = element.sortable( "disable" ); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); - el.sortable("destroy"); + element.sortable( "destroy" ); - el.sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); - el.sortable("option", "disabled", true); - equal(el.sortable("option", "disabled"), true, "disabled option setter"); - ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)"); + element.sortable({ disabled: false }); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + element.sortable( "option", "disabled", true); + equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); - expected = $("
").sortable(), - actual = expected.sortable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" ); + + TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index af872f257..4f44a73ae 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -12,7 +12,7 @@ test( "destroy", function() { }); test( "disable", function() { - expect( 14 ); + expect( 16 ); var element = $( "#spin" ).val( 2 ).spinner(), wrapper = $( "#spin" ).spinner( "widget" ); @@ -21,6 +21,8 @@ test( "disable", function() { element.spinner( "disable" ); ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); + ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" ); + ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" ); ok( element.is( ":disabled"), "after: input has disabled attribute" ); simulateKeyDownUp( element, $.ui.keyCode.UP ); diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index c78c42b58..02a2fea34 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -144,24 +144,40 @@ test( "{ collapsible: true }", function() { }); test( "disabled", function() { - expect( 10 ); + expect( 22 ); // fully enabled by default var element = $( "#tabs1" ).tabs(); disabled( element, false ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable single tab element.tabs( "option", "disabled", [ 1 ] ); disabled( element, [ 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disabled active tab element.tabs( "option", "disabled", [ 0, 1 ] ); disabled( element, [ 0, 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable all tabs element.tabs( "option", "disabled", [ 0, 1, 2 ] ); disabled( element, true ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // enable all tabs element.tabs( "option", "disabled", [] ); disabled( element, false ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index c846d216c..a557ff943 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -54,7 +54,7 @@ test( "open/close with tracking", function() { }); test( "enable/disable", function() { - expect( 7 ); + expect( 10 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); @@ -66,6 +66,11 @@ test( "enable/disable", function() { element.tooltip( "disable" ); equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); + + ok( !element.tooltip( "widget" ).hasClass( "ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( !element.tooltip( "widget" ).hasClass( "ui-tooltip-disabled" ), "element doesn't get ui-tooltip-disabled" ); + // support: jQuery <1.6.2 // support: IE <8 // We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 1afa95cb4..da0d5751c 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -161,6 +161,9 @@ $.widget( "ui.accordion", { // #5332 - opacity doesn't cascade to positioned elements in IE // so we need to add the disabled class to the headers and panels if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); this.headers.add( this.headers.next() ) .toggleClass( "ui-state-disabled", !!value ); } diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index fcb7b14d1..5e64f5164 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -207,9 +207,6 @@ $.widget( "ui.button", { } } - // TODO: pull out $.Widget's handling for the disabled option into - // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can - // be overridden by individual plugins this._setOption( "disabled", options.disabled ); this._resetButton(); }, @@ -273,11 +270,8 @@ $.widget( "ui.button", { _setOption: function( key, value ) { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - } else { - this.element.prop( "disabled", false ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); return; } this._resetButton(); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 552b24a58..34342d33d 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -82,7 +82,7 @@ $.widget("ui.droppable", { return d.is(value); }; } - $.Widget.prototype._setOption.apply(this, arguments); + this._super( key, value ); }, _activate: function(event) { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 1c633786d..bdef93248 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -350,6 +350,11 @@ $.widget( "ui.menu", { .removeClass( this.options.icons.submenu ) .addClass( value.submenu ); } + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 9e959ebc4..0eaa8b41e 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -97,7 +97,11 @@ $.widget( "ui.progressbar", { // Don't allow a max less than min value = Math.max( this.min, value ); } - + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index b3e609aa2..88281240d 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -427,7 +427,11 @@ $.widget( "ui.slider", $.ui.mouse, { valsLength = this.options.values.length; } - $.Widget.prototype._setOption.apply( this, arguments ); + if ( key === "disabled" ) { + this.element.toggleClass( "ui-state-disabled", !!value ); + } + + this._super( key, value ); switch ( key ) { case "orientation": diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 0f9b113a4..99bc23bdb 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -102,17 +102,6 @@ $.widget("ui.sortable", $.ui.mouse, { return this; }, - _setOption: function(key, value){ - if ( key === "disabled" ) { - this.options[ key ] = value; - - this.widget().toggleClass( "ui-sortable-disabled", !!value ); - } else { - // Don't call widget base _setOption for disable as it adds ui-state-disabled class - $.Widget.prototype._setOption.apply(this, arguments); - } - }, - _mouseCapture: function(event, overrideHandle) { var currentItem = null, validHandle = false, diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 644b65239..c022413dc 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -381,13 +381,9 @@ $.widget( "ui.spinner", { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - this.buttons.button( "disable" ); - } else { - this.element.prop( "disabled", false ); - this.buttons.button( "enable" ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); + this.buttons.button( value ? "disable" : "enable" ); } }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index c581e4b81..adc4b9da1 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -345,8 +345,7 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); + .toggleClass( this.widgetFullName + "-disabled", !!value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); } -- cgit v1.2.3 From f87b4e0f4ac2342dff260c32aa8d08148e76f7a4 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 21 Dec 2012 18:26:56 +0100 Subject: Build: Migrate to grunt 0.4. Rename to Gruntfile, upgrade to newer grunt-css and grunt-html, update custom tasks. Drop qunit-junit plugin, not worth the trouble. Update release script to run grunt-prepare after npm-install. --- Gruntfile.js | 385 +++++++++++++++++++++++++++++++++++++++++++++++ build/release/release.js | 3 + build/tasks/build.js | 52 +++---- grunt.js | 345 ------------------------------------------ package.json | 17 ++- 5 files changed, 422 insertions(+), 380 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 grunt.js diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 000000000..06a1855a4 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,385 @@ +module.exports = function( grunt ) { + +"use strict"; + +var + // files + coreFiles = [ + "jquery.ui.core.js", + "jquery.ui.widget.js", + "jquery.ui.mouse.js", + "jquery.ui.draggable.js", + "jquery.ui.droppable.js", + "jquery.ui.resizable.js", + "jquery.ui.selectable.js", + "jquery.ui.sortable.js", + "jquery.ui.effect.js" + ], + + uiFiles = coreFiles.map(function( file ) { + return "ui/" + file; + }).concat( expandFiles( "ui/*.js" ).filter(function( file ) { + return coreFiles.indexOf( file.substring(3) ) === -1; + })), + + allI18nFiles = expandFiles( "ui/i18n/*.js" ), + + cssFiles = [ + "core", + "accordion", + "autocomplete", + "button", + "datepicker", + "dialog", + "menu", + "progressbar", + "resizable", + "selectable", + "slider", + "spinner", + "tabs", + "tooltip", + "theme" + ].map(function( component ) { + return "themes/base/jquery.ui." + component + ".css"; + }), + + // minified files + minify = { + options: { + preserveComments: false + }, + main: { + options: { + banner: createBanner( uiFiles ) + }, + files: { + "dist/jquery-ui.min.js": "dist/jquery-ui.js" + } + }, + i18n: { + options: { + banner: createBanner( allI18nFiles ) + }, + files: { + "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js" + } + } + }, + + minifyCSS = { + options: { + keepSpecialComments: 0 + }, + main: { + options: { + keepSpecialComments: '*' + }, + src: "dist/jquery-ui.css", + dest: "dist/jquery-ui.min.css" + } + }, + + compareFiles = { + files: [ + "dist/jquery-ui.js", + "dist/jquery-ui.min.js" + ] + }; + +function mapMinFile( file ) { + return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); +} + +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) { + return values[ 0 ]; + }); +} + +uiFiles.concat( allI18nFiles ).forEach(function( file ) { + minify[ file ] = { + options: { + banner: createBanner() + }, + files: {} + }; + minify[ file ].files[ mapMinFile( file ) ] = file; +}); + +cssFiles.forEach(function( file ) { + minifyCSS[ file ] = { + options: { + banner: createBanner() + }, + src: file, + dest: "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) + }; +}); + +uiFiles.forEach(function( file ) { + // TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13 + compareFiles[ file ] = [ file, mapMinFile( file ) ]; +}); + +// grunt plugins +grunt.loadNpmTasks( "grunt-contrib-jshint" ); +grunt.loadNpmTasks( "grunt-contrib-uglify" ); +grunt.loadNpmTasks( "grunt-contrib-concat" ); +grunt.loadNpmTasks( "grunt-contrib-qunit" ); +grunt.loadNpmTasks( "grunt-css" ); +grunt.loadNpmTasks( "grunt-html" ); +grunt.loadNpmTasks( "grunt-compare-size" ); +grunt.loadNpmTasks( "grunt-git-authors" ); +// local testswarm and build tasks +grunt.loadTasks( "build/tasks" ); + +function stripDirectory( file ) { + return file.replace( /.+\/(.+?)>?$/, "$1" ); +} + +function createBanner( files ) { + // strip folders + var fileNames = files && files.map( stripDirectory ); + return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + + "<%= grunt.template.today('isoDate') %>\n" + + "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" + + (files ? "* Includes: " + fileNames.join(", ") + "\n" : "")+ + "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n"; +} + +grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + files: { + dist: "<%= pkg.name %>-<%= pkg.version %>", + cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn", + themes: "<%= pkg.name %>-themes-<%= pkg.version %>" + }, + compare_size: compareFiles, + concat: { + ui: { + options: { + banner: createBanner( uiFiles ), + stripBanners: { + block: true + } + }, + src: uiFiles, + dest: "dist/jquery-ui.js" + }, + i18n: { + options: { + banner: createBanner( allI18nFiles ) + }, + src: allI18nFiles, + dest: "dist/i18n/jquery-ui-i18n.js" + }, + css: { + options: { + banner: createBanner( cssFiles ), + stripBanners: { + block: true + } + }, + src: cssFiles, + dest: "dist/jquery-ui.css" + } + }, + uglify: minify, + cssmin: minifyCSS, + htmllint: { + // ignore files that contain invalid html, used only for ajax content testing + all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { + return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); + }) + }, + copy: { + dist: { + src: [ + "AUTHORS.txt", + "jquery-*.js", + "MIT-LICENSE.txt", + "README.md", + "Gruntfile.js", + "package.json", + "*.jquery.json", + "ui/**/*", + "ui/.jshintrc", + "demos/**/*", + "themes/**/*", + "external/**/*", + "tests/**/*" + ], + renames: { + "dist/jquery-ui.js": "ui/jquery-ui.js", + "dist/jquery-ui.min.js": "ui/minified/jquery-ui.min.js", + "dist/i18n/jquery-ui-i18n.js": "ui/i18n/jquery-ui-i18n.js", + "dist/i18n/jquery-ui-i18n.min.js": "ui/minified/i18n/jquery-ui-i18n.min.js", + "dist/jquery-ui.css": "themes/base/jquery-ui.css", + "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + }, + dest: "dist/<%= files.dist %>" + }, + dist_min: { + src: "dist/minified/**/*", + strip: /^dist/, + dest: "dist/<%= files.dist %>/ui" + }, + dist_css_min: { + src: "dist/themes/base/minified/*.css", + strip: /^dist/, + dest: "dist/<%= files.dist %>" + }, + dist_units_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/" + }, + dist_min_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/<%= files.dist %>/themes/base/minified" + }, + cdn: { + src: [ + "AUTHORS.txt", + "MIT-LICENSE.txt", + "ui/*.js", + "package.json" + ], + renames: { + "dist/jquery-ui.js": "jquery-ui.js", + "dist/jquery-ui.min.js": "jquery-ui.min.js", + "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js", + "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js", + "dist/jquery-ui.css": "themes/base/jquery-ui.css", + "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + }, + dest: "dist/<%= files.cdn %>" + }, + cdn_i18n: { + src: "ui/i18n/jquery.ui.datepicker-*.js", + strip: "ui/", + dest: "dist/<%= files.cdn %>" + }, + cdn_i18n_min: { + src: "dist/minified/i18n/jquery.ui.datepicker-*.js", + strip: "dist/minified", + dest: "dist/<%= files.cdn %>" + }, + cdn_min: { + src: "dist/minified/*.js", + strip: /^dist\/minified/, + dest: "dist/<%= files.cdn %>/ui" + }, + cdn_min_images: { + src: "themes/base/images/*", + strip: /^themes\/base\//, + dest: "dist/<%= files.cdn %>/themes/base/minified" + }, + cdn_themes: { + src: "dist/<%= files.themes %>/themes/**/*", + strip: "dist/<%= files.themes %>", + dest: "dist/<%= files.cdn %>" + }, + themes: { + src: [ + "AUTHORS.txt", + "MIT-LICENSE.txt", + "package.json" + ], + dest: "dist/<%= files.themes %>" + } + }, + zip: { + dist: { + src: "<%= files.dist %>", + dest: "<%= files.dist %>.zip" + }, + cdn: { + src: "<%= files.cdn %>", + dest: "<%= files.cdn %>.zip" + }, + themes: { + src: "<%= files.themes %>", + dest: "<%= files.themes %>.zip" + } + }, + md5: { + dist: { + src: "dist/<%= files.dist %>", + dest: "dist/<%= files.dist %>/MANIFEST" + }, + cdn: { + src: "dist/<%= files.cdn %>", + dest: "dist/<%= files.cdn %>/MANIFEST" + }, + themes: { + src: "dist/<%= files.themes %>", + dest: "dist/<%= files.themes %>/MANIFEST" + } + }, + qunit: { + files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { + // disabling everything that doesn't (quite) work with PhantomJS for now + // TODO except for all|index|test, try to include more as we go + return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); + }) + }, + jshint: { + ui: { + options: { + jshintrc: "ui/.jshintrc" + }, + files: { + src: "ui/*.js" + } + }, + grunt: { + options: { + jshintrc: ".jshintrc" + }, + files: { + src: [ "Gruntfile.js", "build/**/*.js" ] + } + }, + tests: { + options: { + jshintrc: "tests/.jshintrc" + }, + files: { + src: "tests/unit/**/*.js" + } + } + }, + csslint: { + // nothing: [] + // TODO figure out what to check for, then fix and enable + base_theme: { + src: expandFiles( "themes/base/*.css" ).filter(function( file ) { + // TODO remove items from this list once rewritten + return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); + }), + // TODO consider reenabling some of these rules + rules: { + "adjoining-classes": false, + "import": false, + "outline-none": false, + // especially this one + "overqualified-elements": false, + "compatible-vendor-prefixes": false + } + } + } +}); + +grunt.registerTask( "default", [ "jshint", "csslint", "htmllint", "qunit" ] ); +grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] ); +grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] ); +grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] ); +grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist".split( " " ) ); +grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes".split( " " ) ); +grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn".split( " " ) ); + +}; diff --git a/build/release/release.js b/build/release/release.js index 2eab5283f..6a387494b 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -72,6 +72,9 @@ function cloneRepo() { if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) { abort( "Error installing dependencies." ); } + if ( exec( "cd node_modules/download.jqueryui.com && grunt prepare" ).code !== 0 ) { + abort( "Error installing dependencies." ); + } } echo(); } diff --git a/build/tasks/build.js b/build/tasks/build.js index a8f25f98f..978bee004 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -5,6 +5,19 @@ module.exports = function( grunt ) { var path = require( "path" ), fs = require( "fs" ); +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).filter(function(filepath) { + // restrict to files, exclude folders + try { + return fs.statSync( filepath[ 0 ] ).isFile(); + } catch(e) { + throw grunt.task.taskError(e.message, e); + } + }).map(function( values ) { + return values[ 0 ]; + }); +} + grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() { var pkg = grunt.config( "pkg" ), base = { @@ -97,8 +110,8 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ grunt.file.copy( src, dest ); } } - var files = grunt.file.expandFiles( this.file.src ), - target = this.file.dest + "/", + var files = expandFiles( this.filesSrc ), + target = this.data.dest + "/", strip = this.data.strip, renameCount = 0, fileName; @@ -121,28 +134,11 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { - // TODO switch back to adm-zip for better cross-platform compability once it actually works - // 0.1.3 works, but result can't be unzipped - // its also a lot slower then zip program, probably due to how its used... - // var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" ); - // grunt.log.writeln( "Creating zip file " + this.file.dest ); - - //var AdmZip = require( "adm-zip" ); - //var zip = new AdmZip(); - //files.forEach(function( file ) { - // grunt.verbose.writeln( "Zipping " + file ); - // // rewrite file names from dist folder (created by build), drop the /dist part - // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); - //}); - //zip.writeZip( "dist/" + this.file.dest ); - //grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); - var done = this.async(), - dest = this.file.dest, - src = grunt.template.process( this.file.src, grunt.config() ); - grunt.utils.spawn({ + dest = this.data.dest; + grunt.util.spawn({ cmd: "zip", - args: [ "-r", dest, src ], + args: [ "-r", dest, this.data.src ], opts: { cwd: 'dist' } @@ -159,19 +155,19 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included - if ( fs.existsSync( this.file.dest ) ) { - fs.unlinkSync( this.file.dest ); + if ( fs.existsSync( this.data.dest ) ) { + fs.unlinkSync( this.data.dest ); } var crypto = require( "crypto" ), - dir = this.file.src + "/", + dir = this.filesSrc + "/", hashes = []; - grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) { + expandFiles( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); hash.update( grunt.file.read( fileName, "ascii" ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); - grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); - grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); + grunt.file.write( this.data.dest, hashes.join( "\n" ) + "\n" ); + grunt.log.writeln( "Wrote " + this.data.dest + " with " + hashes.length + " hashes" ); }); grunt.registerTask( "generate_themes", function() { diff --git a/grunt.js b/grunt.js deleted file mode 100644 index d599496cc..000000000 --- a/grunt.js +++ /dev/null @@ -1,345 +0,0 @@ -module.exports = function( grunt ) { - -"use strict"; - -var - // files - coreFiles = [ - "jquery.ui.core.js", - "jquery.ui.widget.js", - "jquery.ui.mouse.js", - "jquery.ui.draggable.js", - "jquery.ui.droppable.js", - "jquery.ui.resizable.js", - "jquery.ui.selectable.js", - "jquery.ui.sortable.js", - "jquery.ui.effect.js" - ], - - uiFiles = coreFiles.map(function( file ) { - return "ui/" + file; - }).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { - return coreFiles.indexOf( file.substring(3) ) === -1; - })), - - allI18nFiles = grunt.file.expandFiles( "ui/i18n/*.js" ), - - cssFiles = [ - "core", - "accordion", - "autocomplete", - "button", - "datepicker", - "dialog", - "menu", - "progressbar", - "resizable", - "selectable", - "slider", - "spinner", - "tabs", - "tooltip", - "theme" - ].map(function( component ) { - return "themes/base/jquery.ui." + component + ".css"; - }), - - // minified files - minify = { - "dist/jquery-ui.min.js": [ "", "dist/jquery-ui.js" ], - "dist/i18n/jquery-ui-i18n.min.js": [ "", "dist/i18n/jquery-ui-i18n.js" ] - }, - - minifyCSS = { - "dist/jquery-ui.min.css": "dist/jquery-ui.css" - }, - - compareFiles = { - all: [ - "dist/jquery-ui.js", - "dist/jquery-ui.min.js" - ] - }; - -function mapMinFile( file ) { - return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); -} - -uiFiles.concat( allI18nFiles ).forEach(function( file ) { - minify[ mapMinFile( file ) ] = [ "", file ]; -}); - -cssFiles.forEach(function( file ) { - minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "", "" ]; -}); - -uiFiles.forEach(function( file ) { - compareFiles[ file ] = [ file, mapMinFile( file ) ]; -}); - -// grunt plugins -grunt.loadNpmTasks( "grunt-css" ); -grunt.loadNpmTasks( "grunt-html" ); -grunt.loadNpmTasks( "grunt-compare-size" ); -grunt.loadNpmTasks( "grunt-junit" ); -grunt.loadNpmTasks( "grunt-git-authors" ); -// local testswarm and build tasks -grunt.loadTasks( "build/tasks" ); - -grunt.registerHelper( "strip_all_banners", function( filepath ) { - return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); -}); - -function stripBanner( files ) { - return files.map(function( file ) { - return ""; - }); -} - -function stripDirectory( file ) { - // TODO: we're receiving the directive, so we need to strip the trailing > - // we should be receving a clean path without the directive - return file.replace( /.+\/(.+?)>?$/, "$1" ); -} -// allow access from banner template -global.stripDirectory = stripDirectory; - -function createBanner( files ) { - // strip folders - var fileNames = files && files.map( stripDirectory ); - return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + - "<%= grunt.template.today('isoDate') %>\n" + - "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" + - "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" + - "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + - " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; -} - -grunt.initConfig({ - pkg: "", - files: { - dist: "<%= pkg.name %>-<%= pkg.version %>", - cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn", - themes: "<%= pkg.name %>-themes-<%= pkg.version %>" - }, - meta: { - banner: createBanner(), - bannerAll: createBanner( uiFiles ), - bannerI18n: createBanner( allI18nFiles ), - bannerCSS: createBanner( cssFiles ) - }, - compare_size: compareFiles, - concat: { - ui: { - src: [ "", stripBanner( uiFiles ) ], - dest: "dist/jquery-ui.js" - }, - i18n: { - src: [ "", allI18nFiles ], - dest: "dist/i18n/jquery-ui-i18n.js" - }, - css: { - src: [ "", stripBanner( cssFiles ) ], - dest: "dist/jquery-ui.css" - } - }, - min: minify, - cssmin: minifyCSS, - htmllint: { - // ignore files that contain invalid html, used only for ajax content testing - all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { - return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); - }) - }, - copy: { - dist: { - src: [ - "AUTHORS.txt", - "jquery-*.js", - "MIT-LICENSE.txt", - "README.md", - "grunt.js", - "package.json", - "*.jquery.json", - "ui/**/*", - "ui/.jshintrc", - "demos/**/*", - "themes/**/*", - "external/**/*", - "tests/**/*" - ], - renames: { - "dist/jquery-ui.js": "ui/jquery-ui.js", - "dist/jquery-ui.min.js": "ui/minified/jquery-ui.min.js", - "dist/i18n/jquery-ui-i18n.js": "ui/i18n/jquery-ui-i18n.js", - "dist/i18n/jquery-ui-i18n.min.js": "ui/minified/i18n/jquery-ui-i18n.min.js", - "dist/jquery-ui.css": "themes/base/jquery-ui.css", - "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" - }, - dest: "dist/<%= files.dist %>" - }, - dist_min: { - src: "dist/minified/**/*", - strip: /^dist/, - dest: "dist/<%= files.dist %>/ui" - }, - dist_css_min: { - src: "dist/themes/base/minified/*.css", - strip: /^dist/, - dest: "dist/<%= files.dist %>" - }, - dist_units_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/" - }, - dist_min_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/<%= files.dist %>/themes/base/minified" - }, - cdn: { - src: [ - "AUTHORS.txt", - "MIT-LICENSE.txt", - "ui/*.js", - "package.json" - ], - renames: { - "dist/jquery-ui.js": "jquery-ui.js", - "dist/jquery-ui.min.js": "jquery-ui.min.js", - "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js", - "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js", - "dist/jquery-ui.css": "themes/base/jquery-ui.css", - "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" - }, - dest: "dist/<%= files.cdn %>" - }, - cdn_i18n: { - src: "ui/i18n/jquery.ui.datepicker-*.js", - strip: "ui/", - dest: "dist/<%= files.cdn %>" - }, - cdn_i18n_min: { - src: "dist/minified/i18n/jquery.ui.datepicker-*.js", - strip: "dist/minified", - dest: "dist/<%= files.cdn %>" - }, - cdn_min: { - src: "dist/minified/*.js", - strip: /^dist\/minified/, - dest: "dist/<%= files.cdn %>/ui" - }, - cdn_min_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/<%= files.cdn %>/themes/base/minified" - }, - cdn_themes: { - src: "dist/<%= files.themes %>/themes/**/*", - strip: "dist/<%= files.themes %>", - dest: "dist/<%= files.cdn %>" - }, - themes: { - src: [ - "AUTHORS.txt", - "MIT-LICENSE.txt", - "package.json" - ], - dest: "dist/<%= files.themes %>" - } - }, - zip: { - dist: { - src: "<%= files.dist %>", - dest: "<%= files.dist %>.zip" - }, - cdn: { - src: "<%= files.cdn %>", - dest: "<%= files.cdn %>.zip" - }, - themes: { - src: "<%= files.themes %>", - dest: "<%= files.themes %>.zip" - } - }, - md5: { - dist: { - src: "dist/<%= files.dist %>", - dest: "dist/<%= files.dist %>/MANIFEST" - }, - cdn: { - src: "dist/<%= files.cdn %>", - dest: "dist/<%= files.cdn %>/MANIFEST" - }, - themes: { - src: "dist/<%= files.themes %>", - dest: "dist/<%= files.themes %>/MANIFEST" - } - }, - qunit: { - files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { - // disabling everything that doesn't (quite) work with PhantomJS for now - // TODO except for all|index|test, try to include more as we go - return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); - }) - }, - lint: { - ui: "ui/*.js", - grunt: [ "grunt.js", "build/**/*.js" ], - tests: "tests/unit/**/*.js" - }, - csslint: { - // nothing: [] - // TODO figure out what to check for, then fix and enable - base_theme: { - src: grunt.file.expandFiles( "themes/base/*.css" ).filter(function( file ) { - // TODO remove items from this list once rewritten - return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); - }), - // TODO consider reenabling some of these rules - rules: { - "adjoining-classes": false, - "import": false, - "outline-none": false, - // especially this one - "overqualified-elements": false, - "compatible-vendor-prefixes": false - } - } - }, - jshint: (function() { - function parserc( path ) { - var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), - settings = { - options: rc, - globals: {} - }; - - (rc.predef || []).forEach(function( prop ) { - settings.globals[ prop ] = true; - }); - delete rc.predef; - - return settings; - } - - return { - grunt: parserc(), - ui: parserc( "ui/" ), - // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519 - // TODO: don't create so many globals in tests - tests: parserc( "tests/" ) - }; - })() -}); - -grunt.registerTask( "default", "lint csslint htmllint qunit" ); -grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" ); -grunt.registerTask( "sizer_all", "concat:ui min compare_size" ); -grunt.registerTask( "build", "concat min cssmin copy:dist_units_images" ); -grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); -grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes" ); -grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); - -}; diff --git a/package.json b/package.json index ae8b13dc8..89667bf34 100644 --- a/package.json +++ b/package.json @@ -53,13 +53,16 @@ ], "dependencies": {}, "devDependencies": { - "grunt": "~0.3.17", - "grunt-css": "0.2.0", - "grunt-compare-size": "0.1.4", - "grunt-html": "0.1.1", - "grunt-junit": "0.1.5", - "grunt-git-authors": "1.0.0", - "rimraf": "2.0.1", + "grunt": "0.4.0", + "grunt-contrib-jshint": "0.1.1", + "grunt-contrib-uglify": "0.1.1", + "grunt-contrib-concat": "0.1.3", + "grunt-contrib-qunit": "0.1.1", + "grunt-css": "0.5.4", + "grunt-compare-size": "0.3.1", + "grunt-html": "0.3.3", + "grunt-git-authors": "1.1.0", + "rimraf": "2.1.4", "testswarm": "1.0.0-alpha" }, "keywords": [] -- cgit v1.2.3 From bd211df0d35d7f326c338ce3f3fc81e5d966d3d7 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 11 Mar 2013 15:29:08 +0100 Subject: Build: Switch from grunt-css to the equivalent grunt-contrib tasks --- Gruntfile.js | 6 +++--- package.json | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 06a1855a4..96a93ded0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -127,7 +127,8 @@ grunt.loadNpmTasks( "grunt-contrib-jshint" ); grunt.loadNpmTasks( "grunt-contrib-uglify" ); grunt.loadNpmTasks( "grunt-contrib-concat" ); grunt.loadNpmTasks( "grunt-contrib-qunit" ); -grunt.loadNpmTasks( "grunt-css" ); +grunt.loadNpmTasks( "grunt-contrib-csslint" ); +grunt.loadNpmTasks( "grunt-contrib-cssmin" ); grunt.loadNpmTasks( "grunt-html" ); grunt.loadNpmTasks( "grunt-compare-size" ); grunt.loadNpmTasks( "grunt-git-authors" ); @@ -354,7 +355,6 @@ grunt.initConfig({ } }, csslint: { - // nothing: [] // TODO figure out what to check for, then fix and enable base_theme: { src: expandFiles( "themes/base/*.css" ).filter(function( file ) { @@ -362,7 +362,7 @@ grunt.initConfig({ return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); }), // TODO consider reenabling some of these rules - rules: { + options: { "adjoining-classes": false, "import": false, "outline-none": false, diff --git a/package.json b/package.json index 89667bf34..019e715bd 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "grunt-contrib-uglify": "0.1.1", "grunt-contrib-concat": "0.1.3", "grunt-contrib-qunit": "0.1.1", - "grunt-css": "0.5.4", + "grunt-contrib-csslint": "0.1.0", + "grunt-contrib-cssmin": "0.4.2", "grunt-compare-size": "0.3.1", "grunt-html": "0.3.3", "grunt-git-authors": "1.1.0", -- cgit v1.2.3 From ae3af7f0700ae035183a4f9d9a8c6752189abbe3 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 12 Mar 2013 11:00:21 +0100 Subject: Build: Don't call DB's grunt-prepare task, not needed anymore --- build/release/release.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/build/release/release.js b/build/release/release.js index 6a387494b..2eab5283f 100644 --- a/build/release/release.js +++ b/build/release/release.js @@ -72,9 +72,6 @@ function cloneRepo() { if ( exec( "npm install download.jqueryui.com" ).code !== 0 ) { abort( "Error installing dependencies." ); } - if ( exec( "cd node_modules/download.jqueryui.com && grunt prepare" ).code !== 0 ) { - abort( "Error installing dependencies." ); - } } echo(); } -- cgit v1.2.3 From e090a3655550c9cd20067952809f44b052064f4e Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 12 Mar 2013 13:53:18 +0100 Subject: Build: Update to grunt-contrib-qunit 0.2.0 to get latest PhantomJS --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 019e715bd..b30f98eaf 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "grunt-contrib-jshint": "0.1.1", "grunt-contrib-uglify": "0.1.1", "grunt-contrib-concat": "0.1.3", - "grunt-contrib-qunit": "0.1.1", + "grunt-contrib-qunit": "0.2.0", "grunt-contrib-csslint": "0.1.0", "grunt-contrib-cssmin": "0.4.2", "grunt-compare-size": "0.3.1", -- cgit v1.2.3 From 1dc5252de4147d392022b2481072316725cbae7d Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 12 Mar 2013 14:53:18 +0100 Subject: Build: Fix the key for the 'all' subtask for compare_size. Stills needs a new version of grunt-compare-size to actuall work --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 96a93ded0..57dcde8ab 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -81,7 +81,7 @@ var }, compareFiles = { - files: [ + all: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" ] -- cgit v1.2.3 From b280b8587e670036e1f8721e9ca3710ebad9d69b Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 12 Mar 2013 14:55:08 -0400 Subject: Upgrade to grunt-git-authors 1.2.0. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b30f98eaf..143b37cae 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "grunt-contrib-cssmin": "0.4.2", "grunt-compare-size": "0.3.1", "grunt-html": "0.3.3", - "grunt-git-authors": "1.1.0", + "grunt-git-authors": "1.2.0", "rimraf": "2.1.4", "testswarm": "1.0.0-alpha" }, -- cgit v1.2.3 From 787d512786db9bd05026ed09b034de6e544c483d Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 12 Mar 2013 14:55:33 -0400 Subject: Updated AUTHORS.txt. --- AUTHORS.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 2a7a396c8..35267040d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -236,3 +236,7 @@ Thomas Jaggi Vahid Sohrabloo Travis Carden Bruno M. Custódio +Nathanael Silverman +Christian Wenz +Steve Urmston +Zaven Muradyan -- cgit v1.2.3 From 5dca601bc6b396f2d722be1ab817126aa7e8a58c Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 13 Mar 2013 09:59:20 -0400 Subject: Updated mailmap. --- .mailmap | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- AUTHORS.txt | 4 +-- 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/.mailmap b/.mailmap index e130cc4bb..f83fbe970 100644 --- a/.mailmap +++ b/.mailmap @@ -1,6 +1,90 @@ +Aaron Peterson +Adam Baratz +Adam Sontag +Alexander Polomoshnov +Aliaksandr Rahalevich +Andrew Couch +Andrew Newcomb +Andrew Powell +Andrey Kapitcyn +Ben Hollis +Benjamin Scott Boyle +Bert ter Heide +Chairat Sunthornwiphat +Corey Frang +Courtland Allen +Dan Streetman +Diego Tres +Dominique Vincent +Doug Blood +Douglas Cerna +Douglas Neiner +Douglas Neiner +Dylan Just +Eddie Monge +Edward A Faulkner +Eric Hynds +Ethan Romba +EungJun Yi +Eyal Kobrigo +Filippo Cavallarin +Florian Gutmann +Genie <386@mail.com> +Guntupalli Karunakar +Hiroshi Tomita +Ian Simpson +Igor Milla +Israel Tsadok +Jacek Jędrzejewski +Jamie Gegerson +Jay Merrifield +John Enters +Jonathan Vingiano +Josh Varner +Justin Domnitz +Justin MacCarthy +Jörn Zaefferer +Karl Kirch +Kevin Dalman +Klaus Hartl carhartl Kris Borchers Kris Borchers -Corey Frang +Krzysztof Rosiński +Lev Kitsis Maggie Costello Wachs maggiewachs +Marc Neuwirth +Marcos Sousa +Martin Frost +Mathias Stenbom +Matthew Edward Hutton +Max Schnur +Michael Hollis +Michael Stay +Michael Wu +Mike Alsup +Milan Broum +Mohamed Cherif Bouchelaghem +Paul Irish +Pavol Hluchý +Peter Heiberg +Petr Hromadko +Phillip Barnes +Pierre-Henri Ausseil +Raymond Schwartz Richard Worth -Jörn Zaefferer +Rick Waldron +Ryan Neufeld +Ryan Olton +Saji Nediyanchath Saji +Sebastian Sauer +Sergey Kartashov +Shahyar Ghobadpour +Shane Whittet +Shannon Pekary +Simon Sattes +Stojce Slavkovski +Tarafder Ashek-E-Elahi +Thibault Duplessis +Ting Kuei +Wesley Walser +Xavi Ramirez diff --git a/AUTHORS.txt b/AUTHORS.txt index 35267040d..756e9daa5 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -168,7 +168,7 @@ Genie <386@mail.com> Rick Waldron Ian Simpson Lev Kitsis -Ted VanToll +TJ VanToll Justin Domnitz Douglas Cerna Bert ter Heide @@ -216,8 +216,8 @@ Marc-Andre Lafortune Nate Eagle David Souther Mathias Stenbom -Avinash R Sergey Kartashov +Avinash R Ethan Romba Cory Gackenheimer Juan Pablo Kaniefsky -- cgit v1.2.3 From 054449e214449ec5578fe71bb67b9a670adac828 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 12 Mar 2013 22:44:43 -0400 Subject: Sortable: Only animate along the specified axis when reverting. Fixes #7415 - Sortable: Incorrect revert animation with axis: 'y'. --- ui/jquery.ui.sortable.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 99bc23bdb..642d5d947 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -417,14 +417,18 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.options.revert) { var that = this, - cur = this.placeholder.offset(); + cur = this.placeholder.offset(), + axis = this.options.axis, + animation = {}; + if ( !axis || axis === "x" ) { + animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); + } + if ( !axis || axis === "y" ) { + animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); + } this.reverting = true; - - $(this.helper).animate({ - left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft), - top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop) - }, parseInt(this.options.revert, 10) || 500, function() { + $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { that._clear(event); }); } else { -- cgit v1.2.3 From 38fce3f30478bcfce8ea837d850f63b5560d605a Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Thu, 14 Mar 2013 15:33:29 -0300 Subject: Grunt: remove base theme from release cdn --- Gruntfile.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 57dcde8ab..ff64f0c0d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -253,9 +253,7 @@ grunt.initConfig({ "dist/jquery-ui.js": "jquery-ui.js", "dist/jquery-ui.min.js": "jquery-ui.min.js", "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js", - "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js", - "dist/jquery-ui.css": "themes/base/jquery-ui.css", - "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js" }, dest: "dist/<%= files.cdn %>" }, @@ -274,11 +272,6 @@ grunt.initConfig({ strip: /^dist\/minified/, dest: "dist/<%= files.cdn %>/ui" }, - cdn_min_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/<%= files.cdn %>/themes/base/minified" - }, cdn_themes: { src: "dist/<%= files.themes %>/themes/**/*", strip: "dist/<%= files.themes %>", @@ -380,6 +373,6 @@ grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] ); grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] ); grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist".split( " " ) ); grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes".split( " " ) ); -grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn".split( " " ) ); +grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_themes md5:cdn zip:cdn".split( " " ) ); }; -- cgit v1.2.3 From 23771d38ba9d2663f6db0243c8e992dc7ff6844a Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 14 Mar 2013 15:07:06 -0400 Subject: Revert "Widget: Stop setting ui-state-disabled and aria by default on setting disabled option." This needs to wait for a major release. This reverts commit 4d67f4f34908a50ef88f95df4103ee001b777e45. --- tests/unit/accordion/accordion_methods.js | 7 +---- tests/unit/autocomplete/autocomplete_options.js | 11 +++----- tests/unit/button/button_options.js | 29 ++++++++------------ tests/unit/dialog/dialog_methods.js | 4 +-- tests/unit/draggable/draggable_methods.js | 14 ++++------ tests/unit/droppable/droppable_methods.js | 29 +++++++++----------- tests/unit/progressbar/progressbar_methods.js | 10 ------- tests/unit/resizable/resizable_methods.js | 17 +++--------- tests/unit/selectable/selectable_methods.js | 36 +++++++++++-------------- tests/unit/slider/slider_methods.js | 3 +-- tests/unit/sortable/sortable_methods.js | 35 ++++++++++++------------ tests/unit/spinner/spinner_methods.js | 4 +-- tests/unit/tabs/tabs_options.js | 18 +------------ tests/unit/tooltip/tooltip_methods.js | 7 +---- ui/jquery.ui.accordion.js | 3 --- ui/jquery.ui.button.js | 10 +++++-- ui/jquery.ui.droppable.js | 2 +- ui/jquery.ui.menu.js | 5 ---- ui/jquery.ui.progressbar.js | 6 +---- ui/jquery.ui.slider.js | 6 +---- ui/jquery.ui.sortable.js | 11 ++++++++ ui/jquery.ui.spinner.js | 10 ++++--- ui/jquery.ui.widget.js | 3 ++- 23 files changed, 106 insertions(+), 174 deletions(-) diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 7612479f7..b1123b828 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -14,15 +14,10 @@ test( "destroy", function() { }); test( "enable/disable", function() { - expect( 7 ); + expect( 4 ); var element = $( "#list1" ).accordion(); state( element, 1, 0, 0 ); element.accordion( "disable" ); - - ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); - equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); - ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" ); - // event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); state( element, 1, 0, 0 ); diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index c98f2c28e..9f0bd2d43 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -88,20 +88,17 @@ asyncTest( "delay", function() { }); asyncTest( "disabled", function() { - expect( 5 ); + expect( 2 ); var element = $( "#autocomplete" ).autocomplete({ source: data, - delay: 0 + delay: 0, + disabled: true }), - menu = element.autocomplete( "disable" ).autocomplete( "widget" ); + menu = element.autocomplete( "widget" ); element.val( "ja" ).keydown(); ok( menu.is( ":hidden" ) ); - ok( !element.is( ".ui-state-disabled" ), "element doesn't get ui-state-disabled" ); - ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" ); - ok( menu.is( ".ui-autocomplete-disabled" ), "element gets ui-autocomplete-disabled" ); - setTimeout(function() { ok( menu.is( ":hidden" ) ); start(); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index 124a8699f..e1931a54e 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -3,26 +3,19 @@ */ (function($) { -module( "button: options" ); +module("button: options"); -test( "disabled, explicit value", function() { - expect( 9 ); - - var element = $( "#radio01" ).button({ disabled: false }); - deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); - deepEqual( element.prop( "disabled" ), false, "element is disabled" ); - - ok( !element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); - ok( !element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); - - element = $( "#radio02" ).button({ disabled: true }); - - ok( element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); - ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); +test("disabled, explicit value", function() { + expect( 4 ); + $("#radio01").button({ disabled: false }); + deepEqual(false, $("#radio01").button("option", "disabled"), + "disabled option set to false"); + deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); - deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); - deepEqual( element.prop( "disabled" ), true, "element is not disabled" ); + $("#radio02").button({ disabled: true }); + deepEqual(true, $("#radio02").button("option", "disabled"), + "disabled option set to true"); + deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); }); test("disabled, null", function() { diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 2bb06ab46..6de185513 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -101,13 +101,11 @@ test("#4980: Destroy should place element back in original DOM position", functi }); test( "enable/disable disabled", function() { - expect( 4 ); + expect( 2 ); var element = $( "
" ).dialog(); element.dialog( "disable" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); - ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" ); - ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" ); }); test("close", function() { diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 63a19e26d..901c261d6 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -74,16 +74,16 @@ test( "enable", function() { }); test( "disable", function() { - expect( 10 ); + expect( 7 ); - element = $( "#draggable2" ).draggable({ disabled: false }); + element = $("#draggable2").draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - element.draggable( "disable" ); + element.draggable("disable"); TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); - element.draggable( "destroy" ); + element.draggable("destroy"); element.draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); @@ -91,12 +91,8 @@ test( "disable", function() { equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" ); - ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); - ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" ); - var expected = element.draggable(), - actual = expected.draggable( "disable" ); + actual = expected.draggable("disable"); equal( actual, expected, "disable is chainable" ); }); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index f7682d262..2b452a63d 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -63,29 +63,26 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test( "disable", function() { - expect( 10 ); +test("disable", function() { + expect(7); - var actual, expected, - element = $( "#droppable1" ).droppable({ disabled: false }); + var el, actual, expected; + el = $("#droppable1").droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - element.droppable( "disable" ); + el.droppable("disable"); TestHelpers.droppable.shouldNotDrop(); - equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); - element.droppable( "destroy" ); - element.droppable({ disabled: false }); + equal(el.droppable("option", "disabled"), true, "disabled option getter"); + el.droppable("destroy"); + el.droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - element.droppable( "option", "disabled", true ); - ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); - ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.droppable( "widget" ).hasClass( "ui-droppable-disabled" ), "element gets ui-droppable-disabled" ); - equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); + el.droppable("option", "disabled", true); + equal(el.droppable("option", "disabled"), true, "disabled option setter"); TestHelpers.droppable.shouldNotDrop(); - expected = $( "
" ).droppable(); - actual = expected.droppable( "disable" ); - equal( actual, expected, "disable is chainable" ); + expected = $("
").droppable(), + actual = expected.droppable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index 004eacf90..cf7faf6af 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -7,16 +7,6 @@ test( "destroy", function() { }); }); -test( "disable", function() { - expect( 3 ); - - var element = $( "#progressbar" ).progressbar().progressbar( "disable" ); - - ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); - ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" ); - ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" ); -}); - test( "value", function() { expect( 3 ); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index abb8951f9..b12f3035a 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -3,19 +3,10 @@ */ (function($) { -module( "resizable: methods" ); +module("resizable: methods"); -test( "disable", function() { - expect( 5 ); - - var element = $( "#resizable1" ).resizable({ disabled: false }), - chainable = element.resizable( "disable" ); - - ok( !element.resizable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); - ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.resizable( "widget" ).hasClass( "ui-resizable-disabled" ), "element gets ui-resizable-disabled" ); - equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); - equal( chainable, element, "disable is chainable" ); -}); +// this is here to make JSHint pass "unused", and we don't want to +// remove the parameter for when we finally implement +$.noop(); })(jQuery); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index 179d4ecd6..72f9bb28d 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -71,40 +71,34 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test( "disable", function() { - expect( 6 ); - var chainable, +test("disable", function() { + expect(3); + var expected, actual, fired = false, - element = $( "#selectable1" ); + el = $("#selectable1"); - element.selectable({ + el.selectable({ disabled: false, - start: function() { - fired = true; - } + start: function() { fired = true; } }); - element.simulate( "drag", { + el.simulate( "drag", { dx: 20, dy: 20 }); - equal( fired, true, "start fired" ); - - chainable = element.selectable( "disable" ); + equal(fired, true, "start fired"); + el.selectable("disable"); fired = false; - element.simulate( "drag", { + el.simulate( "drag", { dx: 20, dy: 20 }); - equal( fired, false, "start fired" ); - - ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); - ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" ); - - element.selectable( "destroy" ); + equal(fired, false, "start fired"); + el.selectable("destroy"); - equal( chainable, element, "disable is chainable" ); + expected = $("
").selectable(); + actual = expected.selectable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index bd9023133..75df230a6 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -49,7 +49,7 @@ test( "enable", function() { }); test( "disable", function() { - expect( 6 ); + expect( 5 ); var element, expected = $( "
" ).slider(), actual = expected.slider( "disable" ); @@ -61,7 +61,6 @@ test( "disable", function() { element.slider( "disable" ); ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); - ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" ); }); test( "value", function() { diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index f3fe240e7..07a7bc77d 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -64,30 +64,29 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test( "disable", function() { - expect( 9 ); +test("disable", function() { + expect(7); - var chainable, - element = $( "#sortable" ).sortable({ disabled: false }); - - TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + var el, actual, expected; - chainable = element.sortable( "disable" ); - TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); + el = $("#sortable").sortable({ disabled: false }); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); - element.sortable( "destroy" ); + el.sortable("disable"); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter"); - element.sortable({ disabled: false }); - TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - element.sortable( "option", "disabled", true); - equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); + el.sortable("destroy"); - ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); - ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); - ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" ); + el.sortable({ disabled: false }); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); + el.sortable("option", "disabled", true); + equal(el.sortable("option", "disabled"), true, "disabled option setter"); + ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); + TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)"); - TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); - equal( chainable, element, "disable is chainable" ); + expected = $("
").sortable(), + actual = expected.sortable("disable"); + equal(actual, expected, "disable is chainable"); }); })(jQuery); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index 4f44a73ae..af872f257 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -12,7 +12,7 @@ test( "destroy", function() { }); test( "disable", function() { - expect( 16 ); + expect( 14 ); var element = $( "#spin" ).val( 2 ).spinner(), wrapper = $( "#spin" ).spinner( "widget" ); @@ -21,8 +21,6 @@ test( "disable", function() { element.spinner( "disable" ); ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); - ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" ); - ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" ); ok( element.is( ":disabled"), "after: input has disabled attribute" ); simulateKeyDownUp( element, $.ui.keyCode.UP ); diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index 02a2fea34..c78c42b58 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -144,40 +144,24 @@ test( "{ collapsible: true }", function() { }); test( "disabled", function() { - expect( 22 ); + expect( 10 ); // fully enabled by default var element = $( "#tabs1" ).tabs(); disabled( element, false ); - ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); - ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); - ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disable single tab element.tabs( "option", "disabled", [ 1 ] ); disabled( element, [ 1 ] ); - ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); - ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); - ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disabled active tab element.tabs( "option", "disabled", [ 0, 1 ] ); disabled( element, [ 0, 1 ] ); - ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); - ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); - ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // disable all tabs element.tabs( "option", "disabled", [ 0, 1, 2 ] ); disabled( element, true ); - ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); - ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); - ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); - // enable all tabs element.tabs( "option", "disabled", [] ); disabled( element, false ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index a557ff943..c846d216c 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -54,7 +54,7 @@ test( "open/close with tracking", function() { }); test( "enable/disable", function() { - expect( 10 ); + expect( 7 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); @@ -66,11 +66,6 @@ test( "enable/disable", function() { element.tooltip( "disable" ); equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); - - ok( !element.tooltip( "widget" ).hasClass( "ui-state-disabled" ), "element doesn't get ui-state-disabled" ); - ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); - ok( !element.tooltip( "widget" ).hasClass( "ui-tooltip-disabled" ), "element doesn't get ui-tooltip-disabled" ); - // support: jQuery <1.6.2 // support: IE <8 // We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index da0d5751c..1afa95cb4 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -161,9 +161,6 @@ $.widget( "ui.accordion", { // #5332 - opacity doesn't cascade to positioned elements in IE // so we need to add the disabled class to the headers and panels if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); this.headers.add( this.headers.next() ) .toggleClass( "ui-state-disabled", !!value ); } diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 5e64f5164..fcb7b14d1 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -207,6 +207,9 @@ $.widget( "ui.button", { } } + // TODO: pull out $.Widget's handling for the disabled option into + // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can + // be overridden by individual plugins this._setOption( "disabled", options.disabled ); this._resetButton(); }, @@ -270,8 +273,11 @@ $.widget( "ui.button", { _setOption: function( key, value ) { this._super( key, value ); if ( key === "disabled" ) { - this.widget().toggleClass( "ui-state-disabled", !!value ); - this.element.prop( "disabled", !!value ); + if ( value ) { + this.element.prop( "disabled", true ); + } else { + this.element.prop( "disabled", false ); + } return; } this._resetButton(); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 34342d33d..552b24a58 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -82,7 +82,7 @@ $.widget("ui.droppable", { return d.is(value); }; } - this._super( key, value ); + $.Widget.prototype._setOption.apply(this, arguments); }, _activate: function(event) { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index bdef93248..1c633786d 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -350,11 +350,6 @@ $.widget( "ui.menu", { .removeClass( this.options.icons.submenu ) .addClass( value.submenu ); } - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - } this._super( key, value ); }, diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 0eaa8b41e..9e959ebc4 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -97,11 +97,7 @@ $.widget( "ui.progressbar", { // Don't allow a max less than min value = Math.max( this.min, value ); } - if ( key === "disabled" ) { - this.element - .toggleClass( "ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); - } + this._super( key, value ); }, diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 88281240d..b3e609aa2 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -427,11 +427,7 @@ $.widget( "ui.slider", $.ui.mouse, { valsLength = this.options.values.length; } - if ( key === "disabled" ) { - this.element.toggleClass( "ui-state-disabled", !!value ); - } - - this._super( key, value ); + $.Widget.prototype._setOption.apply( this, arguments ); switch ( key ) { case "orientation": diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 642d5d947..efc83f3d5 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -102,6 +102,17 @@ $.widget("ui.sortable", $.ui.mouse, { return this; }, + _setOption: function(key, value){ + if ( key === "disabled" ) { + this.options[ key ] = value; + + this.widget().toggleClass( "ui-sortable-disabled", !!value ); + } else { + // Don't call widget base _setOption for disable as it adds ui-state-disabled class + $.Widget.prototype._setOption.apply(this, arguments); + } + }, + _mouseCapture: function(event, overrideHandle) { var currentItem = null, validHandle = false, diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index c022413dc..644b65239 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -381,9 +381,13 @@ $.widget( "ui.spinner", { this._super( key, value ); if ( key === "disabled" ) { - this.widget().toggleClass( "ui-state-disabled", !!value ); - this.element.prop( "disabled", !!value ); - this.buttons.button( value ? "disable" : "enable" ); + if ( value ) { + this.element.prop( "disabled", true ); + this.buttons.button( "disable" ); + } else { + this.element.prop( "disabled", false ); + this.buttons.button( "enable" ); + } } }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index adc4b9da1..c581e4b81 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -345,7 +345,8 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - .toggleClass( this.widgetFullName + "-disabled", !!value ); + .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); } -- cgit v1.2.3 From db27541b3ccc8af8c558915d99bcf544d4afacc7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 14 Mar 2013 12:23:06 -0700 Subject: Updating the master version to 1.10.3pre. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 143b37cae..5a2250595 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-ui", "title": "jQuery UI", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.", - "version": "1.10.2pre", + "version": "1.10.3pre", "homepage": "http://jqueryui.com", "author": { "name": "jQuery Foundation and other contributors", -- cgit v1.2.3 From 44d07173db32b498e5f83f60db290ff1463daee3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 14 Mar 2013 19:08:21 -0400 Subject: Widget: Stop setting ui-state-disabled and aria by default on setting disabled option. Fixes #5973 - Resizable: disabled should not have the ui-state-disabled class or aria attribute aria-disabled Fixes #5974 - Draggable: disabled should not have the ui-state-disabled class or aria attribute aria-disabled Fixes #6039 - Droppable: disabled should not have ui-state-disabled This reverts commit 23771d38ba9d2663f6db0243c8e992dc7ff6844a. --- tests/unit/accordion/accordion_methods.js | 7 ++++- tests/unit/autocomplete/autocomplete_options.js | 11 +++++--- tests/unit/button/button_options.js | 29 ++++++++++++-------- tests/unit/dialog/dialog_methods.js | 4 ++- tests/unit/draggable/draggable_methods.js | 14 ++++++---- tests/unit/droppable/droppable_methods.js | 29 +++++++++++--------- tests/unit/progressbar/progressbar_methods.js | 10 +++++++ tests/unit/resizable/resizable_methods.js | 17 +++++++++--- tests/unit/selectable/selectable_methods.js | 36 ++++++++++++++----------- tests/unit/slider/slider_methods.js | 3 ++- tests/unit/sortable/sortable_methods.js | 35 ++++++++++++------------ tests/unit/spinner/spinner_methods.js | 4 ++- tests/unit/tabs/tabs_options.js | 18 ++++++++++++- tests/unit/tooltip/tooltip_methods.js | 7 ++++- ui/jquery.ui.accordion.js | 3 +++ ui/jquery.ui.button.js | 10 ++----- ui/jquery.ui.droppable.js | 2 +- ui/jquery.ui.menu.js | 5 ++++ ui/jquery.ui.progressbar.js | 6 ++++- ui/jquery.ui.slider.js | 6 ++++- ui/jquery.ui.sortable.js | 11 -------- ui/jquery.ui.spinner.js | 10 +++---- ui/jquery.ui.widget.js | 3 +-- 23 files changed, 174 insertions(+), 106 deletions(-) diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index b1123b828..7612479f7 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -14,10 +14,15 @@ test( "destroy", function() { }); test( "enable/disable", function() { - expect( 4 ); + expect( 7 ); var element = $( "#list1" ).accordion(); state( element, 1, 0, 0 ); element.accordion( "disable" ); + + ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); + ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" ); + // event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); state( element, 1, 0, 0 ); diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 9f0bd2d43..c98f2c28e 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -88,17 +88,20 @@ asyncTest( "delay", function() { }); asyncTest( "disabled", function() { - expect( 2 ); + expect( 5 ); var element = $( "#autocomplete" ).autocomplete({ source: data, - delay: 0, - disabled: true + delay: 0 }), - menu = element.autocomplete( "widget" ); + menu = element.autocomplete( "disable" ).autocomplete( "widget" ); element.val( "ja" ).keydown(); ok( menu.is( ":hidden" ) ); + ok( !element.is( ".ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( menu.is( ".ui-autocomplete-disabled" ), "element gets ui-autocomplete-disabled" ); + setTimeout(function() { ok( menu.is( ":hidden" ) ); start(); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index e1931a54e..124a8699f 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -3,19 +3,26 @@ */ (function($) { -module("button: options"); +module( "button: options" ); -test("disabled, explicit value", function() { - expect( 4 ); - $("#radio01").button({ disabled: false }); - deepEqual(false, $("#radio01").button("option", "disabled"), - "disabled option set to false"); - deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); +test( "disabled, explicit value", function() { + expect( 9 ); - $("#radio02").button({ disabled: true }); - deepEqual(true, $("#radio02").button("option", "disabled"), - "disabled option set to true"); - deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); + var element = $( "#radio01" ).button({ disabled: false }); + deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); + deepEqual( element.prop( "disabled" ), false, "element is disabled" ); + + ok( !element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + element = $( "#radio02" ).button({ disabled: true }); + + ok( element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); + deepEqual( element.prop( "disabled" ), true, "element is not disabled" ); }); test("disabled, null", function() { diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 6de185513..2bb06ab46 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -101,11 +101,13 @@ test("#4980: Destroy should place element back in original DOM position", functi }); test( "enable/disable disabled", function() { - expect( 2 ); + expect( 4 ); var element = $( "
" ).dialog(); element.dialog( "disable" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); + ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" ); + ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" ); }); test("close", function() { diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 901c261d6..63a19e26d 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -74,16 +74,16 @@ test( "enable", function() { }); test( "disable", function() { - expect( 7 ); + expect( 10 ); - element = $("#draggable2").draggable({ disabled: false }); + element = $( "#draggable2" ).draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - element.draggable("disable"); + element.draggable( "disable" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); - element.draggable("destroy"); + element.draggable( "destroy" ); element.draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); @@ -91,8 +91,12 @@ test( "disable", function() { equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" ); + ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" ); + var expected = element.draggable(), - actual = expected.draggable("disable"); + actual = expected.draggable( "disable" ); equal( actual, expected, "disable is chainable" ); }); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index 2b452a63d..f7682d262 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -63,26 +63,29 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 10 ); - var el, actual, expected; + var actual, expected, + element = $( "#droppable1" ).droppable({ disabled: false }); - el = $("#droppable1").droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("disable"); + element.droppable( "disable" ); TestHelpers.droppable.shouldNotDrop(); - equal(el.droppable("option", "disabled"), true, "disabled option getter"); - el.droppable("destroy"); - el.droppable({ disabled: false }); + equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); + element.droppable( "destroy" ); + element.droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("option", "disabled", true); - equal(el.droppable("option", "disabled"), true, "disabled option setter"); + element.droppable( "option", "disabled", true ); + ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.droppable( "widget" ).hasClass( "ui-droppable-disabled" ), "element gets ui-droppable-disabled" ); + equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.droppable.shouldNotDrop(); - expected = $("
").droppable(), - actual = expected.droppable("disable"); - equal(actual, expected, "disable is chainable"); + expected = $( "
" ).droppable(); + actual = expected.droppable( "disable" ); + equal( actual, expected, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index cf7faf6af..004eacf90 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -7,6 +7,16 @@ test( "destroy", function() { }); }); +test( "disable", function() { + expect( 3 ); + + var element = $( "#progressbar" ).progressbar().progressbar( "disable" ); + + ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" ); + ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" ); +}); + test( "value", function() { expect( 3 ); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index b12f3035a..abb8951f9 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -3,10 +3,19 @@ */ (function($) { -module("resizable: methods"); +module( "resizable: methods" ); -// this is here to make JSHint pass "unused", and we don't want to -// remove the parameter for when we finally implement -$.noop(); +test( "disable", function() { + expect( 5 ); + + var element = $( "#resizable1" ).resizable({ disabled: false }), + chainable = element.resizable( "disable" ); + + ok( !element.resizable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.resizable( "widget" ).hasClass( "ui-resizable-disabled" ), "element gets ui-resizable-disabled" ); + equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); + equal( chainable, element, "disable is chainable" ); +}); })(jQuery); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index 72f9bb28d..179d4ecd6 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -71,34 +71,40 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(3); - var expected, actual, +test( "disable", function() { + expect( 6 ); + var chainable, fired = false, - el = $("#selectable1"); + element = $( "#selectable1" ); - el.selectable({ + element.selectable({ disabled: false, - start: function() { fired = true; } + start: function() { + fired = true; + } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, true, "start fired"); - el.selectable("disable"); + equal( fired, true, "start fired" ); + + chainable = element.selectable( "disable" ); fired = false; - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, false, "start fired"); - el.selectable("destroy"); + equal( fired, false, "start fired" ); - expected = $("
").selectable(); - actual = expected.selectable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" ); + + element.selectable( "destroy" ); + + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 75df230a6..bd9023133 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -49,7 +49,7 @@ test( "enable", function() { }); test( "disable", function() { - expect( 5 ); + expect( 6 ); var element, expected = $( "
" ).slider(), actual = expected.slider( "disable" ); @@ -61,6 +61,7 @@ test( "disable", function() { element.slider( "disable" ); ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); + ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" ); }); test( "value", function() { diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index 07a7bc77d..f3fe240e7 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -64,29 +64,30 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 9 ); - var el, actual, expected; + var chainable, + element = $( "#sortable" ).sortable({ disabled: false }); - el = $("#sortable").sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - el.sortable("disable"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter"); + chainable = element.sortable( "disable" ); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); - el.sortable("destroy"); + element.sortable( "destroy" ); - el.sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); - el.sortable("option", "disabled", true); - equal(el.sortable("option", "disabled"), true, "disabled option setter"); - ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)"); + element.sortable({ disabled: false }); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + element.sortable( "option", "disabled", true); + equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); - expected = $("
").sortable(), - actual = expected.sortable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" ); + + TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index af872f257..4f44a73ae 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -12,7 +12,7 @@ test( "destroy", function() { }); test( "disable", function() { - expect( 14 ); + expect( 16 ); var element = $( "#spin" ).val( 2 ).spinner(), wrapper = $( "#spin" ).spinner( "widget" ); @@ -21,6 +21,8 @@ test( "disable", function() { element.spinner( "disable" ); ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); + ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" ); + ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" ); ok( element.is( ":disabled"), "after: input has disabled attribute" ); simulateKeyDownUp( element, $.ui.keyCode.UP ); diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index c78c42b58..02a2fea34 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -144,24 +144,40 @@ test( "{ collapsible: true }", function() { }); test( "disabled", function() { - expect( 10 ); + expect( 22 ); // fully enabled by default var element = $( "#tabs1" ).tabs(); disabled( element, false ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable single tab element.tabs( "option", "disabled", [ 1 ] ); disabled( element, [ 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disabled active tab element.tabs( "option", "disabled", [ 0, 1 ] ); disabled( element, [ 0, 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable all tabs element.tabs( "option", "disabled", [ 0, 1, 2 ] ); disabled( element, true ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // enable all tabs element.tabs( "option", "disabled", [] ); disabled( element, false ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index c846d216c..a557ff943 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -54,7 +54,7 @@ test( "open/close with tracking", function() { }); test( "enable/disable", function() { - expect( 7 ); + expect( 10 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); @@ -66,6 +66,11 @@ test( "enable/disable", function() { element.tooltip( "disable" ); equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); + + ok( !element.tooltip( "widget" ).hasClass( "ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( !element.tooltip( "widget" ).hasClass( "ui-tooltip-disabled" ), "element doesn't get ui-tooltip-disabled" ); + // support: jQuery <1.6.2 // support: IE <8 // We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 1afa95cb4..da0d5751c 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -161,6 +161,9 @@ $.widget( "ui.accordion", { // #5332 - opacity doesn't cascade to positioned elements in IE // so we need to add the disabled class to the headers and panels if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); this.headers.add( this.headers.next() ) .toggleClass( "ui-state-disabled", !!value ); } diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index fcb7b14d1..5e64f5164 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -207,9 +207,6 @@ $.widget( "ui.button", { } } - // TODO: pull out $.Widget's handling for the disabled option into - // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can - // be overridden by individual plugins this._setOption( "disabled", options.disabled ); this._resetButton(); }, @@ -273,11 +270,8 @@ $.widget( "ui.button", { _setOption: function( key, value ) { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - } else { - this.element.prop( "disabled", false ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); return; } this._resetButton(); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 552b24a58..34342d33d 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -82,7 +82,7 @@ $.widget("ui.droppable", { return d.is(value); }; } - $.Widget.prototype._setOption.apply(this, arguments); + this._super( key, value ); }, _activate: function(event) { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 1c633786d..bdef93248 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -350,6 +350,11 @@ $.widget( "ui.menu", { .removeClass( this.options.icons.submenu ) .addClass( value.submenu ); } + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 9e959ebc4..0eaa8b41e 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -97,7 +97,11 @@ $.widget( "ui.progressbar", { // Don't allow a max less than min value = Math.max( this.min, value ); } - + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index b3e609aa2..88281240d 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -427,7 +427,11 @@ $.widget( "ui.slider", $.ui.mouse, { valsLength = this.options.values.length; } - $.Widget.prototype._setOption.apply( this, arguments ); + if ( key === "disabled" ) { + this.element.toggleClass( "ui-state-disabled", !!value ); + } + + this._super( key, value ); switch ( key ) { case "orientation": diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index efc83f3d5..642d5d947 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -102,17 +102,6 @@ $.widget("ui.sortable", $.ui.mouse, { return this; }, - _setOption: function(key, value){ - if ( key === "disabled" ) { - this.options[ key ] = value; - - this.widget().toggleClass( "ui-sortable-disabled", !!value ); - } else { - // Don't call widget base _setOption for disable as it adds ui-state-disabled class - $.Widget.prototype._setOption.apply(this, arguments); - } - }, - _mouseCapture: function(event, overrideHandle) { var currentItem = null, validHandle = false, diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 644b65239..c022413dc 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -381,13 +381,9 @@ $.widget( "ui.spinner", { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - this.buttons.button( "disable" ); - } else { - this.element.prop( "disabled", false ); - this.buttons.button( "enable" ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); + this.buttons.button( value ? "disable" : "enable" ); } }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index c581e4b81..adc4b9da1 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -345,8 +345,7 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); + .toggleClass( this.widgetFullName + "-disabled", !!value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); } -- cgit v1.2.3 From 4484c52a4d29ea4da53446ddea9f85b3f1231b06 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Thu, 14 Mar 2013 22:56:48 -0400 Subject: Sortable Tests: Add tests for axis option and recent axis option bugs. --- tests/unit/sortable/sortable_options.js | 93 ++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 8 deletions(-) diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index 638573162..8dcf0e82f 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -13,23 +13,100 @@ test("{ appendTo: 'parent' }, default", function() { test("{ appendTo: Selector }", function() { ok(false, "missing test - untested code is broken code."); }); +*/ -test("{ axis: false }, default", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: false }, default", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: false, + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: 'x' }", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: 'x' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "x", + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" ); + equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: 'y' }", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: 'y' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "y", + change: function() { + offsetAfter = item.offset(); + equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: ? }, unexpected", function() { - ok(false, "missing test - untested code is broken code."); +asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() { + expect( 2 ); + var expectedLeft, + element = $( "#sortable" ).sortable({ + axis: "y", + revert: true, + stop: start, + sort: function() { + expectedLeft = item.css( "left" ); + } + }), + item = element.find( "li" ).eq( 0 ); + + item.simulate( "drag", { + dy: 300, + dx: 50 + }); + + setTimeout(function() { + var top = parseFloat( item.css( "top" ) ); + equal( item.css( "left" ), expectedLeft, "left not animated" ); + ok( top > 0 && top < 300, "top is animated" ); + }, 100 ); }); +/* test("{ cancel: 'input,textarea,button,select,option' }, default", function() { ok(false, "missing test - untested code is broken code."); }); -- cgit v1.2.3 From 0cc40d799ffdf7aa978f910b890915ee6ad7a2b8 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 06:40:51 -0400 Subject: Dialog: Removed deprecated position handling. Fixes #8825 - Dialog: Remove array and string notations for position option. --- Gruntfile.js | 2 +- build/tasks/testswarm.js | 1 - tests/unit/all.html | 1 - tests/unit/dialog/dialog_deprecated.html | 67 -------------------------------- tests/unit/dialog/dialog_deprecated.js | 63 ------------------------------ ui/jquery.ui.dialog.js | 50 ------------------------ 6 files changed, 1 insertion(+), 183 deletions(-) delete mode 100644 tests/unit/dialog/dialog_deprecated.html delete mode 100644 tests/unit/dialog/dialog_deprecated.js diff --git a/Gruntfile.js b/Gruntfile.js index ff64f0c0d..05f599dd5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -318,7 +318,7 @@ grunt.initConfig({ files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { // disabling everything that doesn't (quite) work with PhantomJS for now // TODO except for all|index|test, try to include more as we go - return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); + return !( /(all|index|test|dialog|tabs|tooltip)\.html$/ ).test( file ); }) }, jshint: { diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 3361b7fa9..d747d16f9 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -16,7 +16,6 @@ var versions = { "Core": "core/core.html", "Datepicker": "datepicker/datepicker.html", "Dialog": "dialog/dialog.html", - "Dialog_deprecated": "dialog/dialog_deprecated.html", "Draggable": "draggable/draggable.html", "Droppable": "droppable/droppable.html", "Effects": "effects/effects.html", diff --git a/tests/unit/all.html b/tests/unit/all.html index ba96feef2..22b1802dc 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -22,7 +22,6 @@ "core/core.html", "datepicker/datepicker.html", "dialog/dialog.html", - "dialog/dialog_deprecated.html", "draggable/draggable.html", "droppable/droppable.html", "effects/effects.html", diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html deleted file mode 100644 index 1f8bac689..000000000 --- a/tests/unit/dialog/dialog_deprecated.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - jQuery UI Dialog Test Suite - - - - - - - - - - - - - - - - - - - - -

jQuery UI Dialog Test Suite

-

-
-

-
    -
    -
    -
    -
    -
    - Please share some personal information - - -
    -
    -

    Some more (optional) information

    - -
    -
    -
    -
    -
    - - diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js deleted file mode 100644 index ff6284ea5..000000000 --- a/tests/unit/dialog/dialog_deprecated.js +++ /dev/null @@ -1,63 +0,0 @@ -module("dialog (deprecated): position option with string and array"); - -test( "position, right bottom on window w/array", function() { - expect( 2 ); - - // dialogs alter the window width and height in FF and IE7 - // so we collect that information before creating the dialog - // Support: FF, IE7 - var winWidth = $( window ).width(), - winHeight = $( window ).height(), - element = $("
    ").dialog({ position: [ "right", "bottom" ] }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" ); - closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" ); - element.remove(); -}); - -test( "position, right bottom on window", function() { - expect( 2 ); - - // dialogs alter the window width and height in FF and IE7 - // so we collect that information before creating the dialog - // Support: FF, IE7 - var winWidth = $( window ).width(), - winHeight = $( window ).height(), - element = $("
    ").dialog({ position: "right bottom" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" ); - closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" ); - element.remove(); -}); - -test("position, offset from top left w/array", function() { - expect( 2 ); - var element = $("
    ").dialog({ position: [10, 10] }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, 10 + $(window).scrollLeft(), 1); - closeEnough(offset.top, 10 + $(window).scrollTop(), 1); - element.remove(); -}); - -test("position, top on window", function() { - expect( 2 ); - var element = $("
    ").dialog({ position: "top" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1); - closeEnough(offset.top, $(window).scrollTop(), 1); - element.remove(); -}); - -test("position, left on window", function() { - expect( 2 ); - var element = $("
    ").dialog({ position: "left" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, 0, 1); - closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1); - element.remove(); -}); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b35c0ffcf..59a7961ed 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -755,54 +755,4 @@ $.widget( "ui.dialog", { $.ui.dialog.overlayInstances = 0; -// DEPRECATED -if ( $.uiBackCompat !== false ) { - // position option with array notation - // just override with old implementation - $.widget( "ui.dialog", $.ui.dialog, { - _position: function() { - var position = this.options.position, - myAt = [], - offset = [ 0, 0 ], - isVisible; - - if ( position ) { - if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { - myAt = position.split ? position.split(" ") : [ position[0], position[1] ]; - if ( myAt.length === 1 ) { - myAt[1] = myAt[0]; - } - - $.each( [ "left", "top" ], function( i, offsetPosition ) { - if ( +myAt[ i ] === myAt[ i ] ) { - offset[ i ] = myAt[ i ]; - myAt[ i ] = offsetPosition; - } - }); - - position = { - my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + - myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), - at: myAt.join(" ") - }; - } - - position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); - } else { - position = $.ui.dialog.prototype.options.position; - } - - // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is(":visible"); - if ( !isVisible ) { - this.uiDialog.show(); - } - this.uiDialog.position( position ); - if ( !isVisible ) { - this.uiDialog.hide(); - } - } - }); -} - }( jQuery ) ); -- cgit v1.2.3 From 43442c319643ee9fb6f54737d921ba8b03f3ae6b Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 06:45:38 -0400 Subject: Accordion: Remove deprecated content property in create event. Fixes #8999 - Accordion: Remove content property from create event. --- tests/unit/accordion/accordion_events.js | 7 +------ ui/jquery.ui.accordion.js | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 79283d11c..5f6cfa8bc 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -6,7 +6,7 @@ var setupTeardown = TestHelpers.accordion.setupTeardown, module( "accordion: events", setupTeardown() ); test( "create", function() { - expect( 15 ); + expect( 10 ); var element = $( "#list1" ), headers = element.children( "h3" ), @@ -18,8 +18,6 @@ test( "create", function() { strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); - equal( ui.content.length, 1, "content length" ); - strictEqual( ui.content[ 0 ], contents[ 0 ], "content" ); } }); element.accordion( "destroy" ); @@ -31,8 +29,6 @@ test( "create", function() { strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); - equal( ui.content.length, 1, "content length" ); - strictEqual( ui.content[ 0 ], contents[ 2 ], "content" ); } }); element.accordion( "destroy" ); @@ -43,7 +39,6 @@ test( "create", function() { create: function( event, ui ) { equal( ui.header.length, 0, "header length" ); equal( ui.panel.length, 0, "panel length" ); - equal( ui.content.length, 0, "content length" ); } }); element.accordion( "destroy" ); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index da0d5751c..c210a29a9 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -65,8 +65,7 @@ $.widget( "ui.accordion", { _getCreateEventData: function() { return { header: this.active, - panel: !this.active.length ? $() : this.active.next(), - content: !this.active.length ? $() : this.active.next() + panel: !this.active.length ? $() : this.active.next() }; }, -- cgit v1.2.3 From ae9651931f3d0704b33322a7d6f4750c1d83ccf7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 06:53:09 -0400 Subject: Datepicker: Don't use .zIndex(); implement the logic locally. --- ui/jquery.ui.datepicker.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index efee7a819..5892e2ddc 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -19,6 +19,28 @@ var PROP_NAME = "datepicker", dpuuid = new Date().getTime(), instActive; +function getZindex( elem ) { + var position, value; + while ( elem.length && elem[ 0 ] !== document ) { + // Ignore z-index if position is set to a value where z-index is ignored by the browser + // This makes behavior of this function consistent across browsers + // WebKit always returns auto if the element is positioned + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { + // IE returns 0 when zIndex is not specified + // other browsers return a string + // we ignore the case of nested elements with an explicit value of 0 + //
    + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { + return value; + } + } + elem = elem.parent(); + } + + return 0; +} /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. Settings for (groups of) date pickers are maintained in an instance object, @@ -744,7 +766,7 @@ $.extend(Datepicker.prototype, { if (!inst.inline) { showAnim = $.datepicker._get(inst, "showAnim"); duration = $.datepicker._get(inst, "duration"); - inst.dpDiv.zIndex($(input).zIndex()+1); + inst.dpDiv.css( "z-index", getZindex( $( input ) ) + 1 ); $.datepicker._datepickerShowing = true; if ( $.effects && $.effects.effect[ showAnim ] ) { -- cgit v1.2.3 From 932caaf2ddf70c889003d5b42eee4f069d2dd296 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 07:01:24 -0400 Subject: Core: Deprecated .zIndex(). Fixes #9061 - Core: Deprecate .zIndex(). --- build/tasks/testswarm.js | 1 + tests/unit/all.html | 1 + tests/unit/core/core.html | 11 --- tests/unit/core/core.js | 19 ----- tests/unit/core/core_deprecated.html | 136 +++++++++++++++++++++++++++++++++++ tests/unit/core/core_deprecated.js | 24 +++++++ ui/jquery.ui.core.js | 58 +++++++-------- 7 files changed, 191 insertions(+), 59 deletions(-) create mode 100644 tests/unit/core/core_deprecated.html create mode 100644 tests/unit/core/core_deprecated.js diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index d747d16f9..01fb178f9 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -14,6 +14,7 @@ var versions = { "Autocomplete": "autocomplete/autocomplete.html", "Button": "button/button.html", "Core": "core/core.html", + "Core_deprecated": "core/core_deprecated.html", "Datepicker": "datepicker/datepicker.html", "Dialog": "dialog/dialog.html", "Draggable": "draggable/draggable.html", diff --git a/tests/unit/all.html b/tests/unit/all.html index 22b1802dc..8dfff2a4e 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -20,6 +20,7 @@ "autocomplete/autocomplete.html", "button/button.html", "core/core.html", + "core/core_deprecated.html", "datepicker/datepicker.html", "dialog/dialog.html", "draggable/draggable.html", diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 41c8db827..fd472d64a 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -117,17 +117,6 @@
    -
    -
    .
    -
    -
    -
    .
    -
    -
    -
    .
    -
    -
    -
    diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 78a225338..54d50d84e 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -26,25 +26,6 @@ asyncTest( "focus", function() { }); }); -test( "zIndex", function() { - expect( 7 ); - var el = $( "#zIndexAutoWithParent" ), - parent = el.parent(); - equal( el.zIndex(), 100, "zIndex traverses up to find value" ); - equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); - - el = $( "#zIndexAutoWithParentViaCSS" ); - equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); - - el = $( "#zIndexAutoWithParentViaCSSPositioned" ); - equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); - el.parent().zIndex( 200 ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); - - equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); -}); - test( "innerWidth - getter", function() { expect( 2 ); var el = $( "#dimensions" ); diff --git a/tests/unit/core/core_deprecated.html b/tests/unit/core/core_deprecated.html new file mode 100644 index 000000000..d9c41ca39 --- /dev/null +++ b/tests/unit/core/core_deprecated.html @@ -0,0 +1,136 @@ + + + + + jQuery UI Core Test Suite + + + + + + + + + + + + + + + + + +

    jQuery UI Core Test Suite

    +

    +
    +

    +
      +
      + + + + + + + + + + +
      +
      + +
      + + + + + + + + + + xxx + anchor + anchor + x +
      x
      + x +
      x
      +
      + +
      + + + + + + + + + +
      + +
      + + + + + + + + + +
      + +
      + + + + + + . + . + . + . +
      + +
      + + +
      + +
      +
      .
      +
      +
      +
      .
      +
      +
      +
      .
      +
      +
      + +
      + +
      + + diff --git a/tests/unit/core/core_deprecated.js b/tests/unit/core/core_deprecated.js new file mode 100644 index 000000000..bb06f77b2 --- /dev/null +++ b/tests/unit/core/core_deprecated.js @@ -0,0 +1,24 @@ +(function( $ ) { + +module( "core - deprecated" ); + +test( "zIndex", function() { + expect( 7 ); + var el = $( "#zIndexAutoWithParent" ), + parent = el.parent(); + equal( el.zIndex(), 100, "zIndex traverses up to find value" ); + equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); + + el = $( "#zIndexAutoWithParentViaCSS" ); + equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); + + el = $( "#zIndexAutoWithParentViaCSSPositioned" ); + equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); + el.parent().zIndex( 200 ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); + + equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); +}); + +})( jQuery ); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 1a13da251..0d263fa5f 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -78,35 +78,6 @@ $.fn.extend({ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent; }, - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - //
      - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; - }, - uniqueId: function() { return this.each(function() { if ( !this.id ) { @@ -263,6 +234,35 @@ $.fn.extend({ enableSelection: function() { return this.unbind( ".ui-disableSelection" ); + }, + + zIndex: function( zIndex ) { + if ( zIndex !== undefined ) { + return this.css( "zIndex", zIndex ); + } + + if ( this.length ) { + var elem = $( this[ 0 ] ), position, value; + while ( elem.length && elem[ 0 ] !== document ) { + // Ignore z-index if position is set to a value where z-index is ignored by the browser + // This makes behavior of this function consistent across browsers + // WebKit always returns auto if the element is positioned + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { + // IE returns 0 when zIndex is not specified + // other browsers return a string + // we ignore the case of nested elements with an explicit value of 0 + //
      + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { + return value; + } + } + elem = elem.parent(); + } + } + + return 0; } }); -- cgit v1.2.3 From 0cfecb62722fd3bc743141129560964ba30c4802 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 09:04:22 -0400 Subject: Grunt: Don't run htmllint against core_deprecated.html. --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 05f599dd5..d610f2c47 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -192,7 +192,7 @@ grunt.initConfig({ htmllint: { // ignore files that contain invalid html, used only for ajax content testing all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { - return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); + return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core.*\.html)/.test( file ); }) }, copy: { -- cgit v1.2.3 From d8468a33790da8e7be46552325e932162b1942af Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 09:04:48 -0400 Subject: Grunt: Add lint and test aliases. --- Gruntfile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index d610f2c47..e4fa333fd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -367,7 +367,9 @@ grunt.initConfig({ } }); -grunt.registerTask( "default", [ "jshint", "csslint", "htmllint", "qunit" ] ); +grunt.registerTask( "default", [ "lint", "test" ] ); +grunt.registerTask( "lint", [ "jshint", "csslint", "htmllint" ] ); +grunt.registerTask( "test", [ "qunit" ] ); grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] ); grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] ); grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] ); -- cgit v1.2.3 From 5fb68636d19a40451d1190b9a5255d86616d54f5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 09:36:49 -0400 Subject: Grunt: Run all CSS files through csslint. --- Gruntfile.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index e4fa333fd..c2c1aefaf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -348,20 +348,18 @@ grunt.initConfig({ } }, csslint: { - // TODO figure out what to check for, then fix and enable base_theme: { - src: expandFiles( "themes/base/*.css" ).filter(function( file ) { - // TODO remove items from this list once rewritten - return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); - }), - // TODO consider reenabling some of these rules + src: "themes/base/*.css", options: { "adjoining-classes": false, + "box-model": false, + "compatible-vendor-prefixes": false, + "duplicate-background-images": false, "import": false, + "important": false, "outline-none": false, - // especially this one "overqualified-elements": false, - "compatible-vendor-prefixes": false + "text-indent": false } } } -- cgit v1.2.3 From 39a2f465a54d93777781c1a97cb58953a7d6557e Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 15 Mar 2013 09:57:45 -0400 Subject: Use .csslintrc instead of inlining rules in the Gruntfile. --- .csslintrc | 11 +++++++++++ Gruntfile.js | 10 +--------- package.json | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 .csslintrc diff --git a/.csslintrc b/.csslintrc new file mode 100644 index 000000000..5d9db072c --- /dev/null +++ b/.csslintrc @@ -0,0 +1,11 @@ +{ + "adjoining-classes": false, + "box-model": false, + "compatible-vendor-prefixes": false, + "duplicate-background-images": false, + "import": false, + "important": false, + "outline-none": false, + "overqualified-elements": false, + "text-indent": false +} diff --git a/Gruntfile.js b/Gruntfile.js index c2c1aefaf..fae88635c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -351,15 +351,7 @@ grunt.initConfig({ base_theme: { src: "themes/base/*.css", options: { - "adjoining-classes": false, - "box-model": false, - "compatible-vendor-prefixes": false, - "duplicate-background-images": false, - "import": false, - "important": false, - "outline-none": false, - "overqualified-elements": false, - "text-indent": false + csslintrc: ".csslintrc" } } } diff --git a/package.json b/package.json index 5a2250595..93c45a9fc 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "grunt-contrib-uglify": "0.1.1", "grunt-contrib-concat": "0.1.3", "grunt-contrib-qunit": "0.2.0", - "grunt-contrib-csslint": "0.1.0", + "grunt-contrib-csslint": "0.1.1", "grunt-contrib-cssmin": "0.4.2", "grunt-compare-size": "0.3.1", "grunt-html": "0.3.3", -- cgit v1.2.3 From 82f588e82b887fdcb2406da2c5dfedc2f13ebdc9 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Thu, 14 Mar 2013 13:21:24 -0500 Subject: Draggable: Fix double offset bug when scrolling. Fixes #6817 - Draggable: auto scroll goes double distance when dragging --- tests/unit/draggable/draggable_options.js | 34 +++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 21 +++++++++++++++---- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index a71bf57cb..83fbc1712 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1103,6 +1103,40 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { TestHelpers.draggable.restoreScroll( document ); }); +test( "#6817: auto scroll goes double distance when dragging", function() { + expect( 2 ); + + var offsetBefore, + distance = 10, + viewportHeight = $( window ).height(), + element = $( "#draggable1" ).draggable({ + 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" ); + } + }), + scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), + oldY = viewportHeight - scrollSensitivity, + newY = oldY + distance; + + element.offset({ + top: oldY, + left: 1 + }); + + offsetBefore = element.offset(); + + element.simulate( "drag", { + handle: "corner", + dx: 1, + y: newY, + moves: 1 + }); + + TestHelpers.draggable.restoreScroll( document ); +}); + test( "snap, snapMode, and snapTolerance", function() { expect( 9 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 5762d3171..a75f9e9f3 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -135,6 +135,9 @@ $.widget("ui.draggable", $.ui.mouse, { left: this.offset.left - this.margins.left }; + //Reset scroll cache + this.offset.scroll = false; + $.extend(this.offset, { click: { //Where the click happened, relative to the element left: event.pageX - this.offset.left, @@ -433,18 +436,23 @@ $.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); + //Cache the scroll + if (!this.offset.scroll) { + this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; + } + return { top: ( 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 : scroll.scrollTop() ) ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : 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 : scroll.scrollLeft() ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ) * mod) ) }; @@ -459,6 +467,11 @@ $.widget("ui.draggable", $.ui.mouse, { pageX = event.pageX, pageY = event.pageY; + //Cache the scroll + if (!this.offset.scroll) { + this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; + } + /* * - Position constraining - * Constrain the position to a mix of grid, containment. @@ -508,14 +521,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 : scroll.scrollTop() ) )) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : 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 : scroll.scrollLeft() )) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left )) ) }; -- cgit v1.2.3 From ebd5f13027b30be1cdd9e8782e81ce468dcdff5e Mon Sep 17 00:00:00 2001 From: TJ VanToll Date: Sat, 16 Mar 2013 11:02:57 -0400 Subject: Autocomplete: Updated reference in combobox demo. Fixed #9157 - Combobox demo does not show Items --- demos/autocomplete/combobox.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index f89f260eb..69be70220 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -76,7 +76,8 @@ }, _createShowAllButton: function() { - var wasOpen = false; + var input = this.input, + wasOpen = false; $( "" ) .attr( "tabIndex", -1 ) -- cgit v1.2.3 From bd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e Mon Sep 17 00:00:00 2001 From: Zbigniew Motyka Date: Mon, 29 Oct 2012 09:55:54 +0100 Subject: Draggable: modified snapping algorithm to use edges and corners. Fixed #8165 - Draggable: Snapping doesn't take top/left into account properly --- tests/unit/draggable/draggable_options.js | 37 +++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 3 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 83fbc1712..2cb7ec22b 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1257,6 +1257,43 @@ test( "snap, snapMode, and snapTolerance", function() { deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); }); +test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { + expect( 1 ); + + var snapTolerance = 20, + y = 1, + element = $( "#draggable1" ) + .css({ + width: "50px", + height: "200px" + }).offset({ + top: y, + left: 1 + }), + element2 = $( "#draggable2" ) + .css({ + width: "50px", + height: "50px" + }).offset({ + top: y + snapTolerance + 1, + left: 200 + }), + newX = element2.offset().left - element.outerWidth() - snapTolerance + 1; + + $( "#draggable1, #draggable2" ).draggable({ + snap: true, + snapTolerance: snapTolerance + }); + + element.simulate( "drag", { + handle: "corner", + x: newX, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" ); +}); + test( "stack", function() { expect( 2 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index a75f9e9f3..4c8a9d5d5 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -850,8 +850,7 @@ $.ui.plugin.add("draggable", "snap", { t = inst.snapElements[i].top; b = t + inst.snapElements[i].height; - //Yes, I know, this is insane ;) - if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { + if(x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d) { if(inst.snapElements[i].snapping) { (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); } -- cgit v1.2.3 From 9d8af804ad4cebe434d420b29467c596809a7cca Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 16 Mar 2013 14:36:06 -0400 Subject: Draggable: make sure snap elements are in the document before snapping. Fixes #8459 - Draggable: element can snap to an element that was removed during drag. --- tests/unit/draggable/draggable_options.js | 33 +++++++++++++++++++++++++++++++ ui/jquery.ui.draggable.js | 14 +++---------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 2cb7ec22b..f4fca0b2e 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -1257,6 +1257,39 @@ test( "snap, snapMode, and snapTolerance", function() { deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); }); +test( "#8459: element can snap to an element that was removed during drag", function() { + expect( 1 ); + + var newX, newY, + snapTolerance = 15, + element = $( "#draggable1" ).draggable({ + snap: true, + snapMode: "both", + snapTolerance: snapTolerance, + start: function() { + element2.remove(); + } + }), + element2 = $( "#draggable2" ).draggable(); + + element.offset({ + top: 1, + left: 1 + }); + + newX = element2.offset().left - element.outerWidth() - snapTolerance + 1; + newY = element2.offset().top; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" ); +}); + test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { expect( 1 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 4c8a9d5d5..605425859 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -217,9 +217,7 @@ $.widget("ui.draggable", $.ui.mouse, { _mouseStop: function(event) { //If we are using droppables, inform the manager about the drop - var element, - that = this, - elementInDom = false, + var that = this, dropped = false; if ($.ui.ddmanager && !this.options.dropBehaviour) { dropped = $.ui.ddmanager.drop(this, event); @@ -232,13 +230,7 @@ $.widget("ui.draggable", $.ui.mouse, { } //if the original element is no longer in the DOM don't bother to continue (see #8269) - element = this.element[0]; - while ( element && (element = element.parentNode) ) { - if (element === document ) { - elementInDom = true; - } - } - if ( !elementInDom && this.options.helper === "original" ) { + if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) { return false; } @@ -850,7 +842,7 @@ $.ui.plugin.add("draggable", "snap", { t = inst.snapElements[i].top; b = t + inst.snapElements[i].height; - if(x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d) { + if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { if(inst.snapElements[i].snapping) { (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); } -- cgit v1.2.3 From 4202ad07187e15a3b2e64277e170daf9b278c3b4 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 16 Mar 2013 15:27:56 -0400 Subject: Autocomplete demo (combobox): Hide select on create. Fixes #9158 - Autocomplete Combobox demo shows underlying select by default. --- demos/autocomplete/combobox.html | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 69be70220..5c74317e2 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -41,6 +41,7 @@ .addClass( "ui-combobox" ) .insertAfter( this.element ); + this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, -- cgit v1.2.3 From 8bf5bc8bc8322bce796a9d9c9e7dc140e3081973 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 18 Mar 2013 13:05:57 -0400 Subject: Progressbar demo (label): Use absolute positioning for the label. Fixes #9163 - Progressbar demo: Incorrect presentation with progressbar label in IE9. --- demos/progressbar/label.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/demos/progressbar/label.html b/demos/progressbar/label.html index 3e669ba4a..a1e16cb71 100644 --- a/demos/progressbar/label.html +++ b/demos/progressbar/label.html @@ -10,10 +10,13 @@