DLynch has uploaded a new change for review.
https://gerrit.wikimedia.org/r/274984
Change subject: Dialog: trigger the primary action with ctrl-enter
......................................................................
Dialog: trigger the primary action with ctrl-enter
If a dialog has primary actions, trigger the first one when ctrl-enter is
pressed.
Bug: T125860
Change-Id: I6b5cee5e76ca534a8f124c99c7dc67fa64f42ab6
---
M src/Dialog.js
1 file changed, 11 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/84/274984/1
diff --git a/src/Dialog.js b/src/Dialog.js
index a4ada70..6630e56 100644
--- a/src/Dialog.js
+++ b/src/Dialog.js
@@ -135,10 +135,18 @@
* @param {jQuery.Event} e Key down event
*/
OO.ui.Dialog.prototype.onDialogKeyDown = function ( e ) {
- if ( e.which === OO.ui.Keys.ESCAPE ) {
+ var actions;
+ if ( e.which === OO.ui.Keys.ESCAPE && this.constructor.static.escapable
) {
this.executeAction( '' );
e.preventDefault();
e.stopPropagation();
+ } else if ( e.which === OO.ui.Keys.ENTER && e.ctrlKey ) {
+ actions = this.actions.get( { flags: 'primary', visible: true }
);
+ if ( actions.length > 0 ) {
+ this.executeAction( actions[ 0 ].getAction() );
+ e.preventDefault();
+ e.stopPropagation();
+ }
}
};
@@ -229,9 +237,7 @@
);
this.actions.add( this.getActionWidgets( actions ) );
- if ( this.constructor.static.escapable ) {
- this.$element.on( 'keydown',
this.onDialogKeyDownHandler );
- }
+ this.$element.on( 'keydown',
this.onDialogKeyDownHandler );
}, this );
};
@@ -242,9 +248,7 @@
// Parent method
return OO.ui.Dialog.parent.prototype.getTeardownProcess.call( this,
data )
.first( function () {
- if ( this.constructor.static.escapable ) {
- this.$element.off( 'keydown',
this.onDialogKeyDownHandler );
- }
+ this.$element.off( 'keydown',
this.onDialogKeyDownHandler );
this.actions.clear();
this.currentAction = null;
--
To view, visit https://gerrit.wikimedia.org/r/274984
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b5cee5e76ca534a8f124c99c7dc67fa64f42ab6
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits