Dynamically change font properties of a targeted element.
This control will edit all the h2 tags on the page.
Include the jquery.fonttweaks.js, jquery.js and jquery-ui-1.8.14.custom.min.js files in the head section of the page. And link the css stylesheets in the head section.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> <script type="text/javascript" src="js/jquery.fonttweaks.js"> </script> <link rel="stylesheet" type="text/css" href="js/jquery-ui-1.8.14.custom_2/css/ui-darkness/jquery-ui-1.8.14.custom.css" /> <link rel="stylesheet" type="text/css" href="css/ft_redglass.css" /> <link rel="stylesheet" type="text/css" href="css/webfonts.css" />
To change control styles simply change the ft_colorglass.css to the desired color. Here is a list of the available stylesheets:
The jquery-ui-1.8.14.custom.css stylesheet is needed to style the sliders on the control.
<div class="fonttweaks">
<!-- fontfamily selector -->
<select class="famcontrol">
<option selected="selected" value="selectfont" >Select a font...</option>
<option value="Fredoka One" fontname="Fredoka One" style="font-family:Fredoka One;">Fredoka One</option>
...
</select>
<!-- font size slider -->
<div class="fsize_slider_container">
<div class="fsize_slider_bar">
<div class="fsize_slider_caption"></div>
<div class="fsize_slider_handle"></div>
</div>
</div>
<!-- end font size slider -->
<!-- start color sliders -->
<div class="color_slider_wrap">
<div class="slider_red"></div>
<div class="slider_green"></div>
<div class="slider_blue"></div>
<div class="slider_opacity"></div>
<div class="color_caption"></div>
</div>
</div>
<!-- end .fonttweaks div
You can add webfonts to the options list by adding another option and set your font name to all the properties. Make sure to add the @import in the webfonts.css for your fonts.
You should target the container that holds the .fonttweak div. example:
$('#wrap').fonttweaks({
targettext: '.text1',
minfontsize: 2,
maxfontsize: 125,
});
The #wrap container contains the .fonttweaks div and will target the .text1 element.
Wrap the jQuery in a document.ready script like so and inlcude it on the page.
<script type="text/javascript">
$(document).ready(function(){
$('#wrap').fonttweaks({
targettext: '.text1', //required
minfontsize: 2, //optional default=2
maxfontsize: 125, //optional default=190
red: 155, //optional default=155
blue: 155, //optional default=155
green: 155, //optional default=155
easing: 'easeOutBounce', //optional default="swing"
openspeed: 2000, //optional default=2000
fadeSpeed: 2000, //optional default=2000
closedelay: 3000, //optional default=3000
hover: 'true', //optional default="true"
});
});
</script>
Feel free to style .fonttweaks to have a starting opacity less than zero. The plugin animates the controls to opacity:1; on mouseover.
For questions and concerns please email me at nuvuscripts@gmail.com.