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

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

//

 1 //Make ticker go pixel at a time and more efficient (may not always work depending on load order). Probably should do some other way
 2 /*if (navigator.userAgent.indexOf("MSIE") == -1) {
 3 addOnloadHook(function () {window.setTimeout((function () {mw.loader.load( '/w/index.php?title=' + "User:Bawolff/Sandbox/tick.js" + '&action=raw&ctype=text/javascript' );}), 750);});
 4 }*/
 5 //This is just experimentation. No garuntee this will work on any computer that isn't mine
 6 function resizePage() {
 7 var pageWidth = document.getElementById("contentSub").offsetWidth;
 8 var mainBox = document.getElementById("BigBagOMainPage");
 9 var lead1 = document.getElementById("new-main-page-left-lead");
10 var clearBot = 800;
11 var clearTop = 720; //+2 extra
12 var nativeRes = 816;
13 var stopCaring = 200; //lower limit
14 var boxWidth = Math.round(((pageWidth/13)-2)*10)/10;  //Assumes font-size: 13. converts to ems
15 var widthCompensator = Math.round((pageWidth/21.9014)*10)/10;
16 var widthCompensator2 = Math.round((pageWidth/33.7)*10)/10; //this is imprecise
17 
18 //between clearTop and clearBottom (903 - 977)
19 if (pageWidth < clearBot && pageWidth > clearTop) {
20 document.getElementById("brBetweenLeftLeads").style.clear = "both";
21 lead1.style.width = widthCompensator + "em";
22 lead1.style.paddingLeft = "1em";
23 lead1.style.paddingRight = "1em";
24 } // >977
25 else if (pageWidth > clearBot) {
26 document.getElementById("brBetweenLeftLeads").style.clear = "right";
27 lead1.style.width = "23em";
28 }
29 // < 903
30 if (pageWidth <= clearTop && pageWidth > stopCaring) {
31 document.getElementById("new-main-page-right-top-lead").style.clear = "both";
32 lead1.style.width = (boxWidth-1) + "em";
33 lead1.style.paddingLeft = "0";
34 lead1.style.paddingRight = "0";
35 } //>903 (runs after first if)
36 else if (pageWidth > clearTop) {
37 document.getElementById("new-main-page-right-top-lead").style.clear = "none";
38 }
39 //below nativeRes but full two column
40 if (pageWidth > clearBot && pageWidth < nativeRes) {
41 lead1.style.width = widthCompensator2 + "em";
42 lead1.style.paddingLeft = "1em";
43 lead1.style.paddingRight = "1em";
44 }
45 
46 if (pageWidth >= nativeRes) {
47 lead1.style.width = "23em";
48 lead1.style.paddingLeft = "1em";
49 lead1.style.paddingRight = "1em";
50 //mainBox.style.width = "81.9em";
51 }
52 
53 if (pageWidth > stopCaring && pageWidth < nativeRes) { //if its less, then this is really screwed up anyhow, so goto fixed width
54 mainBox.style.width = boxWidth + "em";
55 }
56 }
57 
58 addOnloadHook(resizePage);
59 window.onresize = resizePage;
60 //