} else if ( Util.apiBool( pi.multi ) ) {
widget = new OO.ui.CapsuleMultiselectWidget( {
allowArbitrary: true,
- allowDuplicates: Util.apiBool( pi.allowsduplicates )
+ allowDuplicates: Util.apiBool( pi.allowsduplicates ),
+ $overlay: $( '#mw-apisandbox-ui' )
} );
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.capsuleWidget );
}
widget = new OO.ui.CapsuleMultiselectWidget( {
- menu: { items: items }
+ menu: { items: items },
+ $overlay: $( '#mw-apisandbox-ui' )
} );
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.capsuleWidget );
} else {
widget = new OO.ui.DropdownWidget( {
- menu: { items: items }
+ menu: { items: items },
+ $overlay: $( '#mw-apisandbox-ui' )
} );
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.dropdownWidget );
break;
default:
- if ( !$.isArray( pi.type ) ) {
+ if ( !Array.isArray( pi.type ) ) {
throw new Error( 'Unknown parameter type ' + pi.type );
}
}
widget = new OO.ui.CapsuleMultiselectWidget( {
- menu: { items: items }
+ menu: { items: items },
+ $overlay: $( '#mw-apisandbox-ui' )
} );
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.capsuleWidget );
}
} else {
widget = new OO.ui.DropdownWidget( {
- menu: { items: items }
+ menu: { items: items },
+ $overlay: $( '#mw-apisandbox-ui' )
} );
widget.paramInfo = pi;
$.extend( widget, WidgetMethods.dropdownWidget );
widget = new OO.ui.CapsuleMultiselectWidget( {
allowArbitrary: true,
allowDuplicates: Util.apiBool( pi.allowsduplicates ),
+ $overlay: $( '#mw-apisandbox-ui' ),
popup: {
classes: [ 'mw-apisandbox-popup' ],
$content: $content
if ( !formatDropdown ) {
formatDropdown = new OO.ui.DropdownWidget( {
- menu: { items: [] }
+ menu: { items: [] },
+ $overlay: $( '#mw-apisandbox-ui' )
} );
formatDropdown.getMenu().on( 'choose', Util.onFormatDropdownChange );
}
}
} )
.then( null, function ( code, data, result, jqXHR ) {
+ var deferred = $.Deferred();
+
if ( code !== 'http' ) {
// Not really an error, work around mw.Api thinking it is.
- return $.Deferred()
- .resolve( result, jqXHR )
- .promise();
+ deferred.resolve( result, jqXHR );
+ } else {
+ // Just forward it.
+ deferred.reject.apply( deferred, arguments );
}
- return this;
+ return deferred.promise();
} )
- .fail( function ( code, data ) {
- var details = 'HTTP error: ' + data.exception;
- $result.empty()
- .append(
- new OO.ui.LabelWidget( {
- label: mw.message( 'apisandbox-results-error', details ).text(),
- classes: [ 'error' ]
- } ).$element
- );
- } )
- .done( function ( data, jqXHR ) {
+ .then( function ( data, jqXHR ) {
var m, loadTime, button, clear,
ct = jqXHR.getResponseHeader( 'Content-Type' );
booklet.setPage( '|results|' );
} ).setDisabled( !paramsAreForced ) ).$element,
new OO.ui.PopupButtonWidget( {
+ $overlay: $( '#mw-apisandbox-ui' ),
framed: false,
icon: 'info',
popup: {
$content: $( '<div>' ).append( Util.parseMsg( 'apisandbox-continue-help' ) ),
- padded: true
+ padded: true,
+ width: 'auto'
}
} ).$element
)
.on( 'click', button.setDisabled, [ true ], button )
.$element.appendTo( $result );
}
+ }, function ( code, data ) {
+ var details = 'HTTP error: ' + data.exception;
+ $result.empty()
+ .append(
+ new OO.ui.LabelWidget( {
+ label: mw.message( 'apisandbox-results-error', details ).text(),
+ classes: [ 'error' ]
+ } ).$element
+ );
} );
} );
},
if ( page.tokenWidget ) {
k = page.apiModule + page.tokenWidget.paramInfo.name;
- tokenWait[ k ] = page.tokenWidget.fetchToken()
+ tokenWait[ k ] = page.tokenWidget.fetchToken();
+ tokenWait[ k ]
.done( success.bind( page.tokenWidget, k ) )
.fail( failure.bind( page.tokenWidget, k ) );
}
nooptional: true
} );
button = new OO.ui.ButtonWidget( {
- icon: 'remove',
+ icon: 'trash',
flags: 'destructive'
} );
layout = new OO.ui.ActionFieldLayout(
Util.fetchModuleInfo( this.apiModule )
.done( function ( pi ) {
- var prefix, i, j, dl, widget, $widgetLabel, widgetField, helpField, tmp, flag, count,
+ var prefix, i, j, descriptionContainer, widget, widgetField, helpField, tmp, flag, count,
items = [],
deprecatedItems = [],
buttons = [],
if ( pi.helpurls.length ) {
buttons.push( new OO.ui.PopupButtonWidget( {
+ $overlay: $( '#mw-apisandbox-ui' ),
label: mw.message( 'apisandbox-helpurls' ).text(),
icon: 'help',
popup: {
+ width: 'auto',
+ padded: true,
$content: $( '<ul>' ).append( $.map( pi.helpurls, function ( link ) {
return $( '<li>' ).append( $( '<a>', {
href: link,
if ( pi.examples.length ) {
buttons.push( new OO.ui.PopupButtonWidget( {
+ $overlay: $( '#mw-apisandbox-ui' ),
label: mw.message( 'apisandbox-examples' ).text(),
icon: 'code',
popup: {
+ width: 'auto',
+ padded: true,
$content: $( '<ul>' ).append( $.map( pi.examples, function ( example ) {
var a = $( '<a>', {
href: '#' + example.query,
that.tokenWidget = widget;
}
- dl = $( '<dl>' );
- dl.append( $( '<dd>', {
+ descriptionContainer = $( '<div>' );
+ descriptionContainer.append( $( '<div>', {
addClass: 'description',
append: Util.parseHTML( pi.parameters[ i ].description )
} ) );
if ( pi.parameters[ i ].info && pi.parameters[ i ].info.length ) {
for ( j = 0; j < pi.parameters[ i ].info.length; j++ ) {
- dl.append( $( '<dd>', {
+ descriptionContainer.append( $( '<div>', {
addClass: 'info',
append: Util.parseHTML( pi.parameters[ i ].info[ j ] )
} ) );
case 'limit':
if ( pi.parameters[ i ].highmax !== undefined ) {
- dl.append( $( '<dd>', {
+ descriptionContainer.append( $( '<div>', {
addClass: 'info',
append: [
Util.parseMsg(
]
} ) );
} else {
- dl.append( $( '<dd>', {
+ descriptionContainer.append( $( '<div>', {
addClass: 'info',
append: [
Util.parseMsg( 'api-help-param-limit', pi.parameters[ i ].max ),
tmp += 'max';
}
if ( tmp !== '' ) {
- dl.append( $( '<dd>', {
+ descriptionContainer.append( $( '<div>', {
addClass: 'info',
append: Util.parseMsg(
'api-help-param-integer-' + tmp,
break;
default:
- if ( $.isArray( pi.parameters[ i ].type ) ) {
+ if ( Array.isArray( pi.parameters[ i ].type ) ) {
flag = false;
count = pi.parameters[ i ].type.length;
}
);
}
if ( tmp.length ) {
- dl.append( $( '<dd>', {
+ descriptionContainer.append( $( '<div>', {
addClass: 'info',
append: Util.parseHTML( tmp.join( ' ' ) )
} ) );
} ), {
align: 'inline',
classes: [ 'mw-apisandbox-help-field' ],
- label: dl
+ label: descriptionContainer
}
);
- $widgetLabel = $( '<span>' );
widgetField = new OO.ui.FieldLayout(
widget,
{
align: 'left',
classes: [ 'mw-apisandbox-widget-field' ],
- label: prefix + pi.parameters[ i ].name,
- $label: $widgetLabel
+ label: prefix + pi.parameters[ i ].name
}
);
- // FieldLayout only does click for InputElement
- // widgets. So supply our own click handler.
- $widgetLabel.on( 'click', widgetLabelOnClick.bind( widgetField ) );
+ // We need our own click handler on the widget label to
+ // turn off the disablement.
+ widgetField.$label.on( 'click', widgetLabelOnClick.bind( widgetField ) );
// Don't grey out the label when the field is disabled,
// it makes it too hard to read and our "disabled"