Start typing to see products you are looking for.
function ajouter_mon_script() {
?>
document.addEventListener("DOMContentLoaded", function() {
(function($) {
if( window.Dropzone && window.Dropzone.instances) {
window.Dropzone.instances.forEach(function(i){
i.options.transformFile = function (file, done) {
var openEditor = function( dataURL ) {
window.wapfaiu.initCropper( i, file, dataURL, function (f) {
i.createThumbnail(f, i.options.thumbnailWidth, i.options.thumbnailHeight, i.options.thumbnailMethod, false, function (dataURL) {
i.emit('thumbnail', file, dataURL);
file.transformedFile = f;
done(f);
});
}, function () {
i.removeFile(file);
}, true, editorConfig.openType, $preview);
};
if( file.openedWithEdit ) return done(file);
var $preview = $(file.previewElement);
if (!$preview.length) return done(file);
var editorConfig = $preview.data('editor-config');
if ( ! editorConfig || ! editorConfig.openType || editorConfig.openType === 'button' || file.type.indexOf('image') == -1 || file.type === 'image/heic' )
return done(file);
var fr = new FileReader();
fr.onload = function( f ) {
var img = new Image();
img.onload = function() {
if( editorConfig.openType === 'crop_only' && editorConfig.ratio && wapfaiu.compareRatio(img.width,img.height, editorConfig.ratio) )
return done(file);
openEditor(f.target.result);
};
img.src = f.target.result;
};
fr.readAsDataURL(file);
}
});
}
$(document).on( 'wapf/file_uploaded', function(e,data) {
var $preview = $( data.file.previewElement );
if(!$preview.length) return;
var editorConfig = $preview.data('editor-config');
if( !editorConfig || data.file.type.indexOf( 'image' ) == -1 || data.file.type === 'image/heic' ) return;
var dropzone = $('#wapf-dz-'+ data.fieldId)[0].dropzone;
if ( ! dropzone ) return;
if( editorConfig.openType === 'crop_only' && ! editorConfig.ratio ) return;
window.wapfaiu.initCropper( dropzone, data.file, data.file.transformedFile ? data.file.transformedFile.dataURL : data.file.dataURL, null, null, false, editorConfig.openType, $preview);
});
})(jQuery);
});