(function($) { $(function() { var wrapper$; wrapper$ = $("#editors-diary > div.wrapper"); function buildImage(postId, imageURL, link) { var div$, link$, image$; div$ = $("
").appendTo(wrapper$); link$ = $("", { //"href": link //"href": "/trendsshopping/stylenotes/032812_Editors_Diary/?tumblr-post=" + postId "href": "/trendsshopping/stylenotes/032812_Editors_Diary/" }).appendTo(div$); image$ = $("").css({ "position": "relative", "visibility": "hidden" }).appendTo(link$); image$.load(function() { var image$, width, height, fittedWidth; image$ = $(this); width = image$.width(); height = image$.height(); if (width > height) { image$.css("height", "100px"); } else { image$.css("width", "100px"); } fittedWidth = image$.width(); if (fittedWidth > 100) { image$.css("left", "-" + Math.floor((fittedWidth - 100) / 2) + "px"); } image$.hide().css("visibility", "visible").fadeIn("medium"); }); image$.attr("src", imageURL); } function tumblr(data) { if (!data || !data.posts) return; var i, post; for (i = 0; i < 3 && i < data.posts.length; ++i) { post = data.posts[i]; buildImage(post.id, post["photo-url-250"], post["photo-link-url"]); } } $.ajax({ url: "http://officialstyledotcom.tumblr.com/api/read/json?start=0&num=20&type=photo", dataType: "jsonp", success: tumblr }); }); })(jQuery);