From 4fe6600f2bed9d59cd0e4e045ce41c7b02113374 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 10 Nov 2016 12:18:19 -0500 Subject: [PATCH] Fix ApiSandbox I2b8ef74e broke it by removing the isValid() method from TextInputWidget. Bug: T150454 Change-Id: Iae48c6e038ce66d294a1bf5f6852e29540ac208c --- .../mediawiki.special.apisandbox.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js index 98ed3eecfb..a206328b16 100644 --- a/resources/src/mediawiki.special/mediawiki.special.apisandbox.js +++ b/resources/src/mediawiki.special/mediawiki.special.apisandbox.js @@ -26,7 +26,11 @@ }, apiCheckValid: function () { var that = this; - return this.isValid().done( function ( ok ) { + return this.getValidity().then( function () { + return $.Deferred().resolve( true ).promise(); + }, function () { + return $.Deferred().resolve( false ).promise(); + } ).done( function ( ok ) { ok = ok || suppressErrors; that.setIcon( ok ? null : 'alert' ); that.setIconTitle( ok ? '' : mw.message( 'apisandbox-alert-field' ).plain() ); @@ -35,9 +39,12 @@ }, dateTimeInputWidget: { - isValid: function () { - var ok = !Util.apiBool( this.paramInfo.required ) || this.getApiValue() !== ''; - return $.Deferred().resolve( ok ).promise(); + getValidity: function () { + if ( !Util.apiBool( this.paramInfo.required ) || this.getApiValue() !== '' ) { + return $.Deferred().resolve().promise(); + } else { + return $.Deferred().reject().promise(); + } } }, @@ -372,7 +379,7 @@ } ); widget.setIcon = widget.input.setIcon.bind( widget.input ); widget.setIconTitle = widget.input.setIconTitle.bind( widget.input ); - widget.isValid = widget.input.isValid.bind( widget.input ); + widget.getValidity = widget.input.getValidity.bind( widget.input ); widget.paramInfo = pi; $.extend( widget, WidgetMethods.textInputWidget ); if ( Util.apiBool( pi.enforcerange ) ) { @@ -388,7 +395,7 @@ } ); widget.setIcon = widget.input.setIcon.bind( widget.input ); widget.setIconTitle = widget.input.setIconTitle.bind( widget.input ); - widget.isValid = widget.input.isValid.bind( widget.input ); + widget.getValidity = widget.input.getValidity.bind( widget.input ); widget.input.setValidation( function ( value ) { return value === 'max' || widget.validateNumber( value ); } ); -- 2.20.1