Created
July 22, 2010 09:34
-
-
Save rowanmanning/485772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery expandAbbr Plugin 0.1 | |
* | |
* Tested in jQuery 1.4.2 | |
* | |
* Copyright 2010, Rowan Manning (http://www.rowanmanning.co.uk/) | |
* Dual licensed under the MIT or GPL Version 2 licenses | |
*/ | |
(function($){ | |
//============================================================ | |
// abbreviations expanding functions | |
// expand abbreviations | |
$.fn.expandAbbr = function(highlightColor){ | |
// default the colour | |
var highlightColor = (highlightColor ? highlightColor : '#ffcc00'); | |
// bind a click event | |
return $(this).bind('click', function(e){ | |
// variables | |
var | |
// get the abbreviation | |
$abbr = $(this), | |
// get the expanded text | |
expanded = $abbr.attr('title'); | |
// expand the abbreviation | |
if (expanded){ | |
// variables | |
var | |
// get the parent's colour | |
parent_color = $abbr.parent().css('color'), | |
// create and append a span | |
$span = $(['<span class="abbr-expanded">', expanded, '</span>'].join('')) | |
.css({ | |
color: highlightColor | |
}) | |
.insertAfter($abbr) | |
.animate({ | |
color: parent_color | |
},{ | |
duration: 3000 | |
}); | |
// remove the abbreviation | |
$abbr.remove(); | |
} | |
}); | |
}; | |
//============================================================ | |
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jQuery expandAbbr Plugin 0.1 | |
* | |
* Tested in jQuery 1.4.2 | |
* | |
* Copyright 2010, Rowan Manning (http://www.rowanmanning.co.uk/) | |
* Dual licensed under the MIT or GPL Version 2 licenses | |
*/ | |
(function(a){a.fn.expandAbbr=function(b){b=b?b:"#ffcc00";return a(this).bind("click",function(){var c=a(this),d=c.attr("title");if(d){var e=c.parent().css("color");a(['<span class="abbr-expanded">',d,"</span>"].join("")).css({color:b}).insertAfter(c).animate({color:e},{duration:3E3});c.remove()}})}})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment