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
*
}
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() );
$( ApiSandbox.init );
+ module.exports = ApiSandbox;
+
}( jQuery, mediaWiki, OO ) );