MediaWiki:Common.js/User:Bawolff/sandbox/leads

From Wikinews, the free news source you can write!
Jump to navigation Jump to search

//

//Make ticker go pixel at a time and more efficient (may not always work depending on load order). Probably should do some other way
if (navigator.userAgent.indexOf("MSIE") == -1) {
$(function () {window.setTimeout((function () {mw.loader.load( '/w/index.php?title=' + "User:Bawolff/Sandbox/tick.js" + '&action=raw&ctype=text/javascript' );}), 750);});
}
//This is just experimentation. No garuntee this will work on any computer that isn't mine
function resizePage() {
var pageWidth = document.getElementById("contentSub").offsetWidth;
var mainBox = document.getElementById("BigBagOMainPage");
var lead1 = document.getElementById("new-main-page-left-lead");
var clearBot = 977;
var clearTop = 905; //+2 extra
var nativeRes = 1053;
var stopCaring = 200; //lower limit
var boxWidth = Math.round(((pageWidth/13)-2)*10)/10;  //Assumes font-size: 13. converts to ems
var widthCompensator = Math.round((pageWidth/21.9014)*10)/10;
var widthCompensator2 = Math.round((pageWidth/33.7)*10)/10; //this is imprecise

//between clearTop and clearBottom (903 - 977)
if (pageWidth < clearBot && pageWidth > clearTop) {
document.getElementById("brBetweenLeftLeads").style.clear = "both";
lead1.style.width = widthCompensator + "em";
lead1.style.paddingLeft = "6em";
lead1.style.paddingRight = "6em";
} // >977
else if (pageWidth > clearBot) {
document.getElementById("brBetweenLeftLeads").style.clear = "right";
lead1.style.width = "34.6em";
}
// < 903
if (pageWidth <= clearTop && pageWidth > stopCaring) {
document.getElementById("new-main-page-right-top-lead").style.clear = "both";
lead1.style.width = (boxWidth-1) + "em";
lead1.style.paddingLeft = "0";
lead1.style.paddingRight = "0";
} //>903 (runs after first if)
else if (pageWidth > clearTop) {
document.getElementById("new-main-page-right-top-lead").style.clear = "none";
}
//below nativeRes but full two column
if (pageWidth > clearBot && pageWidth < nativeRes) {
lead1.style.width = widthCompensator2 + "em";
lead1.style.paddingLeft = "6em";
lead1.style.paddingRight = "6em";
}
//Anything higher then 1280x1024 uses fixed width for 1280x1024 as I'm getting tired.
if (pageWidth >= nativeRes) {
lead1.style.width = "34.6em";
lead1.style.paddingLeft = "6em";
lead1.style.paddingRight = "6em";
mainBox.style.width = "81.9em";
}

if (pageWidth > stopCaring && pageWidth < nativeRes) { //if its less, then this is really screwed up anyhow, so goto fixed width
mainBox.style.width = boxWidth + "em";
}
}

$(resizePage);
window.onresize = resizePage;
//