From: Brad Jorsch Date: Mon, 14 Nov 2016 16:52:16 +0000 (-0500) Subject: ApiSandbox: Don't use OO.ui.NumberInputWidget for limit fields X-Git-Tag: 1.31.0-rc.0~4864^2 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=52c4704fd5855d09fc98ce6f19f8fbd7ffe9e7b8;p=lhc%2Fweb%2Fwiklou.git ApiSandbox: Don't use OO.ui.NumberInputWidget for limit fields According to T150455#2789277 it shouldn't be able to allow 'max' even though this is a mostly-numeric field with one non-numeric value. Oh well. Change-Id: I620a233aab20c715db354eff77ea8a3ffee3bc77 --- diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index 64cfcf5c47..9364e074b3 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -389,19 +389,27 @@ break; case 'limit': - widget = new OO.ui.NumberInputWidget( { - required: Util.apiBool( pi.required ), - isInteger: true + widget = new OO.ui.TextInputWidget( { + required: Util.apiBool( pi.required ) } ); - widget.setIcon = widget.input.setIcon.bind( widget.input ); - widget.setIconTitle = widget.input.setIconTitle.bind( widget.input ); - widget.getValidity = widget.input.getValidity.bind( widget.input ); - widget.input.setValidation( function ( value ) { - return value === 'max' || widget.validateNumber( value ); + widget.setValidation( function ( value ) { + var n, pi = this.paramInfo; + + if ( value === 'max' ) { + return true; + } else { + n = +value; + return !isNaN( n ) && isFinite( n ) && + /* jshint bitwise: false */ + ( n | 0 ) === n && + /* jshint bitwise: true */ + n >= pi.min && n <= pi.apiSandboxMax; + } } ); + pi.min = pi.min || 0; + pi.apiSandboxMax = mw.config.get( 'apihighlimits' ) ? pi.highmax : pi.max; widget.paramInfo = pi; $.extend( widget, WidgetMethods.textInputWidget ); - widget.setRange( pi.min || 0, mw.config.get( 'apihighlimits' ) ? pi.highmax : pi.max ); multiMode = 'enter'; break;