From: Jakobus Schürz Date: Wed, 15 Mar 2023 20:05:16 +0000 (+0100) Subject: changes in case of codereview X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=16f065e2600c92354b6e1995385889873a840c24;p=friendica.git changes in case of codereview --- diff --git a/view/js/dropzone-factory.js b/view/js/dropzone-factory.js index fe6c4448b2..5aaab50362 100644 --- a/view/js/dropzone-factory.js +++ b/view/js/dropzone-factory.js @@ -1,6 +1,6 @@ var DzFactory = function () { - this.createDropzone = function(element, target, maxImagesize) { - return new Dropzone( element, { + this.createDropzone = function(dropSelector, textareaSelector, maxImagesize) { + return new Dropzone( dropSelector, { paramName: 'userfile', // The name that will be used to transfer the file maxFilesize: maxImagesize, // MB url: '/media/photo/upload?response=url&album=', @@ -9,14 +9,14 @@ var DzFactory = function () { }, init: function() { this.on('success', function(file, serverResponse) { - var _target = $(target) - var resp = $(serverResponse).find('div#content').text() - if (_target.setRangeText) { + const targetTextarea = document.getElementById(textareaSelector); + const bbcodeString = $(serverResponse).find('div#content').text(); + if (targetTextarea.setRangeText) { //if setRangeText function is supported by current browser - _target.setRangeText(' ' + $.trim(resp) + ' ') + targetTextarea.setRangeText(' ' + $.trim(bbcodeString) + ' '); } else { - _target.focus() - document.execCommand('insertText', false /*no UI*/, ' ' + $.trim(resp) + ' '); + targetTextarea.focus(); + document.execCommand('insertText', false /*no UI*/, '\n' + $.trim(bbcodeString) + '\n'); } }); this.on('complete', function(file) { @@ -35,7 +35,7 @@ var DzFactory = function () { items.forEach((item) => { if (item.kind === 'file') { // adds the file to your dropzone instance - dz.addFile(item.getAsFile()) + dz.addFile(item.getAsFile()); } }) }, @@ -47,15 +47,14 @@ var DzFactory = function () { items.forEach((item) => { if (item.kind === 'file') { // adds the file to your dropzone instance - dz.addFile(item.getAsFile()) + dz.addFile(item.getAsFile()); } }) }; - this.setupDropzone = function(element, target, maxImagesize) { - var dropzone = this.createDropzone(element, target, maxImagesize) - $(element).on('paste', function(event) { - + this.setupDropzone = function(dropSelector, textareaSelector, maxImagesize) { + var dropzone = this.createDropzone(dropSelector, textareaSelector, maxImagesize); + $(dropSelector).on('paste', function(event) { dzFactory.copyPaste(event, dropzone); }) }; diff --git a/view/templates/item/compose.tpl b/view/templates/item/compose.tpl index 07db40d9c6..499dfaffb2 100644 --- a/view/templates/item/compose.tpl +++ b/view/templates/item/compose.tpl @@ -96,5 +96,5 @@ diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 705f472c43..85c258c92f 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -293,48 +293,8 @@ function editpost(url) { // To make dropzone fileupload work on editing a comment, we need to // attach a new dropzone to modal - dropzoneJotEdit = new Dropzone( '#jot-text-wrap', { - paramName: 'userfile', // The name that will be used to transfer the file - maxFilesize: '{{$max_imagesize}}', // MB - url: '/media/photo/upload?response=url&album=', - accept: function(file, done) { - done(); - }, - init: function() { - this.on('success', function(file, serverResponse) { - var target = $('#profile-jot-text') - var resp = $(serverResponse).find('div#content').text() - if (target.setRangeText) { - //if setRangeText function is supported by current browser - target.setRangeText(' ' + $.trim(resp) + ' ') - } else { - target.focus() - document.execCommand('insertText', false /*no UI*/, ' ' + $.trim(resp) + ' '); - } - }); - this.on('complete', function(file) { - // Remove just uploaded file from dropzone, makes interface more clear. - // Image can be seen in posting-preview - // We need preview to get optical feedback about upload-progress. - // you see success, when the bb-code link for image is inserted - setTimeout(function(){ - dropzoneJotEdit.removeFile(file); - },5000); - }); - }, - }); - - // Enables Copy&Paste for this dropzone - $('#jot-text-wrap').on('paste', function(event){ - const items = (event.clipboardData || event.originalEvent.clipboardData).items; - items.forEach((item) => { - if (item.kind === 'file') { - // adds the file to your dropzone instance - dropzoneJotEdit.addFile(item.getAsFile()) - } - }) - }) - + console.log("modal.js max_imagesize",'{{$max_imagesize}}'); + dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text', '{{$max_imagesize}}'); modal.show(); $("#jot-popup").show(); diff --git a/view/theme/frio/templates/comment_item.tpl b/view/theme/frio/templates/comment_item.tpl index b61c1d6f87..3d9860a104 100644 --- a/view/theme/frio/templates/comment_item.tpl +++ b/view/theme/frio/templates/comment_item.tpl @@ -67,13 +67,13 @@ diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl index 1b77ded421..325c8d5b3b 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -180,5 +180,5 @@ can load different content into the jot modal (e.g. the item edit jot)