diff --git a/src/main/twirl/gitbucket/core/helper/attached.scala.html b/src/main/twirl/gitbucket/core/helper/attached.scala.html
index 9bea4f1..02624f2 100644
--- a/src/main/twirl/gitbucket/core/helper/attached.scala.html
+++ b/src/main/twirl/gitbucket/core/helper/attached.scala.html
@@ -46,18 +46,11 @@
@if(generateScript){
try {
+ $([$('#@textareaId')[0]]).dropzone({
+ @dropzone(false, textareaId)
+ });
$([$('#@textareaId').closest('div')[0], $('#@textareaId').next('div')[0]]).dropzone({
- url: '@context.path/upload/file/@repository.owner/@repository.name',
- maxFilesize: 10,
- acceptedFiles: @Html(FileUtil.mimeTypeWhiteList.mkString("'", ",", "'")),
- dictInvalidFileType: 'Unfortunately, we don\'t support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, or PDF.',
- previewTemplate: "
\n
Uploading your files...
\n
\n
",
- success: function(file, id) {
- var attachFile = (file.type.match(/image\/.*/) ? '\n![' + file.name.split('.')[0] : '\n[' + file.name) +
- '](@context.baseUrl/@repository.owner/@repository.name/_attached/' + id + ')';
- $('#@textareaId').val($('#@textareaId').val() + attachFile);
- $(file.previewElement).prevAll('div.dz-preview').addBack().remove();
- }
+ @dropzone(true, textareaId)
});
} catch(e) {
if (e.message !== "Dropzone already attached.") {
@@ -68,3 +61,17 @@
});
}
+@dropzone(clickable: Boolean, textareaId: Option[String]) = {
+ url: '@context.path/upload/file/@repository.owner/@repository.name',
+ maxFilesize: 10,
+ clickable: false,
+ acceptedFiles: @Html(FileUtil.mimeTypeWhiteList.mkString("'", ",", "'")),
+ dictInvalidFileType: 'Unfortunately, we don\'t support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, or PDF.',
+ previewTemplate: "\n
Uploading your files...
\n
\n
",
+ success: function(file, id) {
+ var attachFile = (file.type.match(/image\/.*/) ? '\n![' + file.name.split('.')[0] : '\n[' + file.name) +
+ '](@context.baseUrl/@repository.owner/@repository.name/_attached/' + id + ')';
+ $('#@textareaId').val($('#@textareaId').val() + attachFile);
+ $(file.previewElement).prevAll('div.dz-preview').addBack().remove();
+ }
+}