Jump to content

User:Polygnotus/Scripts/NoDistractions.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
// Stolen from https://de.wikipedia.org/wiki/Benutzer:Schnark/js/fullscreen
// should make a button for this I think, or hide stuff when you are actually typing in the textbox and stop when you stop?
// currently common.css is also hiding a bunch of irrelevant stuff

var fullscreen = {
version: 1.0,

only_on_edit: true,
width: '', height: '',
timeout_left: null, timeout_top: null,
left_show: true, top_show: true,

really_hide_left: function() {
 $('#mw-panel').css('height', $(document).height());
 $('#content').animate({marginLeft: '15px'});
 $('#mw-panel, #p-logo').animate({left: 15 - parseInt(fullscreen.width, 10) + 'px'});
 $('#mw-head').animate({width: '+=' + fullscreen.width});
 fullscreen.left_show = false;
},

really_show_left: function() {
 $('#content').animate({marginLeft: fullscreen.width});
 $('#mw-panel, #p-logo').animate({left: '0px'});
 $('#mw-head').animate({width: '-=' + fullscreen.width});
 fullscreen.left_show = true;
},

really_hide_top: function() {
 $('#mw-head').animate({top: 15 - parseInt(fullscreen.height, 10) + 'px'});
 $('#mw-head-base').animate({height: '15px'});
 fullscreen.top_show = false;
},

really_show_top: function() {
 $('#mw-head').animate({top: '0px'});
 $('#mw-head-base').animate({height: fullscreen.height});
 fullscreen.top_show = true;
},

hide_left: function() {
 if (!fullscreen.left_show) {
    if (fullscreen.timeout_left != null) { window.clearTimeout(fullscreen.timeout_left); fullscreen.timeout_left = null; }
 } else {
    if (fullscreen.timeout_left == null) fullscreen.timeout_left = window.setTimeout('fullscreen.really_hide_left();fullscreen.timeout_left=null;', 500);
 }
},

show_left: function() {
 if (fullscreen.left_show) {
    if (fullscreen.timeout_left != null) { window.clearTimeout(fullscreen.timeout_left); fullscreen.timeout_left = null; }
 } else {
    if (fullscreen.timeout_left == null) fullscreen.timeout_left = window.setTimeout('fullscreen.really_show_left();fullscreen.timeout_left=null;', 500);
 }
},

hide_top: function() {
 if (!fullscreen.top_show) {
    if (fullscreen.timeout_top != null) { window.clearTimeout(fullscreen.timeout_top); fullscreen.timeout_top = null; }
 } else {
    if (fullscreen.timeout_top == null) fullscreen.timeout_top = window.setTimeout('fullscreen.really_hide_top();fullscreen.timeout_top=null;', 500);
 }
},

show_top: function() {
 if (fullscreen.top_show) {
    if (fullscreen.timeout_top != null) { window.clearTimeout(fullscreen.timeout_top); fullscreen.timeout_top = null; }
 } else {
    if (fullscreen.timeout_top == null) fullscreen.timeout_top = window.setTimeout('fullscreen.really_show_top();fullscreen.timeout_top=null;', 500);
 }
},

init: function() {
 fullscreen.width = $('#mw-panel').width(); fullscreen.height = $('#mw-head').height();
 $('#mw-panel').hover(fullscreen.show_left, fullscreen.hide_left);
 $('#mw-head, #p-logo').hover(fullscreen.show_top, fullscreen.hide_top);
 fullscreen.really_hide_left(); fullscreen.really_hide_top();
}
};

if (!fullscreen.only_on_edit || mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') $(fullscreen.init);
//</nowiki>