From 17d0890a78ad087727910a66f60a804d40f1a20d Mon Sep 17 00:00:00 2001 From: thomasb Date: Tue, 6 Oct 2009 06:55:08 +0000 Subject: Hold attachment info in a js list in order to simplify things + codestyle git-svn-id: https://svn.roundcube.net/trunk@3021 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/program/js/app.js | 78 +++++++++++++++++-------------- roundcubemail/program/js/editor_images.js | 20 ++------ 2 files changed, 47 insertions(+), 51 deletions(-) (limited to 'roundcubemail/program/js') diff --git a/roundcubemail/program/js/app.js b/roundcubemail/program/js/app.js index d4161714e..d72f9eebb 100644 --- a/roundcubemail/program/js/app.js +++ b/roundcubemail/program/js/app.js @@ -2172,14 +2172,11 @@ function rcube_webmail() } // check if all files has been uploaded - if (this.gui_objects.attachmentlist) { - var list = this.gui_objects.attachmentlist.getElementsByTagName("li"); - for (i=0;i'+content; if (this.env.cancelicon) content = ''+content; - this.add2attachment_list(ts, content); + this.add2attachment_list(ts, { name:'', html:content, complete:false }); } // set reference to the form object @@ -2506,26 +2503,35 @@ function rcube_webmail() // add file name to attachment list // called from upload page - this.add2attachment_list = function(name, content, upload_id) - { + this.add2attachment_list = function(name, att, upload_id) + { if (!this.gui_objects.attachmentlist) return false; + var li = $('
  • ').attr('id', name).html(att.html); var indicator; + // replace indicator's li if (upload_id && (indicator = document.getElementById(upload_id))) { - var li = document.createElement('li'); - $(li).attr('id', name).html(content); - indicator.parentNode.replaceChild(li, indicator); - } else { // add new li - $('
  • ').attr('id', name).html(content).appendTo(this.gui_objects.attachmentlist); - } + li.replaceAll(indicator); + } + else { // add new li + li.appendTo(this.gui_objects.attachmentlist); + } + + if (upload_id && this.env.attachments[upload_id]) + delete this.env.attachments[upload_id]; + + this.env.attachments[name] = att; return true; - }; + }; this.remove_from_attachment_list = function(name) - { + { + if (this.env.attachments[name]) + delete this.env.attachments[name]; + if (!this.gui_objects.attachmentlist) return false; @@ -2533,11 +2539,11 @@ function rcube_webmail() for (i=0;i