diff options
author | NavaL <mnandri@thoughtworks.com> | 2016-01-11 19:38:24 +0100 |
---|---|---|
committer | NavaL <mnandri@thoughtworks.com> | 2016-01-11 19:38:24 +0100 |
commit | 100bb93759c9bfbc24cd812544a68b729da2706b (patch) | |
tree | 65d5a414b5e78575ff1607c531bae1082b7b4268 | |
parent | c28bdb520cc4ea1249d5a2953d9f78d40dd10806 (diff) |
minor refactoring
Issue #573
-rw-r--r-- | web-ui/app/js/mail_view/ui/attachment_list.js | 16 |
1 files changed, 6 insertions, 10 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 632242ca..72782c6b 100644 --- a/web-ui/app/js/mail_view/ui/attachment_list.js +++ b/web-ui/app/js/mail_view/ui/attachment_list.js @@ -48,19 +48,15 @@ define( this.select('attachmentListItem').html(currentHtml + '<li>' + item + '</li>'); }; - function humanReadable(bytes) { - var e = Math.floor(Math.log(bytes) / Math.log(1024)); - return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'b'; - } - this.buildAttachmentListItem = function (attachment) { return '<a href="' + this.attr.attachmentBaseUrl + '/' + attachment.ident + '?filename=' + attachment.name + '&encoding=' + attachment.encoding + '">' + attachment.name + ' (' + viewHelper.formatSize(attachment.size) + ')' + '</a>'; }; - function addJqueryFileUploadConfig(self) { - self.select('inputFileUpload').fileupload({ + this.addJqueryFileUploadConfig = function() { + var self = this; + this.select('inputFileUpload').fileupload({ url: self.attr.attachmentBaseUrl, dataType: 'json', done: function (e, response) { @@ -76,17 +72,17 @@ define( }).bind('fileuploadadd', function (e) { $('.attachmentsAreaWrap').show(); }); - } + }; this.startUpload = function () { - addJqueryFileUploadConfig(this); + this.addJqueryFileUploadConfig(); this.select('inputFileUpload').click(); }; this.after('initialize', function () { + this.addJqueryFileUploadConfig(); this.on(document, events.mail.uploadedAttachment, this.showAttachment); this.on(document, events.mail.startUploadAttachment, this.startUpload); - //this.on(document, events.mail.sent, this.resetAll); this.on(document, events.mail.appendAttachment, this.addAttachment); }); } |