// I'm surprised this doesn't seem to exist in jQuery or mw.util.
params = {};
- hash = hash.replace( '+', '%20' );
+ hash = hash.replace( /\+/g, '%20' );
re = /([^&=#]+)=?([^&#]*)/g;
while ( ( m = re.exec( hash ) ) ) {
params[ decodeURIComponent( m[ 1 ] ) ] = decodeURIComponent( m[ 2 ] );
* Submit button handler
*/
sendRequest: function () {
- var page, subpages, i, query, $result,
+ var page, subpages, i, query, $result, $focus,
progress, $progressText, progressLoading,
deferreds = [],
params = {},
displayParams = {},
checkPages = [ pages.main ];
+ // Blur any focused widget before submit, because
+ // OO.ui.ButtonWidget doesn't take focus itself (T128054)
+ $focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
+ if ( $focus.length ) {
+ $focus[ 0 ].blur();
+ }
+
suppressErrors = false;
while ( checkPages.length ) {
ApiSandbox.PageLayout.prototype.loadParamInfo = function () {
var dynamicFieldset, dynamicParamNameWidget,
that = this,
+ removeDynamicParamWidget = function ( name, layout ) {
+ dynamicFieldset.removeItems( [ layout ] );
+ delete that.widgets[ name ];
+ },
addDynamicParamWidget = function () {
var name, layout, widget, button;
widget.focus();
dynamicParamNameWidget.setValue( '' );
- },
- removeDynamicParamWidget = function ( name, layout ) {
- dynamicFieldset.removeItems( [ layout ] );
- delete that.widgets[ name ];
};
this.$element.empty()
classes: [ 'mw-apisandbox-spacer' ]
} ), {
align: 'inline',
+ classes: [ 'mw-apisandbox-help-field' ],
label: dl
}
);
widget,
{
align: 'left',
+ classes: [ 'mw-apisandbox-widget-field' ],
label: prefix + pi.parameters[ i ].name,
$label: $widgetLabel
}