.then(function() {
//Show and Hide Input File
this.evaluate(function() {
jQuery('#new_upload_image').css('display', 'block');
});
this.fill('form#postform', {
'upload_data': '".$image."'
}, false);
this.evaluate(function() {
jQuery('#new_upload_image').css('display', 'none');
});
})
.then(function() {
if(this.exists('button#done')) {
this.evaluate(function() {
jQuery('#done').click();
});
//The click event is correctly fired
}
else {
this.die('button dont exist', 1);
}
})
A.$done.click(function() { if (A.$cropper === null) { return false; } A.$loader.show(); var E = A.$cropper.getCroppedCanvas({ width: 840, height: 740, fillColor: "#fff" }); var H = E.toDataURL("image/jpeg", 0.98); var F = new FormData(); var C = A.convertToBlob(E, "image/jpeg", H); var D = { action: "upload" }; var G = A.createParams(D); F.append("upload_data", C, A.file_name); F.append("params", JSON.stringify(G)); xhr = new XMLHttpRequest(); xhr.open("POST", A.url, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { A.success(JSON.parse(xhr.responseText)); A.$loader.hide(); A.$uploadBtn.show(); } else { if (xhr.status === 404 || xhr.status === 500) { A.showErrorMessage(__("general_upload_fail_mobile")); A.$loader.hide(); A.$uploadBtn.show(); A.resetFormElement(A.$input); } } }; xhr.send(F); $J("html, body").scrollTop(A.$header.offset().top); A.hideCropper();});