Improve the accessibility of our jump-to functionality
authorDaniel Friesen <dantman@users.mediawiki.org>
Sun, 25 Sep 2011 00:49:39 +0000 (00:49 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Sun, 25 Sep 2011 00:49:39 +0000 (00:49 +0000)
- Stop hiding with display: none;, this hides our jump links from modern screen readers and users with motor disabilities (ie: nowadays, pratically everyone they are intended to help).
- Instead hide with an overflow that will make the links viable <tab> targets. This alone is enough to help screen reader users.
- Add in a script that will show the jump-links area on-focus for motor-impared users who can still see who have js enabled (this can't be done with css unfortunately)

resources/Resources.php
resources/jquery/jquery.mw-jump.js [new file with mode: 0644]
skins/MonoBook.php
skins/Vector.php
skins/common/commonInterface.css
skins/common/commonPrint.css
skins/common/shared.css

index 1d0a5a4..c6ffee8 100644 (file)
@@ -158,6 +158,9 @@ return array(
        'jquery.mwExtension' => array(
                'scripts' => 'resources/jquery/jquery.mwExtension.js',
        ),
+       'jquery.mw-jump' => array(
+               'scripts' => 'resources/jquery/jquery.mw-jump.js',
+       ),
        'jquery.qunit' => array(
                'scripts' => 'resources/jquery/jquery.qunit.js',
                'styles' => 'resources/jquery/jquery.qunit.css',
@@ -610,6 +613,7 @@ return array(
                        'jquery.checkboxShiftClick',
                        'jquery.makeCollapsible',
                        'jquery.placeholder',
+                       'jquery.mw-jump',
                        'mediawiki.util',
                ),
        ),
diff --git a/resources/jquery/jquery.mw-jump.js b/resources/jquery/jquery.mw-jump.js
new file mode 100644 (file)
index 0000000..36b6690
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * JavaScript to show jump links to motor-impaired users when they are focused.
+ */
+jQuery( function( $ ) {
+
+       $('.mw-jump').delegate( 'a', 'focus blur', function( e ) {
+               // Confusingly jQuery leaves e.type as "focusout" for delegated blur events
+               if ( e.type === "blur" || e.type === "focusout" ) {
+                       $( this ).closest( '.mw-jump' ).css({ height: '0' });
+               } else {
+                       $( this ).closest( '.mw-jump' ).css({ height: 'auto' });
+               }
+       } );
+
+} );
index 1e7988c..bd8a525 100644 (file)
@@ -80,7 +80,7 @@ class MonoBookTemplate extends BaseTemplate {
 <?php } ?><?php if($this->data['newtalk'] ) { ?>
                <div class="usermessage"><?php $this->html('newtalk')  ?></div>
 <?php } ?><?php if($this->data['showjumplinks']) { ?>
-               <div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
+               <div id="jump-to-nav" class="mw-jump"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div>
 <?php } ?>
                <!-- start content -->
 <?php $this->html('bodytext') ?>
index 9b09ca3..f0b14eb 100644 (file)
@@ -158,7 +158,7 @@ class VectorTemplate extends BaseTemplate {
                                <?php endif; ?>
                                <?php if ( $this->data['showjumplinks'] ): ?>
                                <!-- jumpto -->
-                               <div id="jump-to-nav">
+                               <div id="jump-to-nav" class="mw-jump">
                                        <?php $this->msg( 'jumpto' ) ?> <a href="#mw-head"><?php $this->msg( 'jumptonavigation' ) ?></a>,
                                        <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
                                </div>
index 8dde5d2..aedb471 100644 (file)
@@ -46,7 +46,9 @@
        display: none;
 }
 #jump-to-nav {
-       display: none;
+       /* Negate #contentSub's margin and replicate it so that the jump to links don't affect the spacing */
+       margin-top: -1.4em;
+       margin-bottom: 1.4em
 }
 #contentSub, #contentSub2 {
        font-size: 84%;
index 4cad47b..014788f 100644 (file)
@@ -114,6 +114,7 @@ body {
 
 .noprint,
 div#jump-to-nav,
+.mw-jump,
 div.top,
 div#column-one,
 #colophon,
index f19a127..f80f8ad 100644 (file)
@@ -1006,3 +1006,11 @@ table.floatleft {
 #mw-credits a {
        unicode-bidi: embed;
 }
+
+/* Accessibility */
+.mw-jump {
+       overflow: hidden;
+       height: 0;
+       zoom: 1; /* http://webaim.org/techniques/skipnav/#iequirk */
+}
+