jenkins-bot has submitted this change and it was merged.

Change subject: Accessibility attributes for ULS trigger
......................................................................


Accessibility attributes for ULS trigger

Bug: 50575
Change-Id: I07a6fa740e6dcdcb0fd4ae8832ba0ad6fd875170
---
M resources/js/ext.uls.interface.js
1 file changed, 43 insertions(+), 0 deletions(-)

Approvals:
  Santhosh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.uls.interface.js 
b/resources/js/ext.uls.interface.js
index 02aca37..30aa4f5 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -113,6 +113,44 @@
        }
 
        /**
+        * Helper function to make the uls triggers accessible with the 
keyboard.
+        * @param {jQuery} $target One or more jQuery elements.
+        * @since 2013.07
+        */
+       function addAccessibilityFeatures( $target ) {
+               // tabindex=0 makes it appear when tabbing targets.
+               // See also http://www.w3.org/TR/wai-aria/roles#button
+               $target.attr( {
+                       tabIndex: 0,
+                       role: 'button',
+                       'aria-haspopup': true
+               } );
+               // TODO:
+               // * aria-pressed true/false when popup is open
+               // * aria-controls to reference to the popup
+
+               // Remove outline when clicking
+               $target.click( function () {
+                       $( this ).css( 'outline', 'none' );
+               } );
+               // Allow outline to appear again if keyboard activated
+               $target.blur( function () {
+                       $( this ).css( 'outline', '' );
+               } );
+
+               // Make Enter act the same as clicking. This has the 
unfortunate side
+               // effect of removing the outline.
+               $target.keydown( function ( event ) {
+                       // Enter
+                       if ( event.keyCode === 13 ) {
+                               $( this ).click();
+                               event.preventDefault();
+                               event.stopPropagation();
+                       }
+               } );
+       }
+
+       /**
         * The tooltip to be shown when language changed using ULS
         * It also allows to undo the language selection.
         */
@@ -226,6 +264,7 @@
        $( document ).ready( function () {
                mw.uls.init( function () {
                        var $ulsSettingsTrigger,
+                               $triggers,
                                $pLang,
                                ulsOptions,
                                $ulsTrigger = $( '.uls-trigger' ),
@@ -320,6 +359,10 @@
                                $ulsTrigger.uls( ulsOptions );
                        }
 
+                       // At this point we don't care which kind of trigger it 
is
+                       $triggers = $( '.uls-settings-trigger, .uls-trigger' );
+                       addAccessibilityFeatures( $triggers );
+
                        // Bind language settings to preferences page link
                        $( '#uls-preferences-link' )
                                .text( $.i18n( 
'ext-uls-language-settings-preferences-link' ) )

-- 
To view, visit https://gerrit.wikimedia.org/r/71784
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I07a6fa740e6dcdcb0fd4ae8832ba0ad6fd875170
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Pginer <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to