From 100bb93759c9bfbc24cd812544a68b729da2706b Mon Sep 17 00:00:00 2001 From: NavaL Date: Mon, 11 Jan 2016 19:38:24 +0100 Subject: minor refactoring Issue #573 --- web-ui/app/js/mail_view/ui/attachment_list.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'web-ui/app/js') 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 + '
  • ' + item + '
  • '); }; - 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 '' + attachment.name + ' (' + viewHelper.formatSize(attachment.size) + ')' + ''; }; - 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); }); } -- cgit v1.2.3