Show More
@@ -680,69 +680,69 b' var CommentsController = function() {' | |||||
680 | {'repo_name': templateContext.repo_name, |
|
680 | {'repo_name': templateContext.repo_name, | |
681 | 'commit_id': templateContext.commit_data.commit_id}) |
|
681 | 'commit_id': templateContext.commit_data.commit_id}) | |
682 |
|
682 | |||
683 |
var previewTmpl = $(formElement).find('.comment-attachment-uploader-template').get(0) |
|
683 | var previewTmpl = $(formElement).find('.comment-attachment-uploader-template').get(0); | |
684 | var selectLink = $(formElement).find('.pick-attachment').get(0); |
|
684 | if (previewTmpl !== undefined){ | |
685 |
$(formElement).find('. |
|
685 | var selectLink = $(formElement).find('.pick-attachment').get(0); | |
686 | url: storeUrl, |
|
686 | $(formElement).find('.comment-attachment-uploader').dropzone({ | |
687 | headers: {"X-CSRF-Token": CSRF_TOKEN}, |
|
687 | url: storeUrl, | |
688 | paramName: function () { |
|
688 | headers: {"X-CSRF-Token": CSRF_TOKEN}, | |
689 | return "attachment" |
|
689 | paramName: function () { | |
690 | }, // The name that will be used to transfer the file |
|
690 | return "attachment" | |
691 | clickable: selectLink, |
|
691 | }, // The name that will be used to transfer the file | |
692 | parallelUploads: 1, |
|
692 | clickable: selectLink, | |
693 |
|
|
693 | parallelUploads: 1, | |
694 | maxFilesize: templateContext.attachment_store.max_file_size_mb, |
|
694 | maxFiles: 10, | |
695 | uploadMultiple: false, |
|
695 | maxFilesize: templateContext.attachment_store.max_file_size_mb, | |
696 | autoProcessQueue: true, // if false queue will not be processed automatically. |
|
696 | uploadMultiple: false, | |
697 | createImageThumbnails: false, |
|
697 | autoProcessQueue: true, // if false queue will not be processed automatically. | |
698 | previewTemplate: previewTmpl, |
|
698 | createImageThumbnails: false, | |
|
699 | previewTemplate: previewTmpl.innerHTML, | |||
699 |
|
700 | |||
700 | accept: function (file, done) { |
|
701 | accept: function (file, done) { | |
701 | done(); |
|
702 | done(); | |
702 | }, |
|
703 | }, | |
703 | init: function () { |
|
704 | init: function () { | |
704 |
|
705 | |||
705 | this.on("sending", function (file, xhr, formData) { |
|
706 | this.on("sending", function (file, xhr, formData) { | |
706 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-text').hide(); |
|
707 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-text').hide(); | |
707 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').show(); |
|
708 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').show(); | |
708 | }); |
|
709 | }); | |
709 |
|
710 | |||
710 | this.on("success", function (file, response) { |
|
711 | this.on("success", function (file, response) { | |
711 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-text').show(); |
|
712 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-text').show(); | |
712 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide(); |
|
713 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide(); | |
713 |
|
714 | |||
714 | var isRendered = false; |
|
715 | var isRendered = false; | |
715 | var ext = file.name.split('.').pop(); |
|
716 | var ext = file.name.split('.').pop(); | |
716 | var imageExts = templateContext.attachment_store.image_ext; |
|
717 | var imageExts = templateContext.attachment_store.image_ext; | |
717 | if (imageExts.indexOf(ext) !== -1){ |
|
718 | if (imageExts.indexOf(ext) !== -1){ | |
718 | isRendered = true; |
|
719 | isRendered = true; | |
719 | } |
|
720 | } | |
720 |
|
721 | |||
721 | insertAttachmentText(cm, file.name, response.repo_fqn_access_path, isRendered) |
|
722 | insertAttachmentText(cm, file.name, response.repo_fqn_access_path, isRendered) | |
722 | }); |
|
723 | }); | |
723 |
|
724 | |||
724 | this.on("error", function (file, errorMessage, xhr) { |
|
725 | this.on("error", function (file, errorMessage, xhr) { | |
725 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide(); |
|
726 | $(formElement).find('.comment-attachment-uploader').find('.dropzone-upload').hide(); | |
726 |
|
727 | |||
727 | var error = null; |
|
728 | var error = null; | |
728 |
|
729 | |||
729 | if (xhr !== undefined){ |
|
730 | if (xhr !== undefined){ | |
730 | var httpStatus = xhr.status + " " + xhr.statusText; |
|
731 | var httpStatus = xhr.status + " " + xhr.statusText; | |
731 | if (xhr.status >= 500) { |
|
732 | if (xhr.status >= 500) { | |
732 | error = httpStatus; |
|
733 | error = httpStatus; | |
|
734 | } | |||
733 | } |
|
735 | } | |
734 | } |
|
|||
735 |
|
736 | |||
736 | if (error === null) { |
|
737 | if (error === null) { | |
737 | error = errorMessage.error || errorMessage || httpStatus; |
|
738 | error = errorMessage.error || errorMessage || httpStatus; | |
738 | } |
|
739 | } | |
739 | $(file.previewElement).find('.dz-error-message').html('ERROR: {0}'.format(error)); |
|
740 | $(file.previewElement).find('.dz-error-message').html('ERROR: {0}'.format(error)); | |
740 |
|
741 | |||
741 | }); |
|
742 | }); | |
742 | } |
|
743 | } | |
743 | }); |
|
744 | }); | |
744 |
|
745 | } | ||
745 |
|
||||
746 | return commentForm; |
|
746 | return commentForm; | |
747 | }; |
|
747 | }; | |
748 |
|
748 |
General Comments 0
You need to be logged in to leave comments.
Login now