jenkins-bot has submitted this change and it was merged.
Change subject: Make ButtonWidgets more accessible
......................................................................
Make ButtonWidgets more accessible
* Give them a role=button, and a default tabIndex of 0
* Listen for a keypress of 'space' and emit a click event
(you'd have thought role=button would do this, but oh well)
Bug: 50047
Change-Id: I429ad165c95f34d26975daf81db18cc966802cde
---
M modules/ve/ui/widgets/ve.ui.ButtonWidget.js
M modules/ve/ve.js
2 files changed, 22 insertions(+), 1 deletion(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ui/widgets/ve.ui.ButtonWidget.js
b/modules/ve/ui/widgets/ve.ui.ButtonWidget.js
index 7def19a..1b98ce9 100644
--- a/modules/ve/ui/widgets/ve.ui.ButtonWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.ButtonWidget.js
@@ -15,6 +15,7 @@
*
* @constructor
* @param {Object} [config] Config options
+ * @cfg {number} [tabIndex] Button's tab index
*/
ve.ui.ButtonWidget = function VeUiButtonWidget( config ) {
// Parent constructor
@@ -26,8 +27,13 @@
// Events
this.$.on( 'click', ve.bind( this.onClick, this ) );
+ this.$.on( 'keypress', ve.bind( this.onKeyPress, this ) );
// Initialization
+ this.$.attr( {
+ 'role': 'button',
+ 'tabIndex': config.tabIndex || 0
+ } );
this.$.addClass( 've-ui-buttonWidget' ).append( this.$label );
};
@@ -60,3 +66,17 @@
}
return false;
};
+
+/**
+ * Handles keypress events.
+ *
+ * @method
+ * @param {jQuery.Event} e Keypress event
+ * @emits click
+ */
+ve.ui.ButtonWidget.prototype.onKeyPress = function ( e ) {
+ if ( !this.disabled && e.which === ve.Keys.SPACE ) {
+ this.emit( 'click' );
+ }
+ return false;
+};
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index 6a0c5da..01d4f24 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -1011,7 +1011,8 @@
'PAGEUP': 33,
'PAGEDOWN': 34,
'ESCAPE': 27,
- 'SHIFT': 16
+ 'SHIFT': 16,
+ 'SPACE': 32
};
// Expose
--
To view, visit https://gerrit.wikimedia.org/r/75594
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I429ad165c95f34d26975daf81db18cc966802cde
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits