Abbreviations are discouraged, so let’s use the full word.
Change-Id: I31fb4cca32d766559005d1291d6d22da3d74b5e6
* 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
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.
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,
prevSafeVal,
this.value,
elLimit,
- filterFn
+ filterFunction
);
// Only set value property if it was trimmed, because whenever the
*
* @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 );
};
/**
*
* @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 );
};
/**
* 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;
* 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;
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' ) {
// 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 );
}
} );
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' ) {
// 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 );
}
} );
}() );
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' ) {
// 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 );
}
}() );