"Расширитель" кода на jQuery Показать код полностью

ПримерНаведите курсор на область с кодом ниже

$(document).ready(function() {
	$("pre.jcexpander").each(function(){

		if( $("code", this).height() > $(this).height() ||
			$("code", this).width() > $(this).width()) {

			$(this).data('originalHeight' , $(this).height());
			$(this).data('originalWidth', $(this).width());

			var icon = document.createElement("img");
			$(icon).css({ 'position' : 'absolute'});
			$(icon).attr("src", "images/fullscreen.png");

			$(icon).prependTo($(this));

			$(this).hover(function(){

				$(icon).fadeOut();

				var codeWidth = $("code", this).width();
				var codeHeight = $("code", this).height();

				$(this)
					.stop()
					.animate({
						width : codeWidth + "px",
						height : codeHeight + "px"
					}, 1500);

			}, function(){

				$(icon).fadeIn();

				$(this)
					.stop()
					.animate({
						width : $(this).data('originalWidth') + "px",
						height : $(this).data('originalHeight') + "px"
					}, 1500);
			});
		}
	});
});

Код

$(document).ready(function() {
	$("pre.jcexpander").each(function(){

		if( $("code", this).height() > $(this).height() ||
			$("code", this).width() > $(this).width()) {

			$(this).data('originalHeight' , $(this).height());
			$(this).data('originalWidth', $(this).width());

			var icon = document.createElement("img");
			$(icon).css({ 'position' : 'absolute'});
			$(icon).attr("src", "images/fullscreen.png");

			$(icon).prependTo($(this));

			$(this).hover(function(){

				$(icon).fadeOut();

				var codeWidth = $("code", this).width();
				var codeHeight = $("code", this).height();

				$(this)
					.stop()
					.animate({
						width : codeWidth + "px",
						height : codeHeight + "px"
					}, 1500);

			}, function(){

				$(icon).fadeIn();

				$(this)
					.stop()
					.animate({
						width : $(this).data('originalWidth') + "px",
						height : $(this).data('originalHeight') + "px"
					}, 1500);
			});
		}
	});
});