From 1d68f1339975e5c3f725c8860870d402cbcfec27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 18:54:38 +0100 Subject: [PATCH 1/8] Accordion: Use _bind for keydown handler --- ui/jquery.ui.accordion.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 5a49d7813..f4747d168 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -42,6 +42,9 @@ $.widget( "ui.accordion", { .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ); this._hoverable( this.headers ); this._focusable( this.headers ); + this._bind( this.headers, { + keydown: "_keydown" + }); this.headers.next() .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ); @@ -68,8 +71,6 @@ $.widget( "ui.accordion", { this.headers .attr( "role", "tab" ) - // TODO: use _bind() - .bind( "keydown.accordion", $.proxy( this, "_keydown" ) ) .next() .attr( "role", "tabpanel" ); From 050958277317cf127b98f8ac26f70f57cf147b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 19:17:09 +0100 Subject: [PATCH 2/8] Accordion: Fix unbinding of accordion event option when dealing with multiple events. Make sure to unbind only those namespaced to .accordion --- tests/unit/accordion/accordion_options.js | 1 + ui/jquery.ui.accordion.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 8206b1d62..74a9a3177 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -152,6 +152,7 @@ test( "{ event: custom }", function() { // ensure old event handlers are unbound element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" ); + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" ); equal( element.accordion( "option", "active" ), 2 ); accordion_state( element, 0, 0, 1 ); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index f4747d168..bf8434c6d 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -162,8 +162,7 @@ $.widget( "ui.accordion", { if ( key === "event" ) { if ( this.options.event ) { - // TODO: this is incorrect for multiple events (see _setupEvents) - this.headers.unbind( this.options.event + ".accordion", this._eventHandler ); + this.headers.unbind( this.options.event.split( " " ).join( ".accordion " ) + ".accordion", this._eventHandler ); } this._setupEvents( value ); } From 397176da3ecdbcb15adc9a259cbbb59f029a711f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 19:28:42 +0100 Subject: [PATCH 3/8] Accordion: Remove disabled check in _keydown, covered by _bind --- ui/jquery.ui.accordion.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index bf8434c6d..e3e09c9f4 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -192,8 +192,7 @@ $.widget( "ui.accordion", { }, _keydown: function( event ) { - // TODO: remove disabled check when using _bind() - if ( this.options.disabled || event.altKey || event.ctrlKey ) { + if ( event.altKey || event.ctrlKey ) { return; } From 724772e591e9e721b33c7e2739649b9c5d7a4246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 19:45:20 +0100 Subject: [PATCH 4/8] Accordion: Update test helper to use QUnit.push instead of deepEqual to get useful stacktrace --- tests/unit/accordion/accordion_test_helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/accordion/accordion_test_helpers.js b/tests/unit/accordion/accordion_test_helpers.js index 7b316e983..542809ea0 100644 --- a/tests/unit/accordion/accordion_test_helpers.js +++ b/tests/unit/accordion/accordion_test_helpers.js @@ -3,7 +3,7 @@ function accordion_state( accordion ) { var actual = accordion.find( ".ui-accordion-content" ).map(function() { return $( this ).css( "display" ) === "none" ? 0 : 1; }).get(); - deepEqual( actual, expected ); + QUnit.push( QUnit.equiv(actual, expected), actual, expected ); } function accordion_equalHeights( accordion, min, max ) { From c7cf13f5ed42823fc52eae6f6376438af8467a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 19:54:06 +0100 Subject: [PATCH 5/8] Accordion: Update method tests - active option still works when accordion is disabled --- tests/unit/accordion/accordion_methods.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 9f61647c4..2f4722070 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -10,15 +10,19 @@ test( "destroy", function() { }); test( "enable/disable", function() { - expect( 3 ); + expect( 4 ); var element = $( "#list1" ).accordion(); accordion_state( element, 1, 0, 0 ); element.accordion( "disable" ); - element.accordion( "option", "active", 1 ); + // event does nothing + element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); accordion_state( element, 1, 0, 0 ); - element.accordion( "enable" ); + // option still works element.accordion( "option", "active", 1 ); accordion_state( element, 0, 1, 0 ); + element.accordion( "enable" ); + element.accordion( "option", "active", 2 ); + accordion_state( element, 0, 0, 1 ); }); test( "refresh", function() { From 17db755a4f04dfc7b0be8d9a5c290cc5bc48e08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 7 Mar 2012 20:00:02 +0100 Subject: [PATCH 6/8] Accordion: Use _bind for event option. Refactor other _bind call to go into _setupEvents as well, simplifying unbinding a lot. Also add missing semicolon --- ui/jquery.ui.accordion.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index e3e09c9f4..1920063c4 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -42,9 +42,6 @@ $.widget( "ui.accordion", { .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" ); this._hoverable( this.headers ); this._focusable( this.headers ); - this._bind( this.headers, { - keydown: "_keydown" - }); this.headers.next() .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ); @@ -59,7 +56,7 @@ $.widget( "ui.accordion", { } this.active = this._findActive( options.active ) .addClass( "ui-accordion-header-active ui-state-active" ) - .toggleClass( "ui-corner-all ui-corner-top" ) + .toggleClass( "ui-corner-all ui-corner-top" ); this.active.next().addClass( "ui-accordion-content-active" ); this._createIcons(); @@ -162,7 +159,7 @@ $.widget( "ui.accordion", { if ( key === "event" ) { if ( this.options.event ) { - this.headers.unbind( this.options.event.split( " " ).join( ".accordion " ) + ".accordion", this._eventHandler ); + this.headers.unbind( ".accordion" ); } this._setupEvents( value ); } @@ -301,11 +298,15 @@ $.widget( "ui.accordion", { }, _setupEvents: function( event ) { + var events = { + keydown: "_keydown" + }; if ( event ) { - // TODO: use _bind() - this.headers.bind( event.split( " " ).join( ".accordion " ) + ".accordion", - $.proxy( this, "_eventHandler" ) ); + $.each( event.split(" "), function( index, eventName ) { + events[ eventName ] = "_eventHandler"; + }); } + this._bind( this.headers, events ); }, _eventHandler: function( event ) { @@ -325,7 +326,7 @@ $.widget( "ui.accordion", { event.preventDefault(); - if ( options.disabled || + if ( // click on active header, but not collapsible ( clickedIsActive && !options.collapsible ) || // allow canceling activation From 5c53dd1bbc0cb0897d4851bad77c3fe22fda27dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harri=20Kilpio=CC=88?= Date: Thu, 8 Mar 2012 22:52:22 +0200 Subject: [PATCH 7/8] Datepicker: Corrected values of dayNamesShort in Finnish translation. Fixes #8194 - Datepicker: Incorrect day name for Finnish localization. --- ui/i18n/jquery.ui.datepicker-fi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-fi.js b/ui/i18n/jquery.ui.datepicker-fi.js index 1eae6c23b..4c5adda35 100644 --- a/ui/i18n/jquery.ui.datepicker-fi.js +++ b/ui/i18n/jquery.ui.datepicker-fi.js @@ -1,5 +1,5 @@ /* Finnish initialisation for the jQuery UI date picker plugin. */ -/* Written by Harri Kilpi� (harrikilpio@gmail.com). */ +/* Written by Harri Kilpiö (harrikilpio@gmail.com). */ jQuery(function($){ $.datepicker.regional['fi'] = { closeText: 'Sulje', @@ -10,7 +10,7 @@ jQuery(function($){ 'Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'], monthNamesShort: ['Tammi','Helmi','Maalis','Huhti','Touko','Kesä', 'Heinä','Elo','Syys','Loka','Marras','Joulu'], - dayNamesShort: ['Su','Ma','Ti','Ke','To','Pe','Su'], + dayNamesShort: ['Su','Ma','Ti','Ke','To','Pe','La'], dayNames: ['Sunnuntai','Maanantai','Tiistai','Keskiviikko','Torstai','Perjantai','Lauantai'], dayNamesMin: ['Su','Ma','Ti','Ke','To','Pe','La'], weekHeader: 'Vk', From 11b026d59b5d1f6f5cd55570c7148b2a33322c53 Mon Sep 17 00:00:00 2001 From: kborchers Date: Sun, 18 Mar 2012 21:18:00 -0500 Subject: [PATCH 8/8] Menu: Better disabled item handling using preventDefault() for the click event on anchors inside of disabled menu items and change the pointer to default --- themes/base/jquery.ui.menu.css | 1 + ui/jquery.ui.menu.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/themes/base/jquery.ui.menu.css b/themes/base/jquery.ui.menu.css index 84d7d85b1..1e559e661 100644 --- a/themes/base/jquery.ui.menu.css +++ b/themes/base/jquery.ui.menu.css @@ -15,6 +15,7 @@ .ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; } .ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; } +.ui-menu .ui-state-disabled a { cursor: default; } /* icon support */ .ui-menu-icons { position: relative; } diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 18f4eb9f8..17177a906 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -59,6 +59,9 @@ $.widget( "ui.menu", { "mousedown .ui-menu-item > a": function( event ) { event.preventDefault(); }, + "click .ui-state-disabled > a": function( event ) { + event.preventDefault(); + }, "click .ui-menu-item:has(a)": function( event ) { event.stopImmediatePropagation(); //Don't select disabled menu items