Make image list keyboard accessible in gallery dialog

Bug: T140874
Change-Id: I0f00f1ddb397fb8f543a04d62b94fc5db32180f6
This commit is contained in:
Thalia 2016-08-04 14:19:18 -07:00
parent e7a3451931
commit 7d4864729b

View file

@ -34,8 +34,12 @@ ve.ui.MWGalleryItemWidget = function VeUiMWGalleryItemWidget( imageInfo, config
// Mixin constructors // Mixin constructors
OO.ui.mixin.DraggableElement.call( this, ve.extendObject( { $handle: this.$element }, this.config ) ); OO.ui.mixin.DraggableElement.call( this, ve.extendObject( { $handle: this.$element }, this.config ) );
OO.ui.mixin.TabIndexedElement.call( this, config );
this.$element.on( 'click', this.onItemClick.bind( this ) ); this.$element.on( {
click: this.onItemClick.bind( this ),
keypress: this.onItemKeyPress.bind( this )
} );
}; };
/* Inheritance */ /* Inheritance */
@ -43,6 +47,7 @@ ve.ui.MWGalleryItemWidget = function VeUiMWGalleryItemWidget( imageInfo, config
OO.inheritClass( ve.ui.MWGalleryItemWidget, OO.ui.Widget ); OO.inheritClass( ve.ui.MWGalleryItemWidget, OO.ui.Widget );
OO.mixinClass( ve.ui.MWGalleryItemWidget, OO.ui.mixin.DraggableElement ); OO.mixinClass( ve.ui.MWGalleryItemWidget, OO.ui.mixin.DraggableElement );
OO.mixinClass( ve.ui.MWGalleryItemWidget, OO.ui.mixin.TabIndexedElement );
/* Events */ /* Events */
@ -59,6 +64,18 @@ ve.ui.MWGalleryItemWidget.prototype.onItemClick = function () {
this.emit( 'edit', this ); this.emit( 'edit', this );
}; };
/**
* Handle key press events
*
* @param {jQuery.Event} e Key press event
*/
ve.ui.MWGalleryItemWidget.prototype.onItemKeyPress = function ( e ) {
if ( e.which === OO.ui.Keys.ENTER ) {
this.emit( 'edit', this );
return false;
}
};
/** /**
* Set the caption property * Set the caption property
* *