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 | |
parent | 43e5de7f830a098582b519706f9c5da6eecd2c3e (diff) | |
download | gitea-bfe5b86004791823b198be76084aa128d262b290.tar.gz gitea-bfe5b86004791823b198be76084aa128d262b290.zip |
Add file upload for attachments
Diffstat (limited to 'public')
-rwxr-xr-x | public/css/gogs.css | 17 | ||||
-rw-r--r-- | public/js/app.js | 27 |
2 files changed, 38 insertions, 6 deletions
diff --git a/public/css/gogs.css b/public/css/gogs.css index e78d7f940c..cc48f211f4 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -1819,4 +1819,21 @@ body { .attachment-preview-img { border: 1px solid #d8d8d8; +} + +#attachments-button { + float: left; +} + +#attached { + height: 18px; + margin: 10px 10px 15px 10px; +} + +#attached-list .label { + margin-right: 10px; +} + +#issue-create-form #attached { + margin-bottom: 0; }
\ No newline at end of file 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; }); }()); |