From 7326ce854e7e57a875a34139b11fbac67fcf56ea Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 22 Mar 2019 19:40:53 +0100 Subject: [PATCH] resources: Rename a few local 'filterFn' vars to 'filterFunction' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Abbreviations are discouraged, so let’s use the full word. Change-Id: I31fb4cca32d766559005d1291d6d22da3d74b5e6 --- resources/src/jquery/jquery.lengthLimit.js | 32 +++++++++---------- resources/src/mediawiki.String.js | 16 +++++----- .../mediawiki.action.delete.file.js | 6 ++-- .../mediawiki.action.delete.js | 6 ++-- .../src/mediawiki.special.revisionDelete.js | 6 ++-- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/resources/src/jquery/jquery.lengthLimit.js b/resources/src/jquery/jquery.lengthLimit.js index 26f8f9b1f3..0e3394b69b 100644 --- a/resources/src/jquery/jquery.lengthLimit.js +++ b/resources/src/jquery/jquery.lengthLimit.js @@ -31,7 +31,7 @@ * function, if none, pass empty string. * @param {string} newVal New value that may have to be trimmed down. * @param {number} byteLimit Number of bytes the value may be in size. - * @param {Function} [filterFn] See jQuery#byteLimit. + * @param {Function} [filterFunction] See jQuery#byteLimit. * @return {Object} * @return {string} return.newVal * @return {boolean} return.trimmed @@ -39,18 +39,18 @@ mw.log.deprecate( $, 'trimByteLength', trimByteLength, 'Use require( \'mediawiki.String\' ).trimByteLength instead.', '$.trimByteLength' ); - function lengthLimit( trimFn, limit, filterFn ) { + function lengthLimit( trimFn, limit, filterFunction ) { var allowNativeMaxlength = trimFn === trimByteLength; // If the first argument is the function, - // set filterFn to the first argument's value and ignore the second argument. + // set filterFunction to the first argument's value and ignore the second argument. if ( typeof limit === 'function' ) { - filterFn = limit; + filterFunction = limit; limit = undefined; // Either way, verify it is a function so we don't have to call // isFunction again after this. - } else if ( !filterFn || typeof filterFn !== 'function' ) { - filterFn = undefined; + } else if ( !filterFunction || typeof filterFunction !== 'function' ) { + filterFunction = undefined; } // The following is specific to each element in the collection. @@ -79,15 +79,15 @@ return; } - if ( filterFn ) { + if ( filterFunction ) { // Save function for reference - $el.data( 'lengthLimit.callback', filterFn ); + $el.data( 'lengthLimit.callback', filterFunction ); } // Remove old event handlers (if there are any) $el.off( '.lengthLimit' ); - if ( filterFn || !allowNativeMaxlength ) { + if ( filterFunction || !allowNativeMaxlength ) { // Disable the native maxLength (if there is any), because it interferes // with the (differently calculated) character/byte limit. // Aside from being differently calculated, @@ -133,7 +133,7 @@ prevSafeVal, this.value, elLimit, - filterFn + filterFunction ); // Only set value property if it was trimmed, because whenever the @@ -175,12 +175,12 @@ * * @param {number} [limit] Limit to enforce, fallsback to maxLength-attribute, * called with fetched value as argument. - * @param {Function} [filterFn] Function to call on the string before assessing the length. + * @param {Function} [filterFunction] Function to call on the string before assessing the length. * @return {jQuery} * @chainable */ - $.fn.byteLimit = function ( limit, filterFn ) { - return lengthLimit.call( this, trimByteLength, limit, filterFn ); + $.fn.byteLimit = function ( limit, filterFunction ) { + return lengthLimit.call( this, trimByteLength, limit, filterFunction ); }; /** @@ -199,12 +199,12 @@ * * @param {number} [limit] Limit to enforce, fallsback to maxLength-attribute, * called with fetched value as argument. - * @param {Function} [filterFn] Function to call on the string before assessing the length. + * @param {Function} [filterFunction] Function to call on the string before assessing the length. * @return {jQuery} * @chainable */ - $.fn.codePointLimit = function ( limit, filterFn ) { - return lengthLimit.call( this, trimCodePointLength, limit, filterFn ); + $.fn.codePointLimit = function ( limit, filterFunction ) { + return lengthLimit.call( this, trimCodePointLength, limit, filterFunction ); }; /** diff --git a/resources/src/mediawiki.String.js b/resources/src/mediawiki.String.js index 5d9bef0632..5960f93fbd 100644 --- a/resources/src/mediawiki.String.js +++ b/resources/src/mediawiki.String.js @@ -148,16 +148,16 @@ * function, if none, pass empty string. * @param {string} newVal New value that may have to be trimmed down. * @param {number} byteLimit Number of bytes the value may be in size. - * @param {Function} [filterFn] Function to call on the string before assessing the length. + * @param {Function} [filterFunction] Function to call on the string before assessing the length. * @return {Object} * @return {string} return.newVal * @return {boolean} return.trimmed */ - function trimByteLength( safeVal, newVal, byteLimit, filterFn ) { + function trimByteLength( safeVal, newVal, byteLimit, filterFunction ) { var lengthFn; - if ( filterFn ) { + if ( filterFunction ) { lengthFn = function ( val ) { - return byteLength( filterFn( val ) ); + return byteLength( filterFunction( val ) ); }; } else { lengthFn = byteLength; @@ -177,16 +177,16 @@ * function, if none, pass empty string. * @param {string} newVal New value that may have to be trimmed down. * @param {number} codePointLimit Number of characters the value may be in size. - * @param {Function} [filterFn] Function to call on the string before assessing the length. + * @param {Function} [filterFunction] Function to call on the string before assessing the length. * @return {Object} * @return {string} return.newVal * @return {boolean} return.trimmed */ - function trimCodePointLength( safeVal, newVal, codePointLimit, filterFn ) { + function trimCodePointLength( safeVal, newVal, codePointLimit, filterFunction ) { var lengthFn; - if ( filterFn ) { + if ( filterFunction ) { lengthFn = function ( val ) { - return codePointLength( filterFn( val ) ); + return codePointLength( filterFunction( val ) ); }; } else { lengthFn = codePointLength; diff --git a/resources/src/mediawiki.action/mediawiki.action.delete.file.js b/resources/src/mediawiki.action/mediawiki.action.delete.file.js index 7996ea425d..a0505cc5a0 100644 --- a/resources/src/mediawiki.action/mediawiki.action.delete.file.js +++ b/resources/src/mediawiki.action/mediawiki.action.delete.file.js @@ -8,7 +8,7 @@ summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ), reasonList = OO.ui.infuse( $( '#wpDeleteReasonList' ).closest( '.oo-ui-widget' ) ), reason = OO.ui.infuse( $( '#wpReason' ).closest( '.oo-ui-widget' ) ), - filterFn = function ( input ) { + filterFunction = function ( input ) { // Should be built the same as in SpecialRevisionDelete::submit() var comment = reasonList.getValue(); if ( comment === 'other' ) { @@ -22,9 +22,9 @@ // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration if ( summaryCodePointLimit ) { - reason.$input.codePointLimit( summaryCodePointLimit, filterFn ); + reason.$input.codePointLimit( summaryCodePointLimit, filterFunction ); } else if ( summaryByteLimit ) { - reason.$input.byteLimit( summaryByteLimit, filterFn ); + reason.$input.byteLimit( summaryByteLimit, filterFunction ); } } ); diff --git a/resources/src/mediawiki.action/mediawiki.action.delete.js b/resources/src/mediawiki.action/mediawiki.action.delete.js index a7228edd50..f125748237 100644 --- a/resources/src/mediawiki.action/mediawiki.action.delete.js +++ b/resources/src/mediawiki.action/mediawiki.action.delete.js @@ -8,7 +8,7 @@ summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ), reasonList = OO.ui.infuse( $( '#wpDeleteReasonList' ).closest( '.oo-ui-widget' ) ), reason = OO.ui.infuse( $( '#wpReason' ).closest( '.oo-ui-widget' ) ), - filterFn = function ( input ) { + filterFunction = function ( input ) { // Should be built the same as in Article::delete() var comment = reasonList.getValue(); if ( comment === 'other' ) { @@ -22,9 +22,9 @@ // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration if ( summaryCodePointLimit ) { - reason.$input.codePointLimit( summaryCodePointLimit, filterFn ); + reason.$input.codePointLimit( summaryCodePointLimit, filterFunction ); } else if ( summaryByteLimit ) { - reason.$input.byteLimit( summaryByteLimit, filterFn ); + reason.$input.byteLimit( summaryByteLimit, filterFunction ); } } ); }() ); diff --git a/resources/src/mediawiki.special.revisionDelete.js b/resources/src/mediawiki.special.revisionDelete.js index e9b0e6a0ea..6552750418 100644 --- a/resources/src/mediawiki.special.revisionDelete.js +++ b/resources/src/mediawiki.special.revisionDelete.js @@ -7,7 +7,7 @@ summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ), $wpRevDeleteReasonList = $( '#wpRevDeleteReasonList' ), $wpReason = $( '#wpReason' ), - filterFn = function ( input ) { + filterFunction = function ( input ) { // Should be built the same as in SpecialRevisionDelete::submit() var comment = $wpRevDeleteReasonList.val(); if ( comment === 'other' ) { @@ -21,9 +21,9 @@ // Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration if ( summaryCodePointLimit ) { - $wpReason.codePointLimit( summaryCodePointLimit, filterFn ); + $wpReason.codePointLimit( summaryCodePointLimit, filterFunction ); } else if ( summaryByteLimit ) { - $wpReason.byteLimit( summaryByteLimit, filterFn ); + $wpReason.byteLimit( summaryByteLimit, filterFunction ); } }() ); -- 2.20.1