Merge "Remove unnecessary local context variables"

This commit is contained in:
jenkins-bot 2024-11-22 15:40:06 +00:00 committed by Gerrit Code Review
commit 2b5a668cc6
3 changed files with 10 additions and 15 deletions

View file

@ -50,19 +50,18 @@ TitleInputWidget.prototype.onLookupInputBlur = function () {
* @public * @public
*/ */
TitleInputWidget.prototype.selectFirstMatch = function () { TitleInputWidget.prototype.selectFirstMatch = function () {
const that = this;
this.getLookupMenuItems().done( ( items ) => { this.getLookupMenuItems().done( ( items ) => {
// The matching item is not always the first, // The matching item is not always the first,
// because disambiguation pages are moved to the end. // because disambiguation pages are moved to the end.
for ( let i = 0; i < items.length; i++ ) { for ( let i = 0; i < items.length; i++ ) {
const item = items[ i ]; const item = items[ i ];
const queryVal = that.getQueryValue(); const queryVal = this.getQueryValue();
// Check for exact match, or a match with uppercase first character. // Check for exact match, or a match with uppercase first character.
if ( item.getData() === queryVal || if ( item.getData() === queryVal ||
item.getData() === queryVal.charAt( 0 ).toUpperCase() + queryVal.slice( 1 ) item.getData() === queryVal.charAt( 0 ).toUpperCase() + queryVal.slice( 1 )
) { ) {
// If a matching title is is found, fire an event and stop looking. // If a matching title is is found, fire an event and stop looking.
that.emit( 'select', item ); this.emit( 'select', item );
break; break;
} }
} }

View file

@ -148,8 +148,6 @@ module.exports = {
class: 'wikieditor-toolbar-tool-link-insert', class: 'wikieditor-toolbar-tool-link-insert',
text: mw.msg( 'wikieditor-toolbar-tool-link-insert' ), text: mw.msg( 'wikieditor-toolbar-tool-link-insert' ),
click: function () { click: function () {
const that = this;
function escapeInternalText( s ) { function escapeInternalText( s ) {
return s.replace( /(\]{2,})/g, '<nowiki>$1</nowiki>' ); return s.replace( /(\]{2,})/g, '<nowiki>$1</nowiki>' );
} }
@ -192,6 +190,7 @@ module.exports = {
const match = target.match( $( this ).data( 'articlePathRegex' ) ); const match = target.match( $( this ).data( 'articlePathRegex' ) );
if ( match && !$( this ).data( 'ignoreLooksInternal' ) ) { if ( match && !$( this ).data( 'ignoreLooksInternal' ) ) {
const buttons = {}; const buttons = {};
const linkDialog = this;
buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-int' ) ] = buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-int' ) ] =
function () { function () {
let titleValue = match[ 1 ]; let titleValue = match[ 1 ];
@ -209,9 +208,9 @@ module.exports = {
}; };
buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-ext' ) ] = buttons[ mw.msg( 'wikieditor-toolbar-tool-link-lookslikeinternal-ext' ) ] =
function () { function () {
$( that ).data( 'ignoreLooksInternal', true ); $( linkDialog ).data( 'ignoreLooksInternal', true );
$( that ).closest( '.ui-dialog' ).find( 'button' ).first().trigger( 'click' ); $( linkDialog ).closest( '.ui-dialog' ).find( 'button' ).first().trigger( 'click' );
$( that ).data( 'ignoreLooksInternal', false ); $( linkDialog ).data( 'ignoreLooksInternal', false );
$( this ).dialog( 'close' ); $( this ).dialog( 'close' );
}; };
$.wikiEditor.modules.dialogs.quickDialog( $.wikiEditor.modules.dialogs.quickDialog(
@ -911,7 +910,6 @@ module.exports = {
} }
}, },
open: function () { open: function () {
let that = this;
$( this ).data( { offset: 0, matchIndex: 0 } ); $( this ).data( { offset: 0, matchIndex: 0 } );
const $dialog = $( this ).closest( '.ui-dialog' ); const $dialog = $( this ).closest( '.ui-dialog' );
@ -933,7 +931,6 @@ module.exports = {
$dialog.data( 'dialogaction', e.delegateTarget ); $dialog.data( 'dialogaction', e.delegateTarget );
} ); } );
} }
that = this;
const $textarea = $( this ).data( 'context' ).$textarea; const $textarea = $( this ).data( 'context' ).$textarea;
$textarea $textarea
.on( 'keypress.srdialog', ( e ) => { .on( 'keypress.srdialog', ( e ) => {
@ -943,7 +940,7 @@ module.exports = {
e.preventDefault(); e.preventDefault();
} else if ( e.which === 27 ) { } else if ( e.which === 27 ) {
// Escape // Escape
$( that ).dialog( 'close' ); $( this ).dialog( 'close' );
} }
} ); } );
}, },

View file

@ -18,7 +18,6 @@ function ResizingDragBar( config ) {
// * ext-WikiEditor-ResizingDragBar-ns // * ext-WikiEditor-ResizingDragBar-ns
this.$element.addClass( classNameDir ); this.$element.addClass( classNameDir );
const resizingDragBar = this;
// Determine the horizontal direction to move (flexbox automatically reverses but the offset direction doesn't). // 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; const rtlFactor = config.isEW && OO.ui.Element.static.getDir( document ) === 'rtl' ? -1 : 1;
this.$element.on( 'mousedown', ( eventMousedown ) => { this.$element.on( 'mousedown', ( eventMousedown ) => {
@ -35,18 +34,18 @@ function ResizingDragBar( config ) {
// Handle the actual dragging. // Handle the actual dragging.
$( document ).on( 'mousemove.' + classNameDir, ( eventMousemove ) => { $( document ).on( 'mousemove.' + classNameDir, ( eventMousemove ) => {
// Initial width or height of the pane. // 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). // Current position of the mouse (relative to page, not viewport).
const newOffset = eventMousemove[ xOrY ]; const newOffset = eventMousemove[ xOrY ];
// Distance the mouse has moved. // Distance the mouse has moved.
const change = rtlFactor * ( lastOffset - newOffset ); const change = rtlFactor * ( lastOffset - newOffset );
// Set the new size of the pane, and tell others about it. // Set the new size of the pane, and tell others about it.
const newSize = Math.max( startSize - change, ResizingDragBar.static.MIN_PANE_SIZE ); 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. // Save the new starting point of the mouse, from which to calculate the next move.
lastOffset = newOffset; lastOffset = newOffset;
// Let other scripts do things after the resize. // 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). // Add a UI affordance within the handle area (CSS gives it its appearance).