MediaWiki:Gadget-Fullscreen.js
OBS: Efter du har publicerat sidan kan du behöva tömma din webbläsares cache för att se ändringarna.
- Firefox / Safari: Håll ned Skift och klicka på Uppdatera sidan eller tryck Ctrl-F5 eller Ctrl-R (⌘-R på Mac)
- Google Chrome: Tryck Ctrl-Skift-R (⌘-Skift-R på Mac)
- Internet Explorer / Edge: Håll ned Ctrl och klicka på Uppdatera eller tryck Ctrl-F5
- Opera: Tryck Ctrl-F5.
$( function () {
'use strict';
var title = 'Hide everything that does not make editing easier.';
var text = 'Fullscreen';
var lang = mw.config.get( 'wgUserLanguage' );
function unenc( str ) {
return str
.replace( /%20/g, '_' )
.replace( /%3B/g, ';' )
.replace( /%40/g, '@' )
.replace( /%24/g, '$' )
.replace( /%21/g, '!' )
.replace( /%2A/g, '*' )
.replace( /%28/g, '(' )
.replace( /%29/g, ')' )
.replace( /%2C/g, ',' )
.replace( /%2F/g, '/' )
.replace( /%7E/g, '~' )
.replace( /%3A/g, ':' );
}
function toggle() {
$( '#mw-navigation, #siteNotice, #centralNotice, #newarticletext, #noarticletext, #mw-page-base, #contentSub, #editpage-copywarn, #footer, #wpSummaryLabel, #mw-editpage-minoredit a, .cancelLink, h1' ).toggle();
$( '#content, #left-navigation' ).toggleClass( 'gadget-fullscreen-toggle' );
$( '#editform' ).attr( 'action', function( i, old ) {
var URLParams;
if ( old.indexOf( '&fullscreen=1' ) === -1 ) {
if ( window.URLSearchParams ) {
URLParams = ( new URLSearchParams( location.search ) );
URLParams.set( 'fullscreen', 1 );
history.replaceState( null, null, '?' + unenc( URLParams.toString() ) + location.hash );
}
if ( old.indexOf( '#' ) === -1 ) {
return old + '&fullscreen=1';
}
} else {
if ( window.URLSearchParams ) {
URLParams = ( new URLSearchParams( location.search ) );
URLParams.delete( 'fullscreen' );
history.replaceState( null, null, '?' + unenc( URLParams.toString() ) + location.hash );
}
return old.replace( /&fullscreen=1/, '' );
}
} );
}
if ( mw.util.getParamValue( 'fullscreen' ) === '1' ) {
toggle();
}
if ( lang === 'sv' ) {
title = 'Dölj allt som inte underlättar redigering.';
text = 'Fullskärm';
}
$( '#wpDiffWidget' ).after( '<button type="button" id="gadget-fullscreen-button" title="' + title + '">' + text + '</button>' );
$( '#gadget-fullscreen-button' ).click( toggle );
} );