Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created March 14, 2011 03:14
Show Gist options
  • Save lazypower/868699 to your computer and use it in GitHub Desktop.
Save lazypower/868699 to your computer and use it in GitHub Desktop.
$(document).ready(function()
{
$("ul.lfm-thumb li").hover(function() {
if ($(this).hasClass("lfm-lefborder")) {
marTop = '110px';
marLeft = '110px';
} else {
marTop = '-110px'; /* The next 4 lines will vertically align this image */
marLeft = '-110px';
}
$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/
$(this).find('img:not(#tooltip.img)').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
.animate({
marginTop: marTop,
marginLeft: marLeft,
top: '50%',
left: '50%',
width: '174px', /* Set new width */
height: '174px',
padding: '20px'
}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */
} , function() {
$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
$(this).find('img').removeClass("hover").stop() /* Remove the "hover" class , then stop animation queue buildup*/
.animate({
marginTop: '0', /* Set alignment back to default */
marginLeft: '0',
top: '0px',
left: '0px',
width: '100px', /* Set width back to default */
height: '100px', /* Set height back to default */
padding: '1px'
}, 400);
}); // end of animation
// NowPlaying animation -- you will notice this looks STRIKINGLY SIMILAR to the tooltip code (thanks for the idea ;)
/* if ($('img').hasclass('nowplaying')) {*/
////var playing = $(this).attr('playing');
////$(this).attr('playing','');
//$(this.append('<div id="nowplaying"><img src="icon_eq.gif" alt="Currently Listening!"></div>'));
//$('#nowplaying').fadeIn('800');
//}
// TOOLTIP!!
//Select all anchor tag with rel set to tooltip
$('a[rel=tooltip]').mouseover(function(e) {
//Grab the title attribute's value and assign it to a variable
var tip = $(this).attr('title');
//Remove the title attribute's to avoid the native tooltip from the browser
$(this).attr('title','');
//Append the tooltip template and its value
$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
//Show the tooltip with faceIn effect
$('#tooltip').fadeIn('500');
$('#tooltip').fadeTo('10',0.9);
}).mousemove(function(e) {
//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
//$('#tooltip').css('top', e.pageY + 10 ); not workiing, it shot it to the bottom of the browser
//$('#tooltip').css('left', e.pageX + 20 );
}).mouseout(function() {
//Put back the title attribute's value
$(this).attr('title',$('.tipBody').html());
//Remove the appended tooltip template
$(this).children('div#tooltip').remove();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment