resources: Rename a few local 'filterFn' vars to 'filterFunction'
authorLucas Werkmeister <lucas.werkmeister@wikimedia.de>
Fri, 22 Mar 2019 18:40:53 +0000 (19:40 +0100)
committerKrinkle <krinklemail@gmail.com>
Mon, 15 Apr 2019 23:04:04 +0000 (23:04 +0000)
Abbreviations are discouraged, so let’s use the full word.

Change-Id: I31fb4cca32d766559005d1291d6d22da3d74b5e6

resources/src/jquery/jquery.lengthLimit.js
resources/src/mediawiki.String.js
resources/src/mediawiki.action/mediawiki.action.delete.file.js
resources/src/mediawiki.action/mediawiki.action.delete.js
resources/src/mediawiki.special.revisionDelete.js

index 26f8f9b..0e3394b 100644 (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
        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 );
        };
 
        /**
index 5d9bef0..5960f93 100644 (file)
         * 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;
index 7996ea4..a0505cc 100644 (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 );
                }
        } );
 
index a7228ed..f125748 100644 (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 );
                }
        } );
 }() );
index e9b0e6a..6552750 100644 (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 );
        }
 
 }() );