User:Archimedes5000/vector.js: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
}; | }; | ||
mobilefix(); | mobilefix(); | ||
/*Adds scrollable div wrappers to tables*/ | |||
function tablefix(){ | |||
var table = document.querySelectorAll("table"); | |||
for(var i = 0; i < table.length; i = i+1){ | |||
var w = document.createElement("div"); | |||
w.class = "table_wrapper"; | |||
w.style = "overflow-x:scroll"; | |||
table[i].parentNode.replaceChild(w, table[i]); | |||
w.appendChild(table[i]); | |||
}; | |||
}; | |||
if(window.innerWidth <= 700){ | |||
tablefix(); | |||
}; | |||
/*Restores search on narrow screens by moving it above navigation*/ | /*Restores search on narrow screens by moving it above navigation*/ | ||
Line 10: | Line 25: | ||
var s = document.querySelector("#p-search"); | var s = document.querySelector("#p-search"); | ||
var p = document.querySelector("#right-navigation"); | var p = document.querySelector("#right-navigation"); | ||
var a = document.querySelector("div.vector-menu-content"); | var a = document.querySelector("#p-personal>div.vector-menu-content"); | ||
if(window.innerWidth <= 700){ | if(window.innerWidth <= 700){ | ||
a.prepend(s); | a.prepend(s); | ||
Line 18: | Line 33: | ||
}; | }; | ||
searchfix(); | searchfix(); | ||
window.addEventListener("resize", | window.addEventListener("resize", searchfix); | ||
Latest revision as of 11:53, 24 March 2024
/*Forces responsive content*/ function mobilefix(){ var m = document.querySelector('meta[name="viewport"]'); m.content = "width=device-width, initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0"; }; mobilefix(); /*Adds scrollable div wrappers to tables*/ function tablefix(){ var table = document.querySelectorAll("table"); for(var i = 0; i < table.length; i = i+1){ var w = document.createElement("div"); w.class = "table_wrapper"; w.style = "overflow-x:scroll"; table[i].parentNode.replaceChild(w, table[i]); w.appendChild(table[i]); }; }; if(window.innerWidth <= 700){ tablefix(); }; /*Restores search on narrow screens by moving it above navigation*/ function searchfix(){ var s = document.querySelector("#p-search"); var p = document.querySelector("#right-navigation"); var a = document.querySelector("#p-personal>div.vector-menu-content"); if(window.innerWidth <= 700){ a.prepend(s); }else if(window.innerWidth > 700){ p.append(s); }; }; searchfix(); window.addEventListener("resize", searchfix);