File modules/template_engine/components/html/component_upload/upload.min.js
Last commit: Sat Dec 18 03:47:23 2021 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments.
1 import Api from "../../../../cms/ui/themes/default/script/openrat/api.min.js"; 2 import $ from "../../../../cms/ui/themes/default/script/jquery-global.min.js"; 3 export default function (element ) { 4 let form = $(element).find('form'); 5 let dropzone = $(element).find('div.or-dropzone-upload'); 6 dropzone.on('dragenter', function (e) 7 { 8 e.stopPropagation(); 9 e.preventDefault(); 10 $(this).css('border', '1px dotted gray'); 11 }); 12 dropzone.on('dragover', function (e) 13 { 14 e.stopPropagation(); 15 e.preventDefault(); 16 }); 17 dropzone.on('drop', function (e) 18 { 19 $(this).css('border','1px dotted red'); 20 e.preventDefault(); 21 let files = e.originalEvent.dataTransfer.files; 22 handleFileUpload(form,files); 23 }); 24 $(element).find('input[type=file]').change( function() { 25 let files = this.files; 26 handleFileUpload(form,files); 27 }); 28 }; 29 let handleFileUpload = function(form,files) 30 { 31 for (let i = 0; i < files.length; i++) 32 { 33 let f = files[i]; 34 let form_data = new FormData(); 35 form_data.append('file' , f); 36 form_data.append('action' , $(form).data('action')); 37 form_data.append('subaction', $(form).data('method')); 38 form_data.append('token' , $(form).find('input[name=token]').val() ); 39 form_data.append('id' , $(form).find('input[name=id]' ).val() ); 40 form_data.append('output' , 'json' ); 41 let api = new Api(); 42 api.sendData( form_data ); 43 } 44 }
Downloadmodules/template_engine/components/html/component_upload/upload.min.js
History Sat, 18 Dec 2021 03:47:23 +0100 dankert New: Every ES6-Module should have a minified version for performance reasons. Bad: The Minifier "Jsqueeze" is unable to minify ES6-modules, so we had to implement a simple JS-Minifier which strips out all comments.