summaryrefslogtreecommitdiff
path: root/web-ui/app
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-01-29 14:28:51 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-01-29 14:28:51 -0300
commite92c87f7500d0543cb95ab007046b9c91ba1a763 (patch)
tree2f8582a2c037eebcac677e9096196cad3c9c2edf /web-ui/app
parentd984d803936399caa393622171453566ff3194e0 (diff)
testing filesize validation, on attachments
Issue #550
Diffstat (limited to 'web-ui/app')
-rw-r--r--web-ui/app/js/mail_view/ui/attachment_list.js77
1 files changed, 40 insertions, 37 deletions
diff --git a/web-ui/app/js/mail_view/ui/attachment_list.js b/web-ui/app/js/mail_view/ui/attachment_list.js
index eb8ae12a..9a5fd3a9 100644
--- a/web-ui/app/js/mail_view/ui/attachment_list.js
+++ b/web-ui/app/js/mail_view/ui/attachment_list.js
@@ -61,46 +61,49 @@ define(
return templates.compose.attachmentItem(attachmentData);
};
+ this.checkAttachmentSize = function(e, data) {
+ var self = this;
+ var uploadError = self.select('uploadError');
+ if (uploadError) {
+ uploadError.remove();
+ }
+
+ var uploadErrors = [];
+
+ var showUploadFailed = function () {
+ var html = $(templates.compose.uploadAttachmentFailed());
+ html.insertAfter(self.select('attachmentListItem'));
+
+ self.on(self.select('closeIcon'), 'click', dismissUploadFailed);
+ self.on(self.select('dismissButton'), 'click', dismissUploadFailed);
+ self.on(self.select('uploadFileButton'), 'click', uploadAnotherFile);
+ };
+
+ var dismissUploadFailed = function (event) {
+ event.preventDefault();
+ self.select('uploadError').remove();
+ };
+
+ var uploadAnotherFile = function (event) {
+ event.preventDefault();
+ self.startUpload();
+ };
+
+ var ONE_MEGABYTE = 1000000;
+ if (data.originalFiles[0].size > ONE_MEGABYTE) {
+ uploadErrors.push('Filesize is too big');
+ }
+ if (uploadErrors.length > 0) {
+ showUploadFailed();
+ } else {
+ data.submit();
+ }
+ };
+
this.addJqueryFileUploadConfig = function() {
var self = this;
this.select('inputFileUpload').fileupload({
- add: function(e, data) {
- var uploadError = self.select('uploadError');
- if (uploadError) {
- uploadError.remove();
- }
-
- var uploadErrors = [];
-
- this.showUploadFailed = function () {
- var html = $(templates.compose.uploadAttachmentFailed());
- html.insertAfter(self.$node.find(self.attr.attachmentListItem));
-
- self.on(self.select('closeIcon'), 'click', this.dismissUploadFailed);
- self.on(self.select('dismissButton'), 'click', this.dismissUploadFailed);
- self.on(self.select('uploadFileButton'), 'click', this.uploadAnotherFile);
- };
-
- this.dismissUploadFailed = function (event) {
- event.preventDefault();
- self.select('uploadError').remove();
- };
-
- this.uploadAnotherFile = function (event) {
- event.preventDefault();
- self.startUpload();
- };
-
- var ONE_MEGABYTE = 1000000;
- if (data.originalFiles[0].size > ONE_MEGABYTE) {
- uploadErrors.push('Filesize is too big');
- }
- if (uploadErrors.length > 0) {
- this.showUploadFailed();
- } else {
- data.submit();
- }
- },
+ add: function(e, data) { self.checkAttachmentSize(e, data); },
url: self.attr.attachmentBaseUrl,
dataType: 'json',
done: function (e, response) {