(refs #12) Created the helper of the attachment function.

This commit is contained in:
shimamoto
2014-04-29 04:19:40 +09:00
parent 27fa9df2ee
commit bdd0af21a9

View 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 &amp; 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>
}