mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-18 03:10:39 +01:00
(refs #12) Created the helper of the attachment function.
This commit is contained in:
22
src/main/twirl/helper/attached.scala.html
Normal file
22
src/main/twirl/helper/attached.scala.html
Normal file
@@ -0,0 +1,22 @@
|
||||
@(owner: String, repository: String)(textarea: Html)(implicit context: app.Context)
|
||||
@import context._
|
||||
<div class="muted">
|
||||
@textarea
|
||||
Attach images by dragging & dropping, or selecting them.
|
||||
</div>
|
||||
@defining("(id=\")([\\w\\-]*)(\")".r.findFirstMatchIn(textarea.body).map(_.group(2))){ textareaId =>
|
||||
<script>
|
||||
$(function(){
|
||||
$('#@textareaId').closest('div').dropzone({
|
||||
url: '@path/upload/image/@owner/@repository',
|
||||
maxFilesize: 10,
|
||||
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] + '](@path/@owner/@repository/_attached/' + id + ')';
|
||||
$('#@textareaId').val($('#@textareaId').val() + images);
|
||||
file.previewElement.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
Reference in New Issue
Block a user