Ok its posted under plugins in the userinterface section (see howlong until
its remove :( heh). Let me know how it goes. Made a few changes added reset
function. Next will remove the need for the cookies plugin and thats it i
think.

Cheers

Stefan

On 4/12/07, BKDesign Solutions <[EMAIL PROTECTED]> wrote:


This looks great! Needed, is there a demo anywhere for us noobs?

Bruce P
bkdesign

----- Original Message -----
From: "codemonkey" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 12, 2007 5:10 AM
Subject: [jQuery] Font Size Plugin Take 2


>
>
> Sorry first one had no spaces.
>
> Hi made a little plugin that handles resizing the font on a page. Only
> thing
> it relies on is that you have fonts set by em on your page. The plugin
> requires jquery and the cookies plugin.Feedback would be appreciated.
>
> Cheers...
>
> To use simply Initialise it like so:
>
> $(document).ready(function() {
>
> var options = { min: -1, max: 2};
> //Initialize the font sizer for the site.
> $.FontSizer.Init(options);
>
> });
>
> CODE
> --------------------------------------------------
>
> /**
> * Purpose: Font sizer class, handles increasing and decreasing font size
> of a page.
> * It increases the font in 10% increments. By getting the level / 10 +
1.
> i.e. level 2 is .2 + 1 so 1.2 or 120%.
> *
> * Requires: JQuery and the JQuery cookies plugin.
> *
> * Use: Setup the fontsizer $.FontSizer.Init(options); the two options
are
> min and max, for the min level and max level.
> * Defaults are min: -3 and max: 5.
> *
> * Author: Stefan Sedich ([EMAIL PROTECTED]
> */
> $.FontSizer = {
>
> level: 0,
>
> options : {
> min: -3,
> max: 5
> },
>
> Init : function(options) {
> if(options)
> $.FontSizer.options = $.extend($.FontSizer.options, options);
>
> //Get the current level from cookies.
> var level = ($.cookie('font_level') != null) ? $.cookie('font_level') :
0;
>
> //Set the font size to the current leve.
> $.FontSizer.SetFontSize(level);
>
> },
>
> IncreaseFontSize : function() {
>
> if(($.FontSizer.level) + 1 <= $.FontSizer.options.max) {
> //If we have not exceded the max level,
> //Get the next level and the set the size to this level.
> var next = (parseInt($.FontSizer.level) + 1);
> $.FontSizer.SetFontSize(next);
> }
>
> },
>
> DecreaseFontSize : function() {
> if(($.FontSizer.level - 1) >= $.FontSizer.options.min) {
> //If we have not exceded the min level,
> //Get the next level and the set the size to this level.
> var next = (parseInt($.FontSizer.level) - 1);
> $.FontSizer.SetFontSize(next);
> }
> },
>
> SetFontSize: function(level) {
>
> //Set the current level in the member variable and the cookie.
> $.FontSizer.level = level;
> $.cookie('font_level', level);
>
> //Work out the new em value and set it.
> var level = (level / 10) + 1;
> $("body").css("fontSize", level+"em");
>
> }
>
> };
> --
> View this message in context:
>
http://www.nabble.com/Font-Size-Plugin-Take-2-tf3564312s15494.html#a9955726
> Sent from the jQuery Plugins mailing list archive at Nabble.com.
>
>
>



Reply via email to