Index: branches/liangent/makeCollapsible_custom/phase3/resources/jquery/jquery.makeCollapsible.js |
— | — | @@ -268,6 +268,15 @@ |
269 | 269 | $customTogglers.bind( 'click.mw-collapse', function( e ) { |
270 | 270 | toggleLinkCustom( $(this), e, $that ); |
271 | 271 | } ); |
| 272 | + |
| 273 | + // If there's no link for users using keyboard navigation |
| 274 | + if ( !$customTogglers.is( 'a' ) && !$customTogglers.find( 'a' ).length ) { |
| 275 | + $customTogglers.attr( 'tabindex', '0' ).bind( 'keydown.mw-collapse', function( e ) { |
| 276 | + if ( e.which === 13 ) { // Enter key |
| 277 | + toggleLinkCustom( $(this), e, $that ); |
| 278 | + } |
| 279 | + } ); |
| 280 | + } |
272 | 281 | } else { |
273 | 282 | mw.log( _fn + '#' + thatId + ': Missing toggler!' ); |
274 | 283 | } |
— | — | @@ -289,6 +298,15 @@ |
290 | 299 | $customTogglers.bind( 'click.mw-collapse', function( e ) { |
291 | 300 | toggleLinkCustom( $(this), e, $that ); |
292 | 301 | } ); |
| 302 | + |
| 303 | + // If there's no link for users using keyboard navigation |
| 304 | + if ( !$customTogglers.is( 'a' ) && !$customTogglers.find( 'a' ).length ) { |
| 305 | + $customTogglers.attr( 'tabindex', '0' ).bind( 'keydown.mw-collapse', function( e ) { |
| 306 | + if ( e.which === 13 ) { // Enter key |
| 307 | + toggleLinkCustom( $(this), e, $that ); |
| 308 | + } |
| 309 | + } ); |
| 310 | + } |
293 | 311 | } else { |
294 | 312 | mw.log( _fn + '.mw-customcollapsiblechildren: Missing toggler!' ); |
295 | 313 | } |