(function( $ ){

  $.fn.textSizer = function( options ) 
  {  
    
    var settings = 
    {
      action: 1, // increase size = 1, decrease = 0
      name: ["body"], // array of selectors to target
      maxmin: 16, // min/max text height, it is min or max depending on your action arg val
      weight: 1.1 // increase/decrease ratio, if action is 0 weight should be 0.{n} value e.g 0.9
    };
    
    var actionEnum =
    {   
        decrease: 0,
        increase: 1
    }

    return this.each(function() 
    {        
      
        if ( options ) 
        {
            $.extend( settings, options );
        }
    
        $(this).click(
            function()
            {   
                
                $.each(settings.name, function(idx, val){
                    var currentFontSize = $(val).css('font-size');
                    var currentFontSizeNum = parseFloat(currentFontSize, 10);         
                    
                    switch(Number(settings.action))
                    {

                        case actionEnum.increase:
                         
                            if (currentFontSizeNum <= settings.maxmin)
                            {
                                var newFontSize = Math.round(currentFontSizeNum * settings.weight);
                                
                                $(val).css('font-size', newFontSize);
                            }
                            break;
                            
                        case actionEnum.decrease:
                            
                            if (currentFontSizeNum >= settings.maxmin)
                            {
                                var newFontSize = Math.round(currentFontSizeNum * settings.weight);
                                $(val).css('font-size', newFontSize);
                            }
                            break;
                            
                        case NaN:
                            default:
                            alert("textSizer config error: action property must be a number");
                            return false;
                            break;
                    }
                }) 
            }
        );
    });
  };
})( jQuery );
