Replace deprecated `constructive` with `progressive`
[lhc/web/wiklou.git] / resources / src / mediawiki.special / mediawiki.special.apisandbox.js
index 3cfc52c..e58a6cf 100644 (file)
 
                capsuleWidget: {
                        getApiValue: function () {
-                               return this.getItemsData().join( '|' );
+                               var items = this.getItemsData();
+                               if ( items.join( '' ).indexOf( '|' ) === -1 ) {
+                                       return items.join( '|' );
+                               } else {
+                                       return '\x1f' + items.join( '\x1f' );
+                               }
                        },
                        setApiValue: function ( v ) {
-                               this.setItemsFromData( v === undefined || v === '' ? [] : String( v ).split( '|' ) );
+                               if ( v === undefined || v === '' || v === '\x1f' ) {
+                                       this.setItemsFromData( [] );
+                               } else {
+                                       v = String( v );
+                                       if ( v.indexOf( '\x1f' ) !== 0 ) {
+                                               this.setItemsFromData( v.split( '|' ) );
+                                       } else {
+                                               this.setItemsFromData( v.substr( 1 ).split( '\x1f' ) );
+                                       }
+                               }
                        },
                        apiCheckValid: function () {
                                var ok = this.getApiValue() !== undefined || suppressErrors;
                                                        }
                                                } );
                                        } else if ( Util.apiBool( pi.multi ) ) {
-                                               widget = new OO.ui.CapsuleMultiSelectWidget( {
+                                               widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        allowArbitrary: true
                                                } );
                                                widget.paramInfo = pi;
                                                return a.data - b.data;
                                        } );
                                        if ( Util.apiBool( pi.multi ) ) {
-                                               widget = new OO.ui.CapsuleMultiSelectWidget( {
+                                               widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items }
                                                } );
                                                widget.paramInfo = pi;
                                                return new OO.ui.MenuOptionWidget( { data: String( v ), label: String( v ) } );
                                        } );
                                        if ( Util.apiBool( pi.multi ) ) {
-                                               widget = new OO.ui.CapsuleMultiSelectWidget( {
+                                               widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items }
                                                } );
                                                widget.paramInfo = pi;
                                                throw new Error( 'Unknown multiMode "' + multiMode + '"' );
                                }
 
-                               widget = new OO.ui.CapsuleMultiSelectWidget( {
+                               widget = new OO.ui.CapsuleMultiselectWidget( {
                                        allowArbitrary: true,
                                        popup: {
                                                classes: [ 'mw-apisandbox-popup' ],
        *
        * @class mw.special.ApiSandbox
        */
-       mw.special.ApiSandbox = ApiSandbox = {
+       ApiSandbox = {
                /**
                 * Initialize the UI
                 *
                                        fullscreenButton.$element,
                                        new OO.ui.ButtonWidget( {
                                                label: mw.message( 'apisandbox-submit' ).text(),
-                                               flags: [ 'primary', 'constructive' ]
+                                               flags: [ 'primary', 'progressive' ]
                                        } ).on( 'click', ApiSandbox.sendRequest ).$element,
                                        new OO.ui.ButtonWidget( {
                                                label: mw.message( 'apisandbox-reset' ).text(),
                                                }
                                                if ( Util.apiBool( pi.parameters[ i ].multi ) ) {
                                                        tmp = [];
-                                                       if ( flag && !( widget instanceof OO.ui.CapsuleMultiSelectWidget ) &&
+                                                       if ( flag && !( widget instanceof OO.ui.CapsuleMultiselectWidget ) &&
                                                                !(
                                                                        widget instanceof OptionalWidget &&
-                                                                       widget.widget instanceof OO.ui.CapsuleMultiSelectWidget
+                                                                       widget.widget instanceof OO.ui.CapsuleMultiselectWidget
                                                                )
                                                        ) {
                                                                tmp.push( mw.message( 'api-help-param-multi-separate' ).parse() );
                                                        dynamicParamNameWidget,
                                                        new OO.ui.ButtonWidget( {
                                                                icon: 'add',
-                                                               flags: 'constructive'
+                                                               flags: 'progressive'
                                                        } ).on( 'click', addDynamicParamWidget ),
                                                        {
                                                                label: mw.message( 'apisandbox-dynamic-parameters-add-label' ).text(),
 
        $( ApiSandbox.init );
 
+       module.exports = ApiSandbox;
+
 }( jQuery, mediaWiki, OO ) );