This is build from different codes I found on the internet.
plugins.js
//Font Size changer
function resizeText(multiply) {
var sz = document.body.style.fontSize;
if (sz =='') sz = 1.0; //default font size
var size = parseFloat(sz) + (multiply * 0.2) + "em";
document.body.style.fontSize = size;
createCookie("fs",size,365);
}
function resetText(){
document.body.style.fontSize = "1.0em";
size = "1.0em";
createCookie("fs",size,365);
}
// Stylechanger
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}
//Build and read Cookies
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
var sz = readCookie('fs');
if (sz != null && sz != '') {
document.body.style.fontSize= sz;
}
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
var sz = readCookie('fs');
if (sz != null && sz != '') {
document.body.style.fontSize= sz;
}
And the file where the functions are activated (labels are in german)
<div id="top">
<div id="holder">
<span id="bold">Erleichtere Bedienung</span>
<span>Schriftgr??e (Font Size)</span>
<ul>
<li>
<a href="#" onclick="resizeText(1); return false;" title="Die Schrift vergrößern" ><img class="bigger" alt="+" src="<?php echo get_template_directory_uri(); ?>/styles/images/font_plus.png"></a>
</li><li>
<a href="#" class="smaller" onclick="resizeText(-1); return false;" title="Die Schrift verkleinern" ><img class="smaller" alt="+" src="<?php echo get_template_directory_uri(); ?>/styles/images/font_minus.png"></a>
</li><li>
<a href="#" onclick="resetText(); return false;" title="Normale Schrift" >Aus</a>
</li>
</ul>
<span>Kontrast (Contrast)</span>
<ul>
<li>
<a href="#" class="contrast-white" onclick="setActiveStyleSheet('contrast1'); return false;" title="Schwarz auf Weiß" ><img class="smaller" alt="con1" src="<?php echo get_template_directory_uri(); ?>/styles/images/contrast2.png"></a>
</li><li>
<a href="#" class="contrast-black" onclick="setActiveStyleSheet('contrast2'); return false;" title="Weiß auf Schwarz"><img class="smaller" alt="con2" src="<?php echo get_template_directory_uri(); ?>/styles/images/contrast1.png"></a>
</li><li>
<a href="#" onclick="setActiveStyleSheet('Default'); return false;" title="Kontrast ausschalten">Aus</a>
</li>
</ul>
<span>Leichte Sprache</span>
<ul>
<?php pll_the_languages();?>
</ul>
</div>
</div><!-- #top -->