-
- $( window ).on( 'resize', ApiSandbox.resizePanel );
-
- ApiSandbox.resizePanel();
- },
-
- /**
- * Toggle "fullscreen" mode
- */
- toggleFullscreen: function () {
- var $body = $( document.body ),
- $ui = $( '#mw-apisandbox-ui' );
-
- ApiSandbox.isFullscreen = !ApiSandbox.isFullscreen;
-
- $body.toggleClass( 'mw-apisandbox-fullscreen', ApiSandbox.isFullscreen );
- $ui.toggleClass( 'mw-body-content', ApiSandbox.isFullscreen );
- if ( ApiSandbox.isFullscreen ) {
- fullscreenButton.setLabel( mw.message( 'apisandbox-unfullscreen' ).text() );
- fullscreenButton.setTitle( mw.message( 'apisandbox-unfullscreen-tooltip' ).text() );
- OO.ui.getDefaultOverlay().prepend( $ui );
- } else {
- fullscreenButton.setLabel( mw.message( 'apisandbox-fullscreen' ).text() );
- fullscreenButton.setTitle( mw.message( 'apisandbox-fullscreen-tooltip' ).text() );
- $content.append( $ui );
- }
- ApiSandbox.resizePanel();
- },
-
- /**
- * Set the height of the panel based on the current viewport.
- */
- resizePanel: function () {
- var height = $( window ).height(),
- contentTop = $content.offset().top;
-
- if ( ApiSandbox.isFullscreen ) {
- height -= panel.$element.offset().top - $( '#mw-apisandbox-ui' ).offset().top;
- panel.$element.height( height - 1 );
- } else {
- // Subtract the height of the intro text
- height -= panel.$element.offset().top - contentTop;
-
- panel.$element.height( height - 10 );
- $( window ).scrollTop( contentTop - 5 );
- }