From a0c18ea25086ed07634baff5b4fea46e69aad38e Mon Sep 17 00:00:00 2001 From: Viktar Varvanovich Date: Thu, 24 May 2012 14:30:55 -0400 Subject: [PATCH 01/33] Draggable: Apply ui-draggable-dragging class prior to calculating dimensions. Fixes #8349 - Draggable: Incorrect dimensions used if .ui-draggable-dragging changes dimensions --- ui/jquery.ui.draggable.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 84077ed29..5eb235642 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -102,6 +102,8 @@ $.widget("ui.draggable", $.ui.mouse, { //Create and append the visible helper this.helper = this._createHelper(event); + this.helper.addClass("ui-draggable-dragging"); + //Cache the helper size this._cacheHelperProportions(); @@ -162,7 +164,7 @@ $.widget("ui.draggable", $.ui.mouse, { if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, event); - this.helper.addClass("ui-draggable-dragging"); + this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) From 3e3d4308d79e248f9cd7f6235b1badf7da46a3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 24 May 2012 15:01:09 -0400 Subject: [PATCH 02/33] Revert "Autocomplete: make categories work again (follow-up)" This reverts commit db9a015485f0a5dbbb12b22720dbb2111cda2dd8. --- demos/autocomplete/categories.html | 7 ------- themes/base/jquery.ui.autocomplete.css | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html index be59bfaca..3489f56b1 100644 --- a/demos/autocomplete/categories.html +++ b/demos/autocomplete/categories.html @@ -18,13 +18,6 @@ margin: .8em 0 .2em; line-height: 1.5; } - .ui-autocomplete li.ui-autocomplete-category { - font-size: 1em; - line-height: 1.5; - margin: 0.5em 0 0 0; - height: auto; - border: 0; - } + @@ -120,6 +128,23 @@
+
+
+
    +
  • 1
  • +
  • 2
  • +
+
+

Lorem ipsum

+

Lorem ipsum

+

Lorem ipsum

+
+
+

Lorem ipsum

