"apisandbox-jsonly": "JavaScript is required to use the API sandbox.",
"apisandbox-api-disabled": "The API is disabled on this site.",
"apisandbox-intro": "Use this page to experiment with the <strong>MediaWiki web service API</strong>.\nRefer to [[mw:API:Main page|the API documentation]] for further details of API usage. Example: [https://www.mediawiki.org/wiki/API#A_simple_example get the content of a Main Page]. Select an action to see more examples.\n\nNote that, although this is a sandbox, actions you carry out on this page may modify the wiki.",
- "apisandbox-fullscreen": "Expand panel",
- "apisandbox-fullscreen-tooltip": "Expand the sandbox panel to fill the browser window.",
- "apisandbox-unfullscreen": "Show page",
- "apisandbox-unfullscreen-tooltip": "Reduce the sandbox panel, so MediaWiki navigation links are available.",
"apisandbox-submit": "Make request",
"apisandbox-reset": "Clear",
"apisandbox-retry": "Retry",
"apisandbox-jsonly": "Displayed as an error message if the browser does not have JavaScript enabled.",
"apisandbox-api-disabled": "Displayed as an error message if the API is disabled on this site.",
"apisandbox-intro": "Displayed (from JavaScript) as a header on [[Special:ApiSandbox]].",
- "apisandbox-fullscreen": "JavaScript button label for enabling full-page mode.\n\nSee https://phabricator.wikimedia.org/T129632#2465838 for details.",
- "apisandbox-fullscreen-tooltip": "Tooltip for the {{msg-mw|apisandbox-fullscreen}} button.",
- "apisandbox-unfullscreen": "JavaScript button label for disabling full-page mode.\n\nSee https://phabricator.wikimedia.org/T129632#2465838 for details.",
- "apisandbox-unfullscreen-tooltip": "Tooltip for the {{msg-mw|apisandbox-unfullscreen}} button.",
"apisandbox-submit": "JavaScript button label for submitting the request.",
"apisandbox-reset": "JavaScript button label for clearing the form.\n{{Identical|Clear}}",
"apisandbox-retry": "JavaScript button label for retrying the submission.\n{{Identical|Retry}}",
( function ( $, mw, OO ) {
'use strict';
var ApiSandbox, Util, WidgetMethods, Validators,
- $content, panel, booklet, oldhash, windowManager, fullscreenButton,
+ $content, panel, booklet, oldhash, windowManager,
formatDropdown,
api = new mw.Api(),
bookletPages = [],
init: function () {
var $toolbar;
- ApiSandbox.isFullscreen = false;
-
$content = $( '#mw-apisandbox' );
windowManager = new OO.ui.WindowManager();
errorAlert: new OO.ui.MessageDialog()
} );
- fullscreenButton = new OO.ui.ButtonWidget( {
- label: mw.message( 'apisandbox-fullscreen' ).text(),
- title: mw.message( 'apisandbox-fullscreen-tooltip' ).text()
- } ).on( 'click', ApiSandbox.toggleFullscreen );
-
$toolbar = $( '<div>' )
.addClass( 'mw-apisandbox-toolbar' )
.append(
- fullscreenButton.$element,
new OO.ui.ButtonWidget( {
label: mw.message( 'apisandbox-submit' ).text(),
flags: [ 'primary', 'progressive' ]
);
booklet = new OO.ui.BookletLayout( {
+ expanded: false,
outlined: true,
autoFocus: false
} );
.append( $toolbar )
.append( panel.$element )
);
-
- $( 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 );
- }
},
/**
$result = $( '<div>' )
.append( progress.$element );
- resultPage = page = new OO.ui.PageLayout( '|results|' );
+ resultPage = page = new OO.ui.PageLayout( '|results|', { expanded: false } );
page.setupOutlineItem = function () {
this.outlineItem.setLabel( mw.message( 'apisandbox-results' ).text() );
};
* @param {Object} [config] Configuration options
*/
ApiSandbox.PageLayout = function ( config ) {
- config = $.extend( { prefix: '' }, config );
+ config = $.extend( { prefix: '', expanded: false }, config );
this.displayText = config.key;
this.apiModule = config.path;
this.prefix = config.prefix;