Mercurial > mozilla-the-big-picture
changeset 28:fd3973fcd1a1
hopefully fixed things so this should work over http rather than just file:.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 28 Nov 2009 13:41:41 -0500 |
parents | 7b2058439e99 |
children | d18879f4d6c0 |
files | mbp.js |
diffstat | 1 files changed, 47 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/mbp.js Sat Nov 28 13:34:24 2009 -0500 +++ b/mbp.js Sat Nov 28 13:41:41 2009 -0500 @@ -14,53 +14,55 @@ $(".mbp-entry img.small").each( function() { loadsLeft++; - this.addEventListener( - "load", - function() { - $("#countdown").text(--loadsLeft); + + function onLoaded() { + $("#countdown").text(--loadsLeft); - var siblings = [this.previousSibling, - this.nextSibling]; - for (var i = 0; i < siblings.length; i++) - if (siblings[i] && - siblings[i].isElementContentWhitespace) - $(siblings[i]).remove(); + var siblings = [this.previousSibling, + this.nextSibling]; + for (var i = 0; i < siblings.length; i++) + if (siblings[i] && + siblings[i].isElementContentWhitespace) + $(siblings[i]).remove(); - var clip = $(this).css("clip"); - var parts = clip.match(rectRegexp); - var crop = {top: parts[1], - right: parts[2], - bottom: parts[3], - left: parts[4]}; - crop.width = crop.right - crop.left; - crop.height = crop.bottom - crop.top; - var canvas = document.createElement("canvas"); - var self = $(this.parentNode).clone(); - $(canvas).mouseenter( - function() { - $("#images").empty(); - $("#images").append(self); - }); - $(canvas).addClass("thumbnail"); - $(this).before(canvas); - var ctx = canvas.getContext("2d"); - ctx.drawImage(this, - crop.left, - crop.top, - crop.width, - crop.height, - 0, - 0, - canvas.width, - canvas.height); - $(this).remove(); - if (loadsLeft == 0) { - $("#countdown").remove(); - $("#container").fadeIn(); - } - }, - false - ); + var clip = $(this).css("clip"); + var parts = clip.match(rectRegexp); + var crop = {top: parts[1], + right: parts[2], + bottom: parts[3], + left: parts[4]}; + crop.width = crop.right - crop.left; + crop.height = crop.bottom - crop.top; + var canvas = document.createElement("canvas"); + var self = $(this.parentNode).clone(); + $(canvas).mouseenter( + function() { + $("#images").empty(); + $("#images").append(self); + }); + $(canvas).addClass("thumbnail"); + $(this).before(canvas); + var ctx = canvas.getContext("2d"); + ctx.drawImage(this, + crop.left, + crop.top, + crop.width, + crop.height, + 0, + 0, + canvas.width, + canvas.height); + $(this).remove(); + if (loadsLeft == 0) { + $("#countdown").remove(); + $("#container").fadeIn(); + } + } + + if (this.complete) + onLoaded.call(this); + else + this.addEventListener("load", onLoaded, false); }); $("#countdown").text(loadsLeft); });