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
*/
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;
}
}

View file

@ -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, '<nowiki>$1</nowiki>' );
}
@ -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' );
}
} );
},

View file

@ -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).