put crop setCSS into a callback also - modify setCSS function to accept a callback param

This commit is contained in:
Sanj 2012-03-06 18:10:32 +05:30
parent 78b530205d
commit b28f9a6f87

View File

@ -861,12 +861,14 @@ ImageBox.prototype.updateCSS = function(css) {
}); });
}; };
ImageBox.prototype.setCSS = function(css, doUpdate) { ImageBox.prototype.setCSS = function(css, doUpdate, callback) {
var that = this;
var update = doUpdate == undefined ? true : doUpdate; var update = doUpdate == undefined ? true : doUpdate;
this.jq.css(css); this.jq.css(css);
if (update) { if (update) {
this.updateCSS(css); this.updateCSS(css);
} }
callback == undefined ? $.noop() : callback(that);
return this; return this;
}; };
@ -1562,8 +1564,10 @@ $(".box").live("click", function(e){
// console.log(data.path); // console.log(data.path);
new_top = parseInt(box_top) + crop_dimensions.y; new_top = parseInt(box_top) + crop_dimensions.y;
new_left = parseInt(box_left) + crop_dimensions.x; new_left = parseInt(box_left) + crop_dimensions.x;
boxObj.setCSS({'width': crop_dimensions.w, 'height': crop_dimensions.h}, false); boxObj.setCSS({'width': crop_dimensions.w, 'height': crop_dimensions.h}, false, function(obj) {
boxObj.setCSS({'top': new_top, 'left': new_left}); obj.setCSS({'top': new_top, 'left': new_left});
});
jcrop.destroy(); jcrop.destroy();
box.find('.edgeImage').attr("width", crop_dimensions.w); box.find('.edgeImage').attr("width", crop_dimensions.w);
box.find('.edgeImage').attr("height", crop_dimensions.h); box.find('.edgeImage').attr("height", crop_dimensions.h);