Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234011

Change subject: jquery.byteLimit: Expose trimValueForByteLength as 
trimByteLength
......................................................................

jquery.byteLimit: Expose trimValueForByteLength as trimByteLength

Follows-up 6b79105034, which exposed this private function as a
subproperty of a prototype member, but the JSDuck comment still
treated it as private.

Expose it as proper static method instead.

Change-Id: I1e25ee595ac367a9ae24a325efab2942a37835d9
---
M resources/src/jquery/jquery.byteLimit.js
M resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
2 files changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/11/234011/1

diff --git a/resources/src/jquery/jquery.byteLimit.js 
b/resources/src/jquery/jquery.byteLimit.js
index e2315d2..afff463 100644
--- a/resources/src/jquery/jquery.byteLimit.js
+++ b/resources/src/jquery/jquery.byteLimit.js
@@ -10,17 +10,17 @@
         * "fobo", not "foba". Basically emulating the native maxlength by
         * reconstructing where the insertion occurred.
         *
-        * @private
+        * @static
         * @param {string} safeVal Known value that was previously returned by 
this
         * 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} [fn] See jQuery.byteLimit.
+        * @param {Function} [fn] See jQuery#byteLimit.
         * @return {Object}
         * @return {string} return.newVal
         * @return {boolean} return.trimmed
         */
-       function trimValueForByteLength( safeVal, newVal, byteLimit, fn ) {
+       $.trimByteLength = function ( safeVal, newVal, byteLimit, fn ) {
                var startMatches, endMatches, matchesLen, inpParts,
                        oldVal = safeVal;
 
@@ -92,7 +92,7 @@
                        newVal: newVal,
                        trimmed: true
                };
-       }
+       };
 
        var eventKeys = [
                'keyup.byteLimit',
@@ -206,7 +206,7 @@
                        // See 
http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboard-event-order for
                        // the order and characteristics of the key events.
                        $el.on( eventKeys, function () {
-                               var res = trimValueForByteLength(
+                               var res = $.trimByteLength(
                                        prevSafeVal,
                                        this.value,
                                        elLimit,
@@ -221,14 +221,12 @@
                                        this.value = res.newVal;
                                }
                                // Always adjust prevSafeVal to reflect the 
input value. Not doing this could cause
-                               // trimValueForByteLength to compare the new 
value to an empty string instead of the
+                               // trimByteLength to compare the new value to 
an empty string instead of the
                                // old value, resulting in trimming always from 
the end (bug 40850).
                                prevSafeVal = res.newVal;
                        } );
                } );
        };
-
-       $.fn.byteLimit.trimValueForByteLength = trimValueForByteLength;
 
        /**
         * @class jQuery
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js 
b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
index 3697a1c..cf4d788 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
@@ -302,7 +302,7 @@
        mw.widgets.TitleInputWidget.prototype.cleanUpValue = function ( value ) 
{
                var widget = this;
                value = 
mw.widgets.TitleInputWidget.parent.prototype.cleanUpValue.call( this, value );
-               return $.fn.byteLimit.trimValueForByteLength( this.value, 
value, this.maxLength, function ( value ) {
+               return $.trimByteLength( this.value, value, this.maxLength, 
function ( value ) {
                        var title = widget.getTitle( value );
                        return title ? title.getMain() : value;
                } ).newVal;

-- 
To view, visit https://gerrit.wikimedia.org/r/234011
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e25ee595ac367a9ae24a325efab2942a37835d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to