From 934d1e6b7fa72eef03bfc2b00a1bbbe8af4079f7 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 20 Apr 2012 18:03:36 +0200 Subject: [PATCH] wip: UI refactoring Fixes. see #204 --- extensions/webmail/imaputils.py | 16 +++++++++++----- extensions/webmail/static/js/webmail.js | 3 +-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/webmail/imaputils.py b/extensions/webmail/imaputils.py index 8372b3b46..8c1f758ed 100644 --- a/extensions/webmail/imaputils.py +++ b/extensions/webmail/imaputils.py @@ -82,10 +82,11 @@ class BodyStructure(object): params = dict(pnum=pnum, params=definition[2], cid=definition[3], description=definition[4], encoding=definition[5], size=definition[6]) + mtype = definition[0].lower() subtype = definition[1].lower() - mtype = "%s/%s" % (definition[0].lower(), subtype) - if mtype in ("text/plain", "text/html"): - if not self.contents.has_key(mtype): + ftype = "%s/%s" % (definition[0].lower(), subtype) + if ftype in ("text/plain", "text/html"): + if not self.contents.has_key(ftype): self.contents[subtype] = params return elif multisubtype in ["related"]: @@ -93,8 +94,13 @@ class BodyStructure(object): return if len(definition) > 7: - params.update(md5=definition[7], disposition=definition[8], - lang=definition[9], location=definition[10]) + extensions = ["md5", "disposition", "language", "location"] + if mtype == "text": + extensions = ["textlines"] + extensions + elif ftype == "message/rfc822": + extensions = ["envelopestruct", "bodystruct", "textlines"] + extensions + for idx, value in enumerate(definition[7:]): + params[extensions[idx]] = value self.attachments += [params] def load_from_definition(self, definition, multisubtype=None): diff --git a/extensions/webmail/static/js/webmail.js b/extensions/webmail/static/js/webmail.js index 48ac95f9f..8306b0bfb 100644 --- a/extensions/webmail/static/js/webmail.js +++ b/extensions/webmail/static/js/webmail.js @@ -111,8 +111,7 @@ Webmail.prototype = { $.proxy(this.sendmail, this)); $(document).on("click", "#attachments", $.proxy(function(e) { - var $div = $(e.target).parent(); - modalbox(e, undefined, $div.attr("name"), + modalbox(e, undefined, $("#attachments").attr("name"), $.proxy(this.attachments_init, this)); }, this)); },