Index: trunk/phase3/skins/vector/vector.js |
— | — | @@ -2,18 +2,35 @@ |
3 | 3 | * Vector-specific scripts |
4 | 4 | */ |
5 | 5 | jQuery( function( $ ) { |
6 | | - var $pCactions = $( '#p-cactions' ); |
7 | | - $pCactions.find( 'h5 a' ) |
8 | | - // For accessibility, show the menu when the hidden link in the menu is clicked (bug 24298) |
9 | | - .click( function( e ) { |
10 | | - $pCactions.find( '.menu' ).toggleClass( 'menuForceShow' ); |
11 | | - e.preventDefault(); |
12 | | - }) |
13 | | - // When the hidden link has focus, also set a class that will change the arrow icon |
14 | | - .focus( function() { |
15 | | - $pCactions.addClass( 'vectorMenuFocus' ); |
16 | | - }) |
17 | | - .blur( function() { |
18 | | - $pCactions.removeClass( 'vectorMenuFocus' ); |
19 | | - }); |
| 6 | + |
| 7 | + // For accessibility, show the menu whe |
| 8 | + // the hidden link in the menu is focused (bug 24298) |
| 9 | + $( 'div.vectorMenu' ).each( function() { |
| 10 | + var self = this; |
| 11 | + var focused = false; |
| 12 | + $( 'h5:first a:first', this ) |
| 13 | + .click( function( e ) { |
| 14 | + e.preventDefault(); |
| 15 | + } ) |
| 16 | + // Blur the link if it was focused before the click |
| 17 | + .mousedown( function( e ) { |
| 18 | + focused = $( this ).is( ':focus' ); |
| 19 | + } ) |
| 20 | + .mouseup( function( e ) { |
| 21 | + if ( focused ) { |
| 22 | + $( this ).blur(); |
| 23 | + } |
| 24 | + e.preventDefault(); |
| 25 | + } ) |
| 26 | + // When the hidden link has focus, show the menu |
| 27 | + // and set a class that will change the arrow icon |
| 28 | + .focus( function() { |
| 29 | + $( '.menu:first', self ).addClass( 'menuForceShow' ); |
| 30 | + $( self ).addClass( 'vectorMenuFocus' ); |
| 31 | + } ) |
| 32 | + .blur( function() { |
| 33 | + $( '.menu:first', self ).removeClass( 'menuForceShow' ); |
| 34 | + $( self ).removeClass( 'vectorMenuFocus' ); |
| 35 | + } ); |
| 36 | + } ); |
20 | 37 | }); |