Created
January 2, 2010 19:23
-
-
Save cfpg/267624 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
javascript:(function() { | |
var s=document.createElement('script'); | |
s.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"); | |
if(typeof jQuery=='undefined') { | |
document.getElementsByTagName('head')[0].appendChild(s); | |
} | |
function doWork() { | |
$.expr[':'].image = function(obj){ | |
return obj.href.match(/(jpg|png|gif)$/i); | |
}; | |
$("a:image").each(function() { | |
var img = new Image(); | |
img.src = $(this).attr('href'); | |
$(img).attr("class", "thumb"); | |
$(this).html(img).attr("target", "_blank"); | |
$(img).load(function() { | |
$(img).attr("rel", img.width).css("width", getWidth(img.width)+"px"); | |
}); | |
}); | |
$("img.thumb").mouseover(function() { | |
$(this).css("width", $(this).attr("rel")+'px'); | |
}).mouseout(function() { | |
$(this).css("width", getWidth($(this).attr("rel"))+"px"); | |
}); | |
} | |
function getWidth(n) { | |
if ( n > 300 ) { | |
return n*0.6; | |
} else if ( n == 0 ) { | |
return "300"; | |
} else { | |
return n; | |
} | |
} | |
var tryjQuery=function() { | |
setTimeout(function() { | |
if (typeof jQuery=='undefined') { | |
if (tryCounter) { | |
tryCounter--; | |
tryjQuery(); | |
} else { | |
msg='Sorry, but after ' + startCounter; | |
showMsg(); | |
} | |
} else { | |
doWork(); | |
} | |
}, 250); | |
}; | |
tryjQuery(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment