From 79151572ae6e4d3fc44f43061f6e78ef59d03741 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 15 Nov 2024 12:22:50 +0000 Subject: [PATCH] Remove unnecessary local context variables Change-Id: Ia8e9d9b750f3d9cc1ab9859afe0cb5c6084058df --- modules/insertlink/TitleInputWidget.js | 5 ++--- modules/jquery.wikiEditor.dialogs.config.js | 13 +++++-------- modules/realtimepreview/ResizingDragBar.js | 7 +++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/insertlink/TitleInputWidget.js b/modules/insertlink/TitleInputWidget.js index 0ef43612..48f38b46 100644 --- a/modules/insertlink/TitleInputWidget.js +++ b/modules/insertlink/TitleInputWidget.js @@ -50,19 +50,18 @@ TitleInputWidget.prototype.onLookupInputBlur = function () { * @public */ TitleInputWidget.prototype.selectFirstMatch = function () { - const that = this; this.getLookupMenuItems().done( ( items ) => { // The matching item is not always the first, // because disambiguation pages are moved to the end. for ( let i = 0; i < items.length; i++ ) { const item = items[ i ]; - const queryVal = that.getQueryValue(); + const queryVal = this.getQueryValue(); // Check for exact match, or a match with uppercase first character. if ( item.getData() === queryVal || item.getData() === queryVal.charAt( 0 ).toUpperCase() + queryVal.slice( 1 ) ) { // If a matching title is is found, fire an event and stop looking. - that.emit( 'select', item ); + this.emit( 'select', item ); break; } } diff --git a/modules/jquery.wikiEditor.dialogs.config.js b/modules/jquery.wikiEditor.dialogs.config.js index 3f62fd85..004031c0 100644 --- a/modules/jquery.wikiEditor.dialogs.config.js +++ b/modules/jquery.wikiEditor.dialogs.config.js @@ -148,8 +148,6 @@ module.exports = { class: 'wikieditor-toolbar-tool-link-insert', text: mw.msg( 'wikieditor-toolbar-tool-link-insert' ), click: function () { - const that = this; - function escapeInternalText( s ) { return s.replace( /(\]{2,})/g, '$1' ); } @@ -192,6 +190,7 @@ module.exports = { const match = target.match( $( this ).data( 'articlePathRegex' ) ); if ( match && !$( this ).data( 'ignoreLooksInternal' ) ) { const buttons = {}; + const linkDialog = this; buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-int' ) ] = function () { let titleValue = match[ 1 ]; @@ -209,9 +208,9 @@ module.exports = { }; buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-ext' ) ] = function () { - $( that ).data( 'ignoreLooksInternal', true ); - $( that ).closest( '.ui-dialog' ).find( 'button' ).first().trigger( 'click' ); - $( that ).data( 'ignoreLooksInternal', false ); + $( linkDialog ).data( 'ignoreLooksInternal', true ); + $( linkDialog ).closest( '.ui-dialog' ).find( 'button' ).first().trigger( 'click' ); + $( linkDialog ).data( 'ignoreLooksInternal', false ); $( this ).dialog( 'close' ); }; $.wikiEditor.modules.dialogs.quickDialog( @@ -911,7 +910,6 @@ module.exports = { } }, open: function () { - let that = this; $( this ).data( { offset: 0, matchIndex: 0 } ); const $dialog = $( this ).closest( '.ui-dialog' ); @@ -933,7 +931,6 @@ module.exports = { $dialog.data( 'dialogaction', e.delegateTarget ); } ); } - that = this; const $textarea = $( this ).data( 'context' ).$textarea; $textarea .on( 'keypress.srdialog', ( e ) => { @@ -943,7 +940,7 @@ module.exports = { e.preventDefault(); } else if ( e.which === 27 ) { // Escape - $( that ).dialog( 'close' ); + $( this ).dialog( 'close' ); } } ); }, diff --git a/modules/realtimepreview/ResizingDragBar.js b/modules/realtimepreview/ResizingDragBar.js index 27ace43a..aee2fb10 100644 --- a/modules/realtimepreview/ResizingDragBar.js +++ b/modules/realtimepreview/ResizingDragBar.js @@ -18,7 +18,6 @@ function ResizingDragBar( config ) { // * ext-WikiEditor-ResizingDragBar-ns this.$element.addClass( classNameDir ); - const resizingDragBar = this; // Determine the horizontal direction to move (flexbox automatically reverses but the offset direction doesn't). const rtlFactor = config.isEW && OO.ui.Element.static.getDir( document ) === 'rtl' ? -1 : 1; this.$element.on( 'mousedown', ( eventMousedown ) => { @@ -35,18 +34,18 @@ function ResizingDragBar( config ) { // Handle the actual dragging. $( document ).on( 'mousemove.' + classNameDir, ( eventMousemove ) => { // Initial width or height of the pane. - const startSize = resizingDragBar.getResizedPane()[ widthOrHeight ](); + const startSize = this.getResizedPane()[ widthOrHeight ](); // Current position of the mouse (relative to page, not viewport). const newOffset = eventMousemove[ xOrY ]; // Distance the mouse has moved. const change = rtlFactor * ( lastOffset - newOffset ); // Set the new size of the pane, and tell others about it. const newSize = Math.max( startSize - change, ResizingDragBar.static.MIN_PANE_SIZE ); - resizingDragBar.getResizedPane().css( widthOrHeight, newSize ); + this.getResizedPane().css( widthOrHeight, newSize ); // Save the new starting point of the mouse, from which to calculate the next move. lastOffset = newOffset; // Let other scripts do things after the resize. - mw.hook( 'ext.WikiEditor.realtimepreview.resize' ).fire( resizingDragBar ); + mw.hook( 'ext.WikiEditor.realtimepreview.resize' ).fire( this ); } ); } ); // Add a UI affordance within the handle area (CSS gives it its appearance).