diff options
author | Justin Nuß <justin.nuss@hmmh.de> | 2014-07-24 15:19:59 +0200 |
---|---|---|
committer | Justin Nuß <justin.nuss@hmmh.de> | 2014-07-24 15:19:59 +0200 |
commit | bfe5b86004791823b198be76084aa128d262b290 (patch) | |
tree | 95e7e6f9633793f20d43309412fe9c2e66b1527f /public/js | |
parent | 43e5de7f830a098582b519706f9c5da6eecd2c3e (diff) | |
download | gitea-bfe5b86004791823b198be76084aa128d262b290.tar.gz gitea-bfe5b86004791823b198be76084aa128d262b290.zip |
Add file upload for attachments
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/app.js | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/public/js/app.js b/public/js/app.js index 3d4ed62362..7ffcbd4a3e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -536,7 +536,7 @@ function initIssue() { var over = function() { var $this = $(this); - if ($this.text().match(/\.(png|jpg|jpeg|gif)$/) == false) { + if ($this.text().match(/\.(png|jpg|jpeg|gif)$/i) == false) { return; } @@ -576,15 +576,30 @@ function initIssue() { // Upload. (function() { - var $attached = $("#attached"); - var $attachments = $("input[name=attachments]"); + var $attachedList = $("#attached-list"); var $addButton = $("#attachments-button"); - var commentId = $addButton.attr("data-comment-id"); // "0" == for issue, "" == for comment - var accepted = $addButton.attr("data-accept"); + var fileInput = $("#attachments-input")[0]; + + fileInput.addEventListener("change", function(event) { + $attachedList.empty(); + $attachedList.append("<b>Attachments:</b> "); + + for (var index = 0; index < fileInput.files.length; index++) { + var file = fileInput.files[index]; + + var $span = $("<span></span>"); + + $span.addClass("label"); + $span.addClass("label-default"); + + $span.append(file.name.toLowerCase()); + $attachedList.append($span); + } + }); $addButton.on("click", function() { - // TODO: (nuss-justin): open dialog, upload file, add id to list, add file to $attached list + fileInput.click(); return false; }); }()); |