From ddaa6a18c18c3f99d7c3ac78d410c5cd968b1ed6 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Tue, 23 Nov 2021 10:38:50 +0100 Subject: [PATCH] Fix missing Meta+D shortcut on Mac I also discovered and applied ways to make this code more compact. Bug: T294905 Change-Id: I1edc2b3b0a77e02bf8e7ac789cabe007c5f5c527 --- .../ui/dialogs/ve.ui.MWTransclusionDialog.js | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index 26b690ea0a..17bbf6ecef 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -246,31 +246,16 @@ ve.ui.MWTransclusionDialog.prototype.onReplacePart = function ( removed, added ) this.updateActionSet(); }; -/** - * @private - * @param {string} key - * @return {string} - */ -ve.ui.MWTransclusionDialog.prototype.getHotkeyCombo = function ( key ) { - return ( ve.getSystemPlatform() === 'mac' ? 'meta+' : 'ctrl+' ) + 'shift+' + key; -}; - /** * @private */ ve.ui.MWTransclusionDialog.prototype.setupHotkeyTriggers = function () { - var context = this; + var meta = ve.getSystemPlatform() === 'mac' ? 'meta+' : 'ctrl+'; this.hotkeyTriggers = {}; - this.hotkeyTriggers[ 'ctrl+d' ] = function () { - context.addTemplatePlaceholder(); - }; - this.hotkeyTriggers[ this.getHotkeyCombo( 'y' ) ] = function () { - context.addContent(); - }; - this.hotkeyTriggers[ this.getHotkeyCombo( 'd' ) ] = function () { - context.addParameter(); - }; + this.hotkeyTriggers[ meta + 'd' ] = this.addTemplatePlaceholder.bind( this ); + this.hotkeyTriggers[ meta + 'shift+y' ] = this.addContent.bind( this ); + this.hotkeyTriggers[ meta + 'shift+d' ] = this.addParameter.bind( this ); }; /**