A jQuery plugin that applies highlight and shadow effects to text in a control. If you find this plugin useful please vote for it on the jQuery site.
The current version is 1.0.0 and is available under the GPL and MIT licences. For more detail see the documentation reference page. Or see a minimal page that you could use as a basis for your own investigations.
The label effect functionality can easily be added to a control containing text
with appropriate default settings.
You can also remove the label effect functionality if it is no longer required.
Default effect (floating): Floating text
$('#defaultEffect').labeleffect();
$('#removeEffect').toggle(function() {
$(this).text('Re-attach');
$('#defaultEffect').labeleffect('destroy');
},
function() {
$(this).text('Remove');
$('#defaultEffect').labeleffect();
}
);
You can override the defaults globally as shown below:
$.labeleffect.setDefaults({effect: 'sunken'});
Processed fields are marked with a class of hasLabelEffect
and are not re-processed if targetted a second time.
Several preset effects can be invoked via a single option that provides values for most of the other settings.
Raised text: Raised text
$('#raisedEffect').labeleffect({effect: 'raised'});
Sunken text: Sunken text
$('#sunkenEffect').labeleffect({effect: 'sunken'});
Echoed text: Echoed text
$('#echoedEffect').labeleffect({effect: 'echoed'});
Floating text: Floating text
$('#floatingEffect').labeleffect({effect: 'floating'});
Shadow text: Shadow text
$('#shadowEffect').labeleffect({effect: 'shadow'});
You can customise any of the settings to achieve your own effect. There are two aspects to the effects - a highlight and a shadow. Each can have its own colour, direction, and distance. You can also have the effect fill the intervening space and even blend from the main colour to the effect colour.
Text:
Highlight:
Shadow:
Sample: Customised text
$('#customEffect').labeleffect();
$('#custom input, #custom select').change(function() {
$('#customEffect').labeleffect('change',
{color: $('#customColour').val(),
hiColor: $('#customHiColour').val(),
hiDir: $('#customHiDir').val(),
hiOffset: $('#customHiOffset').val(),
hiFill: $('#customHiFill').is(':checked'),
hiBlend: $('#customHiBlend').is(':checked'),
shadowColor: $('#customShadowColour').val(),
shadowDir: $('#customShadowDir').val(),
shadowOffset: $('#customShadowOffset').val(),
shadowFill: $('#customShadowFill').is(':checked'),
shadowBlend: $('#customShadowBlend').is(':checked')});
});
You can apply the effects to anything that contains text.
A whole paragraph.
$('.anythingEffect').labeleffect({shadowOffset: 10});
This tab highlights examples of this plugin in use "in the wild".
None as yet.
To add another example, please contact me (kbwood{at}iinet.com.au) and provide the plugin name, the URL of your site, its title, and a short description of its purpose and where/how the plugin is used.
A full list of all possible settings is shown below. Note that not all would apply in all cases. For more detail see the documentation reference page.
$(selector).labeleffect({
color: '', // Main text colour
hiColor: 'silver', // The highlight colour
hiDir: this.NONE, // The highlight direction
hiOffset: 0, // The highlight offset
hiFill: false, // True to fill from main text to highlight
hiBlend: false, // True to blend from main color to highlight
shadowColor: 'silver', // The shadow colour
shadowDir: this.DOWNRIGHT, // The shadow direction
shadowOffset: 5, // The shadow offset
shadowFill: false, // True to fill from main text to shadow
shadowBlend: false, // True to blend from main color to shadow
effect: '' // A preset effect
});
$.labeleffect.setDefaults(settings) // Change settings for all instances
$.labeleffect.addEffect(id, settings) // Add a new named effect
$.labeleffect.getEffects() // Retrieve a list of named effects
$(selector).labeleffect('change', settings) // Change the instance settings
$(selector).labeleffect('change', name, value) // Change a single setting
$(selector).labeleffect('destroy') // Remove the label effect functionality
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><style type="text/css">@import "jquery.labeleffect.css";</style>
<script type="text/javascript" src="jquery.labeleffect.js"></script>
Alternately, you can use the packed version
jquery.labeleffect.pack.js (4.4K vs 11.4K), or the minified version
jquery.labeleffect.min.js (5.4K, 1.9K when zipped).$(selector).labeleffect();
You can include custom settings as part of this process.
$(selector).labeleffect({effect: 'floating'});For more detail see the documentation reference page. Or see a minimal page that you could use as a basis for your own investigations.
None as yet.
Contact Keith Wood at kbwood{at}iinet.com.au with comments or suggestions.
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 25 Jul 2009 |
|