+
+
+
+ diff --git a/tests/unit/tabs/tabs_common.js b/tests/unit/tabs/tabs_common.js index b98ff3575..a589515f8 100644 --- a/tests/unit/tabs/tabs_common.js +++ b/tests/unit/tabs/tabs_common.js @@ -4,6 +4,7 @@ TestHelpers.commonWidgetTests( "tabs", { collapsible: false, disabled: false, event: "click", + heightStyle: "content", hide: null, show: null, diff --git a/tests/unit/tabs/tabs_common_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js index 718ae8272..5b41014da 100644 --- a/tests/unit/tabs/tabs_common_deprecated.js +++ b/tests/unit/tabs/tabs_common_deprecated.js @@ -7,6 +7,7 @@ TestHelpers.commonWidgetTests( "tabs", { cookie: null, disabled: false, event: "click", + heightStyle: "content", hide: null, fx: null, idPrefix: "ui-tabs-", diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index e58382efb..bb4088350 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -30,6 +30,14 @@ + @@ -119,6 +127,23 @@
+
+
+
    +
  • 1
  • +
  • 2
  • +
+
+

Lorem ipsum

+

Lorem ipsum

+

Lorem ipsum

+
+
+

Lorem ipsum

+
+
+
+ diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index df6827c57..8365a42d7 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -1,6 +1,7 @@ (function( $ ) { var disabled = TestHelpers.tabs.disabled, + equalHeight = TestHelpers.tabs.equalHeight, state = TestHelpers.tabs.state; module( "tabs: options" ); @@ -211,6 +212,72 @@ test( "{ event: custom }", function() { state( element, 0, 1, 0 ); }); +test( "{ heightStyle: 'auto' }", function() { + expect( 2 ); + var element = $( "#tabs8" ).tabs({ heightStyle: "auto" }); + equalHeight( element, 45 ); +}); + +test( "{ heightStyle: 'content' }", function() { + expect( 2 ); + var element = $( "#tabs8" ).tabs({ heightStyle: "content" }), + sizes = element.find( ".ui-tabs-panel" ).map(function() { + return $( this ).height(); + }).get(); + equal( sizes[ 0 ], 45 ); + equal( sizes[ 1 ], 15 ); +}); + +test( "{ heightStyle: 'fill' }", function() { + expect( 2 ); + $( "#tabs8Wrapper" ).height( 500 ); + var element = $( "#tabs8" ).tabs({ heightStyle: "fill" }); + equalHeight( element, 485 ); +}); + +test( "{ heightStyle: 'fill' } with sibling", function() { + expect( 2 ); + $( "#tabs8Wrapper" ).height( 500 ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#tabs8Wrapper" ); + var element = $( "#tabs8" ).tabs({ heightStyle: "fill" }); + equalHeight( element, 385 ); +}); + +test( "{ heightStyle: 'fill' } with multiple siblings", function() { + expect( 2 ); + $( "#tabs8Wrapper" ).height( 500 ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#tabs8Wrapper" ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30, + position: "absolute" + }) + .prependTo( "#tabs8Wrapper" ); + $( "

Lorem Ipsum

" ) + .css({ + height: 25, + marginTop: 10, + marginBottom: 15 + }) + .prependTo( "#tabs8Wrapper" ); + var element = $( "#tabs8" ).tabs({ heightStyle: "fill" }); + equalHeight( element, 335 ); +}); + // TODO: add animation tests }( jQuery ) ); diff --git a/tests/unit/tabs/tabs_test_helpers.js b/tests/unit/tabs/tabs_test_helpers.js index 508043943..0c9309186 100644 --- a/tests/unit/tabs/tabs_test_helpers.js +++ b/tests/unit/tabs/tabs_test_helpers.js @@ -38,6 +38,12 @@ TestHelpers.tabs = { deepEqual( actual, expected ); }, + equalHeight: function( tabs, height ) { + tabs.find( ".ui-tabs-panel" ).each(function() { + equal( $( this ).outerHeight(), height ); + }); + }, + state: function( tabs ) { var expected = $.makeArray( arguments ).slice( 1 ), actual = tabs.find( ".ui-tabs-nav li" ).map(function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index a693899da..1224f47b9 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -34,6 +34,7 @@ $.widget( "ui.tabs", { active: null, collapsible: false, event: "click", + heightStyle: "content", hide: null, show: null, @@ -150,6 +151,10 @@ $.widget( "ui.tabs", { if ( key === "event" ) { this._setupEvents( value ); } + + if ( key === "heightStyle" ) { + this._setupHeightStyle( value ); + } }, _tabId: function( tab ) { @@ -202,6 +207,7 @@ $.widget( "ui.tabs", { this._setupDisabled( options.disabled ); this._setupEvents( options.event ); + this._setupHeightStyle( options.heightStyle ); // remove all handlers, may run on existing tabs this.lis.unbind( ".tabs" ); @@ -290,6 +296,50 @@ $.widget( "ui.tabs", { this._bind( this.anchors, events ); }, + _setupHeightStyle: function( heightStyle ) { + var maxHeight, overflow, + parent = this.element.parent(); + + if ( heightStyle === "fill" ) { + // IE 6 treats height like minHeight, so we need to turn off overflow + // in order to get a reliable height + // we use the minHeight support test because we assume that only + // browsers that don't support minHeight will treat height as minHeight + if ( !$.support.minHeight ) { + overflow = parent.css( "overflow" ); + parent.css( "overflow", "hidden"); + } + maxHeight = parent.height(); + this.element.siblings( ":visible" ).each(function() { + var elem = $( this ), + position = elem.css( "position" ); + + if ( position === "absolute" || position === "fixed" ) { + return; + } + maxHeight -= elem.outerHeight( true ); + }); + if ( overflow ) { + parent.css( "overflow", overflow ); + } + + this.element.children().not( this.panels ).each(function() { + maxHeight -= $( this ).outerHeight( true ); + }); + + this.panels.each(function() { + $( this ).height( Math.max( 0, maxHeight - + $( this ).innerHeight() + $( this ).height() ) ); + }) + .css( "overflow", "auto" ); + } else if ( heightStyle === "auto" ) { + maxHeight = 0; + this.panels.each(function() { + maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); + }).height( maxHeight ); + } + }, + _eventHandler: function( event ) { var options = this.options, active = this.active, @@ -448,6 +498,10 @@ $.widget( "ui.tabs", { } }); + if ( this.options.heightStyle !== "content" ) { + this.panels.css( "height", "" ); + } + return this; }, From 234ced07ef55df99f1886f47b7783dcbec33a77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 29 May 2012 10:04:20 -0400 Subject: [PATCH 21/33] Tabs: Simplify _findActive() now that hrefs are never used. --- ui/jquery.ui.tabs.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 1224f47b9..9c5de53d1 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -447,14 +447,8 @@ $.widget( "ui.tabs", { }); }, - _findActive: function( selector ) { - if ( typeof selector === "number" ) { - return this.lis.eq( selector ); - } - if ( typeof selector === "string" ) { - return this.anchors.filter( "[href$='" + selector + "']" ).closest( "li" ); - } - return $(); + _findActive: function( index ) { + return index === false ? $() : this.lis.eq( index ); }, _getIndex: function( index ) { From 0bbad349b982839c607d7c16bf2e46a293532dee Mon Sep 17 00:00:00 2001 From: Pavel Stetina Date: Tue, 29 May 2012 10:20:02 -0400 Subject: [PATCH 22/33] Datepicker: Corrected language code for Georgian language according to ISO 639. Fixed #8356 - jquery.ui.datepicker-ge.js has wrong language code. --- demos/datepicker/localization.html | 2 +- demos/index.html | 2 +- ...{jquery.ui.datepicker-ge.js => jquery.ui.datepicker-ka.js} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename ui/i18n/{jquery.ui.datepicker-ge.js => jquery.ui.datepicker-ka.js} (93%) diff --git a/demos/datepicker/localization.html b/demos/datepicker/localization.html index ba5efdfc3..e7bb42c16 100644 --- a/demos/datepicker/localization.html +++ b/demos/datepicker/localization.html @@ -32,7 +32,6 @@ - @@ -43,6 +42,7 @@ + diff --git a/demos/index.html b/demos/index.html index 678c9961f..059bf42cb 100644 --- a/demos/index.html +++ b/demos/index.html @@ -66,7 +66,6 @@ - @@ -77,6 +76,7 @@ + diff --git a/ui/i18n/jquery.ui.datepicker-ge.js b/ui/i18n/jquery.ui.datepicker-ka.js similarity index 93% rename from ui/i18n/jquery.ui.datepicker-ge.js rename to ui/i18n/jquery.ui.datepicker-ka.js index 10d4e5851..c10658d79 100644 --- a/ui/i18n/jquery.ui.datepicker-ge.js +++ b/ui/i18n/jquery.ui.datepicker-ka.js @@ -1,7 +1,7 @@ /* Georgian (UTF-8) initialisation for the jQuery UI date picker plugin. */ /* Written by Lado Lomidze (lado.lomidze@gmail.com). */ jQuery(function($){ - $.datepicker.regional['ge'] = { + $.datepicker.regional['ka'] = { closeText: 'დახურვა', prevText: '< წინა', nextText: 'შემდეგი >', @@ -17,5 +17,5 @@ jQuery(function($){ isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; - $.datepicker.setDefaults($.datepicker.regional['ge']); + $.datepicker.setDefaults($.datepicker.regional['ka']); }); From 649a670d1c86be5e50b13cc03161d20098f80588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 29 May 2012 15:14:35 -0400 Subject: [PATCH 23/33] Tests: Differentiate between attributes and properties in domEqual(). --- tests/unit/testsuite.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 6c7ecf10b..3c8ec04c4 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -138,12 +138,16 @@ TestHelpers.commonWidgetTests = function( widget, settings ) { /* * Experimental assertion for comparing DOM objects. * - * Serializes an element and some properties and it's children if any, otherwise the text. + * Serializes an element and some properties and attributes and it's children if any, otherwise the text. * Then compares the result using deepEqual. */ window.domEqual = function( selector, modifier, message ) { var expected, actual, properties = [ + "disabled", + "readOnly" + ], + attributes = [ "autocomplete", "aria-activedescendant", "aria-controls", @@ -159,11 +163,9 @@ window.domEqual = function( selector, modifier, message ) { "aria-valuemin", "aria-valuenow", "class", - "disabled", "href", "id", "nodeName", - "readOnly", "role", "tabIndex", "title" @@ -179,7 +181,12 @@ window.domEqual = function( selector, modifier, message ) { var children, result = {}; $.each( properties, function( index, attr ) { - result[ attr ] = elem.prop( attr ); + var value = elem.prop( attr ); + result[ attr ] = value !== undefined ? value : ""; + }); + $.each( attributes, function( index, attr ) { + var value = elem.attr( attr ); + result[ attr ] = value !== undefined ? value : ""; }); children = elem.children(); if ( children.length ) { From 40e47c0b08c31e5003833b9c46d36e7468a63de8 Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 20:55:43 -0500 Subject: [PATCH 24/33] Core: Add the uniqueId() and removeUniqueId() methods written by @scottgonzalez to provide a generalized way of generating and removing generated element id's. Also, added a unit test. Fixed #8361 - Add uniqueId() and removeUniqueId() --- tests/unit/core/core.js | 10 ++++++++++ ui/jquery.ui.core.js | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 7a78ae34d..1026c5b0b 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -153,4 +153,14 @@ test( "outerHeight(true) - setter", function() { equal( el.height(), 32, "height set properly when hidden" ); }); +test( "uniqueId / removeUniqueId", function() { + var el = $( "img" ).eq( 0 ); + + equal( el.attr( "id" ), undefined, "element has no initial id" ); + el.uniqueId(); + ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" ); + el.removeUniqueId(); + equal( el.attr( "id" ), undefined, "unique id has been removed from element" ); +}); + })( jQuery ); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index d8fff91e1..a511de24b 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -9,6 +9,9 @@ */ (function( $, undefined ) { +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 @@ -107,6 +110,22 @@ $.fn.extend({ return 0; }, + uniqueId: function() { + return this.each(function() { + if ( !this.id ) { + this.id = "ui-id-" + (++uuid); + } + }); + }, + + removeUniqueId: function() { + return this.each(function() { + if ( runiqueId.test( this.id ) ) { + $( this ).removeAttr( "id" ); + } + }); + }, + disableSelection: function() { return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + ".ui-disableSelection", function( event ) { From d44f3d079e1a5976333afe56d104d03ba00a901b Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 20:59:03 -0500 Subject: [PATCH 25/33] Menu: Use new uniqueId and removeUniqueId methods for generating id's on menus and menu items and for removing those id's during destroy. Also, properly remove the aria-disabled attribute during destroy. --- ui/jquery.ui.menu.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 8d28ee82f..54a85abf5 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -13,8 +13,7 @@ */ (function($) { -var idIncrement = 0, - currentEventTarget = null; +var currentEventTarget = null; $.widget( "ui.menu", { version: "@VERSION", @@ -35,12 +34,11 @@ $.widget( "ui.menu", { }, _create: function() { this.activeMenu = this.element; - this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++; this.element + .uniqueId() .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length ) .attr({ - id: this.menuId, role: this.options.role, tabIndex: 0 }) @@ -145,18 +143,21 @@ $.widget( "ui.menu", { .removeAttr( "aria-labelledby" ) .removeAttr( "aria-expanded" ) .removeAttr( "aria-hidden" ) + .removeAttr( "aria-disabled" ) + .removeUniqueId() .show(); // destroy menu items this.element.find( ".ui-menu-item" ) .removeClass( "ui-menu-item" ) .removeAttr( "role" ) + .removeAttr( "aria-disabled" ) .children( "a" ) + .removeUniqueId() .removeClass( "ui-corner-all ui-state-hover" ) .removeAttr( "tabIndex" ) .removeAttr( "role" ) .removeAttr( "aria-haspopup" ) - .removeAttr( "id" ) // TODO: is this correct? Don't these exist in the original markup? .children( ".ui-icon" ) .remove(); @@ -273,7 +274,6 @@ $.widget( "ui.menu", { refresh: function() { // initialize nested menus var menus, - menuId = this.menuId, submenus = this.element.find( this.options.menus + ":not(.ui-menu)" ) .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .hide() @@ -290,13 +290,11 @@ $.widget( "ui.menu", { .addClass( "ui-menu-item" ) .attr( "role", "presentation" ) .children( "a" ) + .uniqueId() .addClass( "ui-corner-all" ) .attr({ tabIndex: -1, - role: this._itemRole(), - id: function( i ) { - return menuId + "-" + i; - } + role: this._itemRole() }); // initialize unlinked menu-items containing spaces and/or dashes only as dividers From 1f60380413d65920df37fb9dc90a06378a44b6de Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 20:59:50 -0500 Subject: [PATCH 26/33] Menu tests: Modify test to check for id's generated by the new uniqueId method --- tests/unit/menu/menu_core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index 68b625687..6dab6addd 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -23,7 +23,7 @@ test("accessibility", function () { item = menu.find( "li:last" ); menu.menu( "focus", $.Event(), item ); - equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id"); + ok( /ui-id-\d+$/.test( menu.attr( "aria-activedescendant" ) ), "aria attribute, generated id"); }); })(jQuery); From 112daf13335115063c1e39670663fa5947e613e1 Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 21:00:30 -0500 Subject: [PATCH 27/33] Menu tests: Add id's to some anchors to ensure destroy is only removing id's that have been generated --- tests/unit/menu/menu.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index a8a76bf14..691ad339b 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -55,7 +55,7 @@
  • Aberdeen
  • Ada
  • Adamsville
  • -
  • Addyston
  • +
  • Addyston
  • Adelphi
  • @@ -235,7 +235,7 @@ Delphi @@ -258,7 +258,7 @@
  • Adamsville
  • Addyston
  • - Delphi + Delphi
    • Ada
    • Saarland
    • From 5c96d817be0812d2c81cfdd2f71018a8887c7f86 Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 21:21:35 -0500 Subject: [PATCH 28/33] Menu tests: Fix test id's so that they are unique to pass linting --- tests/unit/menu/menu.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 691ad339b..31c29a924 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -55,7 +55,7 @@
    • Aberdeen
    • Ada
    • Adamsville
    • -
    • Addyston
    • +
    • Addyston
    • Adelphi
    @@ -235,7 +235,7 @@ Delphi @@ -258,7 +258,7 @@
  • Adamsville
  • Addyston
  • - Delphi + Delphi
    • Ada
    • Saarland
    • From 9f59d01fdc5e0a62f3bd2072b197d92ee107b2c3 Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 22:25:23 -0500 Subject: [PATCH 29/33] Tabs: Remove aria-controls attribute during destroy --- ui/jquery.ui.tabs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 9c5de53d1..79587bba6 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -488,7 +488,8 @@ $.widget( "ui.tabs", { "ui-tabs-panel", "ui-widget-content", "ui-corner-bottom" - ].join( " " ) ); + ].join( " " ) ) + .removeAttr( "aria-controls" ); } }); From 240b22b1439df22408c5782e640e98cb335c7a2e Mon Sep 17 00:00:00 2001 From: kborchers Date: Tue, 29 May 2012 23:11:42 -0500 Subject: [PATCH 30/33] Dialog: Use new uniqueId method for generating id's --- tests/unit/dialog/dialog_core.js | 21 +++------------------ ui/jquery.ui.dialog.js | 12 ++++++------ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index 5d7beb99b..636b957e8 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -89,26 +89,11 @@ function margin(el, side) { module("dialog: core"); test("title id", function() { - expect(3); - - var titleId; - - // reset the uuid so we know what values to expect - $.ui.dialog.uuid = 0; + expect(1); el = $('
      ').dialog(); - titleId = dlg().find('.ui-dialog-title').attr('id'); - equal(titleId, 'ui-dialog-title-1', 'auto-numbered title id'); - el.remove(); - - el = $('
      ').dialog(); - titleId = dlg().find('.ui-dialog-title').attr('id'); - equal(titleId, 'ui-dialog-title-2', 'auto-numbered title id'); - el.remove(); - - el = $('
      ').dialog(); - titleId = dlg().find('.ui-dialog-title').attr('id'); - equal(titleId, 'ui-dialog-title-foo', 'carried over title id'); + var titleId = dlg().find('.ui-dialog-title').attr('id'); + ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id'); el.remove(); }); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index e48c26400..4ef8a20cb 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -87,7 +87,6 @@ $.widget("ui.dialog", { options = this.options, title = options.title || " ", - titleId = $.ui.dialog.getTitleId( this.element ), uiDialog = ( this.uiDialog = $( "
      " ) ) .addClass( uiDialogClasses + options.dialogClass ) @@ -105,10 +104,6 @@ $.widget("ui.dialog", { event.preventDefault(); } }) - .attr({ - role: "dialog", - "aria-labelledby": titleId - }) .mousedown(function( event ) { that.moveToTop( false, event ); }) @@ -140,8 +135,8 @@ $.widget("ui.dialog", { .appendTo( uiDialogTitlebarClose ), uiDialogTitle = $( "" ) + .uniqueId() .addClass( "ui-dialog-title" ) - .attr( "id", titleId ) .html( title ) .prependTo( uiDialogTitlebar ), @@ -152,6 +147,11 @@ $.widget("ui.dialog", { .addClass( "ui-dialog-buttonset" ) .appendTo( uiDialogButtonPane ); + uiDialog.attr({ + role: "dialog", + "aria-labelledby": uiDialogTitle.attr( "id" ) + }); + uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection(); this._hoverable( uiDialogTitlebarClose ); this._focusable( uiDialogTitlebarClose ); From fe567eb9584892b3a035f74d5f75c149576fe1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 29 May 2012 17:55:24 -0400 Subject: [PATCH 31/33] Tabs: Properly remove generated aria-controls attributes on destroy. --- ui/jquery.ui.tabs.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 79587bba6..a64dca6e4 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -247,7 +247,9 @@ $.widget( "ui.tabs", { if ( panel.length) { that.panels = that.panels.add( panel ); } - tab.attr( "aria-controls", selector.substring( 1 ) ); + tab + .data( "ui-tabs-aria-controls", tab.attr( "aria-controls" ) ) + .attr( "aria-controls", selector.substring( 1 ) ); }); }, @@ -488,8 +490,17 @@ $.widget( "ui.tabs", { "ui-tabs-panel", "ui-widget-content", "ui-corner-bottom" - ].join( " " ) ) - .removeAttr( "aria-controls" ); + ].join( " " ) ); + } + }); + + this.lis.each(function() { + var li = $( this ), + prev = li.data( "ui-tabs-aria-controls" ); + if ( prev ) { + li.attr( "aria-controls", prev ); + } else { + li.removeAttr( "aria-controls" ); } }); From f5954fcd743079058dd0b2113dca3c029072e4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 30 May 2012 08:08:12 -0400 Subject: [PATCH 32/33] Menu tests: Anchor the regex for aria-activedescendant check. --- tests/unit/menu/menu_core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index 6dab6addd..7732fd7b7 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -23,7 +23,7 @@ test("accessibility", function () { item = menu.find( "li:last" ); menu.menu( "focus", $.Event(), item ); - ok( /ui-id-\d+$/.test( menu.attr( "aria-activedescendant" ) ), "aria attribute, generated id"); + ok( /^ui-id-\d+$/.test( menu.attr( "aria-activedescendant" ) ), "aria attribute, generated id"); }); })(jQuery); From e0fe788ee0c0c0d8d23f9d90b9acff713ba1302f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 30 May 2012 14:40:03 +0200 Subject: [PATCH 33/33] Accordion: Update activate and beforeActivate event properties to newPanel/oldPanel (instead of content). Fixes #6840 and #6842 --- tests/unit/accordion/accordion_events.js | 46 ++++++++++++------------ ui/jquery.ui.accordion.js | 24 +++++++++---- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 079c71a62..b67f2b26d 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -56,11 +56,11 @@ test( "beforeActivate", function() { element.one( "accordionbeforeactivate", function( event, ui ) { ok( !( "originalEvent" in event ) ); equal( ui.oldHeader.length, 0 ); - equal( ui.oldContent.length, 0 ); + equal( ui.oldPanel.length, 0 ); equal( ui.newHeader.length, 1 ); strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); - equal( ui.newContent.length, 1 ); - strictEqual( ui.newContent[ 0 ], content[ 0 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); state( element, 0, 0, 0 ); }); element.accordion( "option", "active", 0 ); @@ -70,12 +70,12 @@ test( "beforeActivate", function() { equal( event.originalEvent.type, "click" ); equal( ui.oldHeader.length, 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); - equal( ui.oldContent.length, 1 ); - strictEqual( ui.oldContent[ 0 ], content[ 0 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); equal( ui.newHeader.length, 1 ); strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); - equal( ui.newContent.length, 1 ); - strictEqual( ui.newContent[ 0 ], content[ 1 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); state( element, 1, 0, 0 ); }); headers.eq( 1 ).click(); @@ -85,10 +85,10 @@ test( "beforeActivate", function() { ok( !( "originalEvent" in event ) ); equal( ui.oldHeader.length, 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); - equal( ui.oldContent.length, 1 ); - strictEqual( ui.oldContent[ 0 ], content[ 1 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); equal( ui.newHeader.length, 0 ); - equal( ui.newContent.length, 0 ); + equal( ui.newPanel.length, 0 ); state( element, 0, 1, 0 ); }); element.accordion( "option", "active", false ); @@ -97,11 +97,11 @@ test( "beforeActivate", function() { element.one( "accordionbeforeactivate", function( event, ui ) { ok( !( "originalEvent" in event ) ); equal( ui.oldHeader.length, 0 ); - equal( ui.oldContent.length, 0 ); + equal( ui.oldPanel.length, 0 ); equal( ui.newHeader.length, 1 ); strictEqual( ui.newHeader[ 0 ], headers[ 2 ] ); - equal( ui.newContent.length, 1 ); - strictEqual( ui.newContent[ 0 ], content[ 2 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 2 ] ); event.preventDefault(); state( element, 0, 0, 0 ); }); @@ -120,33 +120,33 @@ test( "activate", function() { element.one( "accordionactivate", function( event, ui ) { equal( ui.oldHeader.length, 0 ); - equal( ui.oldContent.length, 0 ); + equal( ui.oldPanel.length, 0 ); equal( ui.newHeader.length, 1 ); strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); - equal( ui.newContent.length, 1 ); - strictEqual( ui.newContent[ 0 ], content[ 0 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 0 ] ); }); element.accordion( "option", "active", 0 ); element.one( "accordionactivate", function( event, ui ) { equal( ui.oldHeader.length, 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); - equal( ui.oldContent.length, 1 ); - strictEqual( ui.oldContent[ 0 ], content[ 0 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 0 ] ); equal( ui.newHeader.length, 1 ); strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); - equal( ui.newContent.length, 1 ); - strictEqual( ui.newContent[ 0 ], content[ 1 ] ); + equal( ui.newPanel.length, 1 ); + strictEqual( ui.newPanel[ 0 ], content[ 1 ] ); }); headers.eq( 1 ).click(); element.one( "accordionactivate", function( event, ui ) { equal( ui.oldHeader.length, 1 ); strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); - equal( ui.oldContent.length, 1 ); - strictEqual( ui.oldContent[ 0 ], content[ 1 ] ); + equal( ui.oldPanel.length, 1 ); + strictEqual( ui.oldPanel[ 0 ], content[ 1 ] ); equal( ui.newHeader.length, 0 ); - equal( ui.newContent.length, 0 ); + equal( ui.newPanel.length, 0 ); }); element.accordion( "option", "active", false ); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 0f1455790..856b3ba4b 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -389,9 +389,9 @@ $.widget( "ui.accordion", { toHide = active.next(), eventData = { oldHeader: active, - oldContent: toHide, + oldPanel: toHide, newHeader: collapsing ? $() : clicked, - newContent: toShow + newPanel: toShow }; event.preventDefault(); @@ -437,8 +437,8 @@ $.widget( "ui.accordion", { }, _toggle: function( data ) { - var toShow = data.newContent, - toHide = this.prevShow.length ? this.prevShow : data.oldContent; + var toShow = data.newPanel, + toHide = this.prevShow.length ? this.prevShow : data.oldPanel; // handle activating a panel during the animation for another activation this.prevShow.add( this.prevHide ).stop( true, true ); @@ -524,7 +524,7 @@ $.widget( "ui.accordion", { }, _toggleComplete: function( data ) { - var toHide = data.oldContent; + var toHide = data.oldPanel; toHide .removeClass( "ui-accordion-content-active" ) @@ -676,9 +676,19 @@ if ( $.uiBackCompat !== false ) { } if ( type === "beforeActivate" ) { - ret = _trigger.call( this, "changestart", event, data ); + ret = _trigger.call( this, "changestart", event, { + oldHeader: data.oldHeader, + oldContent: data.oldPanel, + newHeader: data.newHeader, + newContent: data.newPanel + }); } else if ( type === "activate" ) { - ret = _trigger.call( this, "change", event, data ); + ret = _trigger.call( this, "change", event, { + oldHeader: data.oldHeader, + oldContent: data.oldPanel, + newHeader: data.newHeader, + newContent: data.newPanel + }); } return ret; };