From: Michael M Slusarz Date: Thu, 3 Jun 2010 17:54:10 +0000 (-0600) Subject: Bug #9073: More IE fixes for clearing a file input field X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6291908e487ca530962ed9df16171db3504e1345;p=horde.git Bug #9073: More IE fixes for clearing a file input field While we are here, do a little bit less dynamic DOM node creation. Also, fix issue where, if attachment was removed when at attachment limit, the upload box would not appear. --- diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index d973cd478..393109193 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -214,8 +214,7 @@ var DimpCompose = { uniqueSubmitCallback: function(r) { - var elt, - d = r.response; + var d = r.response; if (!d) { return; @@ -285,15 +284,9 @@ var DimpCompose = { if (d.success) { this.addAttach(d.atc.num, d.atc.name, d.atc.type, d.atc.size); } - if (DIMP.conf_compose.attach_limit != -1 && - $('attach_list').childElements().size() > DIMP.conf_compose.attach_limit) { - $('upload').enable(); - elt = new Element('DIV', [ DIMP.text_compose.atc_limit ]); - } else { - elt = new Element('INPUT', { type: 'file', name: 'file_1' }); - } - $('upload_wait').next().show(); - $('upload_wait').replace(elt.writeAttribute('id', 'upload')); + + $('upload_wait').hide(); + this.initAttachList(); this.resizeMsgArea(); break; } @@ -626,6 +619,7 @@ var DimpCompose = { n.fade({ afterFinish: function() { n.remove(); + this.initAttachList(); this.resizeMsgArea(); }.bind(this), duration: 0.4 @@ -637,6 +631,31 @@ var DimpCompose = { DimpCore.doAction('deleteAttach', { atc_indices: ids, imp_compose: $F('composeCache') }); }, + initAttachList: function() + { + var u = $('upload'), + u_parent = u.up(); + + if (DIMP.conf_compose.attach_limit != -1 && + $('attach_list').childElements().size() >= DIMP.conf_compose.attach_limit) { + $('upload_limit').show(); + } else if (!u_parent.visible()) { + $('upload_limit').hide(); + + if (Prototype.Browser.IE) { + // Trick to allow us to clear the file input on IE without + // creating a new node. Need to re-add the event handler + // however, as it won't survive this assignment. + u.stopObserving(); + u_parent.innerHTML = u_parent.innerHTML; + u = $('upload'); + u.observe('change', this.changeHandler.bindAsEventListener(this)); + } + + u.clear().up().show().next().show(); + } + }, + resizeMsgArea: function() { var mah, rows, @@ -681,8 +700,8 @@ var DimpCompose = { { var u = $('upload'); this.uniqueSubmit('addAttachment'); - u.next().hide(); - u.replace(new Element('SPAN', { id: 'upload_wait' }).insert(DIMP.text_compose.uploading + ' (' + $F(u) + ')')); + u.up().hide().next().hide(); + $('upload_wait').update(DIMP.text_compose.uploading + ' (' + $F(u) + ')').show(); }, attachmentComplete: function() diff --git a/imp/templates/dimp/chunks/compose.php b/imp/templates/dimp/chunks/compose.php index d56be8db0..ec33c30cb 100644 --- a/imp/templates/dimp/chunks/compose.php +++ b/imp/templates/dimp/chunks/compose.php @@ -123,7 +123,11 @@ $compose_disable = !IMP::canCompose(); : - + + + + +
diff --git a/imp/templates/dimp/javascript_defs_dimp.php b/imp/templates/dimp/javascript_defs_dimp.php index d0f0fb0a3..fffbdb077 100644 --- a/imp/templates/dimp/javascript_defs_dimp.php +++ b/imp/templates/dimp/javascript_defs_dimp.php @@ -166,7 +166,6 @@ if (in_array(basename($_SERVER['PHP_SELF']), array('compose-dimp.php', 'message- /* Gettext strings used in compose page. */ $code['text_compose'] = array( - 'atc_limit' => _("The attachment limit has been reached."), 'cancel' => _("Cancelling this message will permanently discard its contents and will delete auto-saved drafts.\nAre you sure you want to do this?"), 'nosubject' => _("The message does not have a Subject entered.") . "\n" . _("Send message without a Subject?"), 'remove' => _("Remove"),