this is not really new but I've used it in my two last projects (http://www.srdu.be) and Liro just asked me how did I manage to put the famous aaa (increase-decrease font size). I replied the PM and thought it could be usefull to publish it here too (though I have the feeling that I've read it before in the forum but don't remember where and a search didn't give results...
It's based on:
- adding some lines to the frontend.js
- duplicating your frontend.css in two other files (frontend_a.css and frontend_aa.css)
- the html code for displaying the functionnality
- putting 2 lines of code in your header (in your template).
- images for the aaa.
So, here it goes:
1. frontend.js (in phpwcms_templates/inc_js/frontend.js)
Add this (at the end of the file for example) to your frontend.js:
Code: Select all
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;
}
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);
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
Change the values of ALL css where font-size is used (typically the h1, h2, etc., the p tag, and so on...)
I use to increase everything by 2 px or .2em in the frontend_a.css and 4 px in the frontend_aa.css.
3. Displaying the feature: add this where you want the aaa to display in your page:
Code: Select all
<a onclick="setActiveStyleSheet('default'); return false;" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('_a','','picture/menu/_a_.gif',0)"><img src="picture/menu/_a.gif" name="_a" alt="Normaal" title="Normaal" border="0"></a><a onclick="setActiveStyleSheet('a'); return false;" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('_aa','','picture/menu/_aa_.gif',0)"><img src="picture/menu/_aa.gif" name="_aa" alt="Groter" title="Groter" border="0"></a><a onclick="setActiveStyleSheet('aa'); return false;" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('_aaa','','picture/menu/_aaa_.gif',0)"><img src="picture/menu/_aaa.gif" name="_aaa" alt="Grootste" title="Grootste" border="0"></a><br>
a, the default font size (named it _a.gif and _a_.gif for the mouse hover gif)
a, bigger font size (named it _aa.gif and _aa_.gif for the mouse hover gif)
a, biggest font size (named it _aaa.gif and _aaa_.gif for the mouse hover gif)
4. Adding 2 lines in your template, in your header:
Code: Select all
<link rel="alternate stylesheet" type="text/css" href="phpwcms_template/inc_css/frontend_a.css" title="a"/>
<link rel="alternate stylesheet" type="text/css" href="phpwcms_template/inc_css/frontend_aa.css" title="aa"/>
Voilà, I hope that this is usefull for you too.
PS: I know that you can increase/decrease font sizes by using your browser but A LOT of people don't
Cheers