var ret = JSON.parse(r);
if ( ret.error ) {
- $('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p><div>');
+ $('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p></div>');
imageEdit.close(postid);
return;
}
open : function( postid, nonce, view ) {
this._view = view;
- var data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
+ var dfd, data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
btn = $('#imgedit-open-btn-' + postid), spin = btn.siblings('.spinner');
btn.prop('disabled', true);
'do': 'open'
};
- elem.load(ajaxurl, data, function() {
- elem.fadeIn('fast');
+ dfd = $.ajax({
+ url: ajaxurl,
+ type: 'post',
+ data: data
+ }).done(function( html ) {
+ elem.html( html );
head.fadeOut('fast', function(){
+ elem.fadeIn('fast');
btn.removeAttr('disabled');
spin.hide();
});
});
+
+ return dfd;
},
imgLoaded : function(postid) {
},
setCropSelection : function(postid, c) {
- var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128',
- sizer = this.hold.sizer;
- min = min.split(':');
- c = c || 0;
+ var sel;
+
+ c = c || 0;
if ( !c || ( c.width < 3 && c.height < 3 ) ) {
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
return false;
}
- if ( c.width < (min[0] * sizer) && c.height < (min[1] * sizer) ) {
- this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
- $('#imgedit-selection-' + postid).val('');
- return false;
- }
-
sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1);
$('#imgedit-selection-' + postid).val( JSON.stringify(sel) );