mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-14 01:15:50 +01:00
28 lines
1.3 KiB
HTML
28 lines
1.3 KiB
HTML
@(owner: String, repository: String)(textarea: Html)(implicit context: app.Context)
|
|
@import context._
|
|
<div class="muted attachable">
|
|
@textarea
|
|
<div>Attach images by dragging & dropping, or selecting them.</div>
|
|
</div>
|
|
@defining("(id=\")([\\w\\-]*)(\")".r.findFirstMatchIn(textarea.body).map(_.group(2))){ textareaId =>
|
|
<script>
|
|
$(function(){
|
|
$('#@textareaId').next('div').dropzone({
|
|
url: '@path/upload/image/@owner/@repository',
|
|
maxFilesize: 10,
|
|
acceptedFiles: 'image/*',
|
|
dictInvalidFileType: 'Unfortunately, we don\'t support that file type. Try again with a PNG, GIF, or JPG.',
|
|
previewTemplate: "<div class=\"dz-preview\">\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress>Uploading your images...</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
|
|
success: function(file, id) {
|
|
var images = '\n![' + file.name.split('.')[0] + '](@baseUrl/@owner/@repository/_attached/' + id + ')';
|
|
$('#@textareaId').val($('#@textareaId').val() + images);
|
|
$(file.previewElement).prevAll('div.dz-preview').addBack().remove();
|
|
}
|
|
});
|
|
|
|
// Adjust attachment area width
|
|
$('div.attachable div').css('width', ($('div.attachable textarea').width() + 8) + 'px');
|
|
});
|
|
</script>
|
|
}
|