User:BioBrain/global.js

switch (document.URL.split('.')[0]) { case 'http://unchartedwaters': case 'http://biobrain': case 'http://gbi-putera': break; default: //alert('Global.js running');

// Resize Wikia page if desktop screen wider than 1024 pixels. // Resize to 85% if aspect-ratio 16:9 or 85% if aspect-ratio 4:3

screen_ratio = screen.width / screen.height; width_scale = (screen_ratio.toFixed(2) == 1.78) ? 0.85 : 0.85;

desktop = 1024; $wkia_main = $('section#WikiaPage'); wdth_main = (screen.width > desktop) ? screen.width * width_scale : $wkia_main.width;

$wkia_rail = $('div.WikiaRail#WikiaRail');

wk_url = document.URL.split('?')[0]; wk_id = wk_url.slice(wk_url.lastIndexOf('/wiki/') + 6); wk_ttl = document.title.replace(/ /g, '_'); wdth_rail = (wk_id == wk_ttl) ? 0 : 320;

$wkia_head = $('header#wikiheader'); wdth_head = wdth_main - 20;

$wkia_navi = $('div.navbackground'); wdth_navi = wdth_head - 251;

$wkia_content = $('article.WikiaMainContent'); wdth_content = (screen.width > desktop) ? wdth_main - wdth_rail : $wkia_content.width;

xpandbutt = 'g-Xpand>>'; xpanded = false;

function resizepage(content, rail, opacity, display, speed1, speed2, xpanstat, txt, title) { xpanded = xpanstat; $wkia_content.stop; $wkia_rail.stop; $wkia_content.animate({ 'width': content }, speed1); $wkia_rail.animate({ 'width': rail, 'opacity': opacity }, speed2, function {                $wkia_rail.css({ 'display': display });                $xpandbutt.text(txt).attr('title', title);            }); }

if (wdth_rail != 0) { $('div.buttons', 'header#WikiHeader').prepend(xpandbutt); $xpandbutt = $('a#XpandButton'); $xpandbutt.click(function {                //alert('$xpanbutt.click');                if (xpanded == false) {                    resizepage(wdth_main - 5, 0, 0, 'none', 'slow', 'normal', true, 'g-Restor<<', 'Compress the content area & restore the side rail');               } else {                    $wkia_rail.css({ 'display': 'block' });                    resizepage(wdth_content, wdth_rail - 20, 1, 'block', 'normal', 'slow', false, 'g-Xpand>>', 'Expands the content area & hide the side rail');               }            }); }

if (screen.width > desktop) { $('header#WikiaHeader').width(wdth_main + 14); $wkia_main.width(wdth_main); $wkia_head.width(wdth_head); $wkia_navi.width(wdth_navi); $wkia_content.width(wdth_content); $('div.wikiaPhotoGallery-slider-body').css('margin', 'auto'); $('div.toolbar').width(wdth_main + 10); $('section#EditPageDialog').width(wdth_content); $('div#SharingToolbar').css({ 'left': wdth_main, 'z-index': '5' }); } }