load more than one scatterplot at a time but still make the dialog be cancellable

git-svn-id: http://google-refine.googlecode.com/svn/trunk@578 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-30 21:19:13 +00:00
parent bab1e8905b
commit 78d62d3caf

View File

@ -187,22 +187,33 @@ ScatterplotDialog.prototype._renderMatrix = function() {
}); });
var load_images = function(data) { var load_images = function(data) {
if (data.index < data.images.length && self._active) { if (self._active) {
data.index++; data.batch = 0;
var elmt = $(data.images[data.index]); var end = Math.min(data.index + data.batch_size,data.images.length);
var src2 = elmt.attr("src2"); for (; data.index < end; data.index++) {
if (src2) { load_image(data);
elmt.attr("src", src2);
elmt.removeAttr("src2");
elmt.load(function() {
load_images(data);
});
} }
} }
}; };
var load_image = function(data) {
var img = $(data.images[data.index]);
var src2 = img.attr("src2");
if (src2) {
img.attr("src", src2);
img.removeAttr("src2");
img.load(function() {
data.batch++;
if (data.batch == data.batch_size) {
load_images(data);
}
});
}
};
load_images({ load_images({
index : 0, index : 0,
batch_size: 4,
images : container.find(".scatterplot img") images : container.find(".scatterplot img")
}) })
}); });