Use native ES5 Array prototype methods instead of jQuery
[lhc/web/wiklou.git] / resources / src / mediawiki.special / mediawiki.special.apisandbox.js
index 73c3c45..7029116 100644 (file)
                        multi: function () {
                                var map = this.paramInfo.submodules,
                                        v = this.isDisabled() ? this.paramInfo[ 'default' ] : this.getApiValue();
-                               return v === undefined || v === '' ? [] : $.map( String( v ).split( '|' ), function ( v ) {
+                               return v === undefined || v === '' ? [] : String( v ).split( '|' ).map( function ( v ) {
                                        return { value: v, path: map[ v ] };
                                } );
                        }
                                        break;
 
                                case 'text':
-                                       widget = new OO.ui.TextInputWidget( {
-                                               multiline: true,
+                                       widget = new OO.ui.MultilineTextInputWidget( {
                                                required: Util.apiBool( pi.required )
                                        } );
                                        widget.paramInfo = pi;
                                                throw new Error( 'Unknown parameter type ' + pi.type );
                                        }
 
-                                       items = $.map( pi.type, function ( v ) {
+                                       items = pi.type.map( function ( v ) {
                                                var config = {
                                                        data: String( v ),
                                                        label: String( v ),
                                        new OO.ui.MenuOptionWidget( {
                                                label: Util.parseMsg( 'apisandbox-request-format-json-label' ),
                                                data: new OO.ui.FieldLayout(
-                                                       jsonInput = new OO.ui.TextInputWidget( {
+                                                       jsonInput = new OO.ui.MultilineTextInputWidget( {
                                                                classes: [ 'mw-apisandbox-textInputCode' ],
                                                                readOnly: true,
-                                                               multiline: true,
                                                                autosize: true,
                                                                maxRows: 6,
                                                                value: JSON.stringify( displayParams, null, '\t' )
                                        selectedLabel = selectedLabel.text();
                                }
                                menu.clearItems().addItems( formatItems );
-                               menu.chooseItem( menu.getItemFromLabel( selectedLabel ) || menu.getFirstSelectableItem() );
+                               menu.chooseItem( menu.getItemFromLabel( selectedLabel ) || menu.findFirstSelectableItem() );
 
                                // Fire the event to update field visibilities
                                Util.onFormatDropdownChange();
                                                if ( $.isFunction( f.focus ) ) {
                                                        f.focus();
                                                }
-                                       },
-                                       doNothing = function () {};
+                                       };
 
                                // This is something of a hack. We always want the 'format' and
                                // 'action' parameters from the main module to be specified,
                                                // it makes it too hard to read and our "disabled"
                                                // isn't really disabled.
                                                widgetField.onFieldDisable( false );
-                                               widgetField.onFieldDisable = doNothing;
+                                               widgetField.onFieldDisable = $.noop;
 
                                                if ( Util.apiBool( pi.parameters[ i ].deprecated ) ) {
                                                        deprecatedItems.push( widgetField, helpField );