FontSizer

Summary: Add buttons for instant font (text) resizing, preferrences are stored
Version: 2006-10-28
Status: stable
Prerequisites: pmwiki-2.0
Maintainer: DaveG
Categories: Layout Skins
Download: fontsizer.zipΔ
Users: (View / Edit)

Question

How can I add an easy way for visitors/users to change font sizes?

Answer

Fontsizer allows instant incremental text sizing, and preferred text size is remembered via a cookie setting. It adds button links to increase/decrease the size of all text via markup (:fontsizer:), usually added to the SideBar or the header or top menu.

Prerequisites:

  • Skin with fonts set to relative units (em or ex or %, not pt or mm etc.)
  • Javascript enabled browser

Installation

Download fontsizer.zipΔ, extract fontsizer.php to cookbook/ folder and fontsizer.js to pub/fontsizer/. Add to config.php:

              include_once("$FarmD/cookbook/fontsizer.php");

Description

The fontsizer is based on javascript and creates links via markup (:fontsizer:) for quick changing of all fontsizes. The preferred size gets stored in a cookie, so changes have an effect on viewing all the pages of the site and are remembered the next time the visitor/user comes back to the site.

Internationalisation of the fontsizer link names is enabled.

The fontsizer links are not displayed if the browser is not supporting javascript or javascript is disabled.

Notes

Depending on the font setting of the page section (:fontsizer:) markup is deployed, the text font size may change initially. This can be counteracted by setting a different value for $FontSizeDefault. For instance if the sidebar font is 75% of the body font size , then $FontSizeDefault = '75'; may work better.

This problem of adjustments needed for various skins is caused by the placement of the script initialization code in a div and not immediately after the <body> tag in the html source. To overcome this place the variable $FontSizerInit into the skin template file directly underneath the <body> tag. This will add the script initialization code into the more suitable placement.

If you wish to load the script via the skin's skin.php file, and have fontsizer.php and fontsizer.js moved to the skin directory, then you need to change the code line loading fontsizer.js to give the right location of $SkinDirUrl and not $FarmPubDirUrl, and add to skin.php include_once("$SkinDir/fontsizer.php");.

  • This recipe was last tested on PmWiki version: 2.0.beta30
  • This recipe requires at least PmWiki version: and (any other recipes)
  • This recipe, version...... was installed here the...(date)

Releases

  • 2006-10-28: Added $RecipeInfo
  • 2006-09-02: Added access keys.
  • 2006-04-28: Removed onkeypress event from fontsizer.js, which interfered with tab navigation.
  • 2006-03-10: added switch and variable to enable better initialization.
  • 2006-03-08: updated code so fontsizer will work in a Farm Isidor
  • 2006-03-08: updated code so fontsizer will not be displayed if javascript is disabled.
  • 2006-03-06: rewritten code so fontsizer can be added as cookbook module.
  • 2005-11-19: first release as skin add-on module.

Comments

2007-05-19 Isidor Issue with recipecheck or analyze It's not possible for the Analyze to find the version of script on pmwiki.org because of the zip file. could it be possible to have the .php and .css not in a Zip Also the name in the Analyze is Cookbook:Fontsizer? and not Cookbook:FontSizer Regards

See Also

Contributors


Category: Skins

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.