Merge "resources: Rename a few local 'filterFn' vars to 'filterFunction'"

This commit is contained in:
jenkins-bot 2019-04-15 23:23:46 +00:00 committed by Gerrit Code Review
commit 3353ced6cd
5 changed files with 33 additions and 33 deletions

View file

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

View file

@ -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;

View file

@ -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 );
}
} );

View file

@ -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 );
}
} );
}() );

View file

@ -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 );
}
}() );