Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/80927
Change subject: Accessibility: Make the collapsible sidebar screen reader
friendly
......................................................................
Accessibility: Make the collapsible sidebar screen reader friendly
Change-Id: I6dcd8d0a9ef5a1b62582b02d1b95e4635f4f4cf4
---
M modules/ext.vector.collapsibleNav.js
1 file changed, 34 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Vector
refs/changes/27/80927/1
diff --git a/modules/ext.vector.collapsibleNav.js
b/modules/ext.vector.collapsibleNav.js
index 49d8a15..dd2f6f2 100644
--- a/modules/ext.vector.collapsibleNav.js
+++ b/modules/ext.vector.collapsibleNav.js
@@ -7,9 +7,11 @@
// Use the same function for all navigation headings - don't repeat
function toggle( $element ) {
+ var isCollapsed = $element.parent().is( '.collapsed' );
+
$.cookie(
'vector-nav-' + $element.parent().attr( 'id' ),
- $element.parent().is( '.collapsed' ),
+ isCollapsed,
{ 'expires': 30, 'path': '/' }
);
$element
@@ -18,6 +20,14 @@
.toggleClass( 'collapsed' )
.find( '.body' )
.slideToggle( 'fast' );
+ isCollapsed = !isCollapsed;
+
+ $element
+ .find( '> a' )
+ .attr( {
+ 'aria-pressed': isCollapsed ? 'false' : 'true',
+ 'aria-expanded': isCollapsed ? 'false' : 'true'
+ } );
}
/* Browser Support */
@@ -136,7 +146,7 @@
$.cookie( 'accept-language',
langs.join( ',' ), {
path: '/',
expires: 30
- });
+ } );
}
);
}
@@ -193,8 +203,19 @@
.each( function ( i ) {
var id = $(this).attr( 'id' ),
state = $.cookie( 'vector-nav-' + id );
+
+ $(this).find( 'ul:first' ).attr( 'id', id +
'-list' );
// Add anchor tag to heading for better
accessibility
- $( this ).find( 'h3' ).wrapInner( $( '<a
href="#"></a>' ).click( false ) );
+ $( this ).find( 'h3' ).wrapInner(
+ $( '<a>' )
+ .attr( {
+ href: '#',
+ 'aria-haspopup': 'true',
+ 'aria-controls': id +
'-list',
+ role: 'button'
+ } )
+ .click( false )
+ );
// In the case that we are not showing the new
version, let's show the languages by default
if (
state === 'true' ||
@@ -207,10 +228,20 @@
.find( '.body' )
.hide() // bug 34450
.show();
+ $(this).find( 'h3 > a' )
+ .attr( {
+ 'aria-pressed': 'true',
+ 'aria-expanded': 'true'
+ } );
} else {
$(this)
.addClass( 'collapsed' )
.removeClass( 'expanded' );
+ $(this).find( 'h3 > a' )
+ .attr( {
+ 'aria-pressed': 'false',
+ 'aria-expanded': 'false'
+ } );
}
// Re-save cookie
if ( state !== null ) {
--
To view, visit https://gerrit.wikimedia.org/r/80927
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dcd8d0a9ef5a1b62582b02d1b95e4635f4f4cf4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Vector
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits