+
+<script>
+ Dropzone.autoDiscover = false;
+ console.log('comment_item.tpl', {{$max_imagesize}} / 100000);
+ var maxis = {{$max_imagesize}} / 100000;
+ var dropzone{{$id}} = new Dropzone( '#comment-edit-wrapper-{{$id}}', {
+ paramName: "userfile", // The name that will be used to transfer the file
+ maxFilesize: maxis, // MB
+ previewsContainer: '#dz-preview-{{$id}}',
+ preventDuplicates: true,
+ clickable: true,
+ thumbnailWidth: 100,
+ thumbnailHeight: 100,
+ url: "/media/photo/upload?response=url&album=",
+ accept: function(file, done) {
+ done();
+ },
+ init: function() {
+ this.on("success", function(file, serverResponse) {
+ var target = $('#comment-edit-text-{{$id}}')
+ 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) + " ");
+ }
+ });
+ },
+ });
+
+ $('#comment-edit-wrapper-{{$id}}').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
+ dropzone{{$id}}.addFile(item.getAsFile())
+ }
+ })
+ });
+</script>