- update cropper js

This commit is contained in:
ashubawork
2023-10-12 14:52:39 +03:00
parent e35e7b2fb6
commit 870e807765
3 changed files with 3290 additions and 1587 deletions
+3273 -1571
View File
File diff suppressed because it is too large Load Diff
+10 -13
View File
@@ -539,9 +539,6 @@ function initCrop_UM() {
zoomable: false,
rotatable: false,
dashed: false,
done: function(data) {
target_img.parent().attr('data-coord', Math.round(data.x) + ',' + Math.round(data.y) + ',' + Math.round(data.width) + ',' + Math.round(data.height) );
}
};
} else if ( crop_data == 'cover' ) {
@@ -556,9 +553,6 @@ function initCrop_UM() {
zoomable: false,
rotatable: false,
dashed: false,
done: function(data) {
target_img.parent().attr('data-coord', Math.round(data.x) + ',' + Math.round(data.y) + ',' + Math.round(data.width) + ',' + Math.round(data.height) );
}
};
} else if ( crop_data == 'user' ) {
@@ -571,16 +565,18 @@ function initCrop_UM() {
zoomable: false,
rotatable: false,
dashed: false,
done: function(data) {
target_img.parent().attr('data-coord', Math.round(data.x) + ',' + Math.round(data.y) + ',' + Math.round(data.width) + ',' + Math.round(data.height) );
}
};
}
if ( crop_data != 0 ) {
target_img.cropper( opts );
jQuery('.um-single-image-preview img.cropper-hidden').cropper('destroy');
// console.log( opts );
cropper = new Cropper(target_img[0], opts);
console.log(cropper.getCropBoxData())
// target_img.cropper( opts );
// cropper.destroy();
// jQuery('.um-single-image-preview img.cropper-hidden').cropper('destroy');
// jQuery('.um-single-image-preview img.cropper-hidden').cropper.destroy();
jQuery('.um-single-image-preview img.lazyloaded').addClass('cropper-hidden');
jQuery('.um-single-image-preview img.lazyloaded').removeClass('lazyloaded');
jQuery('.um-single-image-preview .cropper-container').append('<div class="um-clear"></div>');
@@ -727,7 +723,8 @@ function um_modal_responsive() {
}
function um_remove_modal() {
jQuery('img.cropper-hidden').cropper('destroy');
// jQuery('img.cropper-hidden').cropper('destroy');
cropper.destroy();
jQuery('body,html,textarea').css("overflow", "auto");
@@ -837,4 +834,4 @@ function um_selected( selected, current ){
if( selected == current ){
return "selected='selected'";
}
}
}
+7 -3
View File
@@ -95,7 +95,7 @@ jQuery(document).ready(function() {
var key = jQuery(this).attr('data-key');
var img_c = jQuery(this).parents('.um-modal-body').find('.um-single-image-preview');
var src = img_c.find('img').attr('src');
var coord = img_c.attr('data-coord');
// var coord = img_c.attr('data-coord');
var file = img_c.find('img').data('file');
var user_id = 0;
if ( jQuery(this).parents('#um_upload_single').data('user_id') ) {
@@ -111,10 +111,14 @@ jQuery(document).ready(function() {
mode = $formWrapper.attr('data-mode');
}
var data = cropper.getCropBoxData();
var coord = Math.round(data.left) + ',' + Math.round(data.top) + ',' + Math.round(data.width) + ',' + Math.round(data.height);
// target_img.parent().attr('data-coord', Math.round(data.x) + ',' + Math.round(data.y) + ',' + Math.round(data.width) + ',' + Math.round(data.height) );
console.log(coord);
if ( coord ) {
jQuery(this).html( jQuery(this).attr('data-processing') ).addClass('disabled');
console.log(src);
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'POST',
@@ -130,7 +134,7 @@ jQuery(document).ready(function() {
nonce: um_scripts.nonce
},
success: function( response ) {
console.log(response);
if ( response.success ) {
d = new Date();