Merge "ApiSandbox: Use OO.ui.getDefaultOverlay()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 12 Jan 2018 21:50:26 +0000 (21:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Jan 2018 21:50:26 +0000 (21:50 +0000)
1  2 
resources/src/mediawiki.special/mediawiki.special.apisandbox.js

                                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        allowArbitrary: true,
                                                        allowDuplicates: Util.apiBool( pi.allowsduplicates ),
-                                                       $overlay: $( '#mw-apisandbox-ui' )
+                                                       $overlay: true
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, WidgetMethods.capsuleWidget );
  
                                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items },
-                                                       $overlay: $( '#mw-apisandbox-ui' )
+                                                       $overlay: true
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, WidgetMethods.capsuleWidget );
                                        } else {
                                                widget = new OO.ui.DropdownWidget( {
                                                        menu: { items: items },
-                                                       $overlay: $( '#mw-apisandbox-ui' )
+                                                       $overlay: true
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, WidgetMethods.dropdownWidget );
  
                                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                                        menu: { items: items },
-                                                       $overlay: $( '#mw-apisandbox-ui' )
+                                                       $overlay: true
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, WidgetMethods.capsuleWidget );
                                        } else {
                                                widget = new OO.ui.DropdownWidget( {
                                                        menu: { items: items },
-                                                       $overlay: $( '#mw-apisandbox-ui' )
+                                                       $overlay: true
                                                } );
                                                widget.paramInfo = pi;
                                                $.extend( widget, WidgetMethods.dropdownWidget );
                                widget = new OO.ui.CapsuleMultiselectWidget( {
                                        allowArbitrary: true,
                                        allowDuplicates: Util.apiBool( pi.allowsduplicates ),
-                                       $overlay: $( '#mw-apisandbox-ui' ),
+                                       $overlay: true,
                                        popup: {
                                                classes: [ 'mw-apisandbox-popup' ],
                                                $content: $content
                        if ( ApiSandbox.isFullscreen ) {
                                fullscreenButton.setLabel( mw.message( 'apisandbox-unfullscreen' ).text() );
                                fullscreenButton.setTitle( mw.message( 'apisandbox-unfullscreen-tooltip' ).text() );
-                               $body.append( $ui );
+                               OO.ui.getDefaultOverlay().prepend( $ui );
                        } else {
                                fullscreenButton.setLabel( mw.message( 'apisandbox-fullscreen' ).text() );
                                fullscreenButton.setTitle( mw.message( 'apisandbox-fullscreen-tooltip' ).text() );
                                if ( !formatDropdown ) {
                                        formatDropdown = new OO.ui.DropdownWidget( {
                                                menu: { items: [] },
-                                               $overlay: $( '#mw-apisandbox-ui' )
+                                               $overlay: true
                                        } );
                                        formatDropdown.getMenu().on( 'select', Util.onFormatDropdownChange );
                                }
                                                                                booklet.setPage( '|results|' );
                                                                        } ).setDisabled( !paramsAreForced ) ).$element,
                                                                        new OO.ui.PopupButtonWidget( {
-                                                                               $overlay: $( '#mw-apisandbox-ui' ),
+                                                                               $overlay: true,
                                                                                framed: false,
                                                                                icon: 'info',
                                                                                popup: {
                                                        for ( j = 0; j < tmp.length; j++ ) {
                                                                availableFormats[ tmp[ j ] ] = true;
                                                        }
 -                                                      pi.parameters[ i ].type = $.grep( tmp, filterFmModules );
 +                                                      pi.parameters[ i ].type = tmp.filter( filterFmModules );
                                                        pi.parameters[ i ][ 'default' ] = 'json';
                                                        pi.parameters[ i ].required = true;
                                                }
  
                                // Hide the 'wrappedhtml' parameter on format modules
                                if ( pi.group === 'format' ) {
 -                                      pi.parameters = $.grep( pi.parameters, function ( p ) {
 +                                      pi.parameters = pi.parameters.filter( function ( p ) {
                                                return p.name !== 'wrappedhtml';
                                        } );
                                }
  
                                if ( pi.helpurls.length ) {
                                        buttons.push( new OO.ui.PopupButtonWidget( {
-                                               $overlay: $( '#mw-apisandbox-ui' ),
+                                               $overlay: true,
                                                label: mw.message( 'apisandbox-helpurls' ).text(),
                                                icon: 'help',
                                                popup: {
                                                        width: 'auto',
                                                        padded: true,
 -                                                      $content: $( '<ul>' ).append( $.map( pi.helpurls, function ( link ) {
 +                                                      $content: $( '<ul>' ).append( pi.helpurls.map( function ( link ) {
                                                                return $( '<li>' ).append( $( '<a>' )
                                                                        .attr( { href: link, target: '_blank' } )
                                                                        .text( link )
  
                                if ( pi.examples.length ) {
                                        buttons.push( new OO.ui.PopupButtonWidget( {
-                                               $overlay: $( '#mw-apisandbox-ui' ),
+                                               $overlay: true,
                                                label: mw.message( 'apisandbox-examples' ).text(),
                                                icon: 'code',
                                                popup: {
                                                        width: 'auto',
                                                        padded: true,
 -                                                      $content: $( '<ul>' ).append( $.map( pi.examples, function ( example ) {
 +                                                      $content: $( '<ul>' ).append( pi.examples.map( function ( example ) {
                                                                var a = $( '<a>' )
                                                                        .attr( 'href', '#' + example.query )
                                                                        .html( example.description );
                config = config || {};
  
                this.widget = widget;
-               this.$overlay = config.$overlay ||
-                       $( '<div>' ).addClass( 'mw-apisandbox-optionalWidget-overlay' );
+               this.$cover = config.$cover ||
+                       $( '<div>' ).addClass( 'mw-apisandbox-optionalWidget-cover' );
                this.checkbox = new OO.ui.CheckboxInputWidget( config.checkbox )
                        .on( 'change', this.onCheckboxChange, [], this );
  
                        }
                }
  
-               this.$overlay.on( 'click', this.onOverlayClick.bind( this ) );
+               this.$cover.on( 'click', this.onOverlayClick.bind( this ) );
  
                this.$element
                        .addClass( 'mw-apisandbox-optionalWidget' )
                        .append(
-                               this.$overlay,
+                               this.$cover,
                                $( '<div>' ).addClass( 'mw-apisandbox-optionalWidget-fields' ).append(
                                        $( '<div>' ).addClass( 'mw-apisandbox-optionalWidget-widget' ).append(
                                                widget.$element
                OptionalWidget[ 'super' ].prototype.setDisabled.call( this, disabled );
                this.widget.setDisabled( this.isDisabled() );
                this.checkbox.setSelected( !this.isDisabled() );
-               this.$overlay.toggle( this.isDisabled() );
+               this.$cover.toggle( this.isDisabled() );
                return this;
        };