From a4c163f93027f38c7264e9bc1bef8e2593b3e1cf Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 15 Apr 2010 13:11:05 +0000 Subject: - removed redundant code + code formatting --- program/js/app.js | 115 ++++++++++++++++++++++++------------------------------ 1 file changed, 52 insertions(+), 63 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 9c5df7661..01601a6c0 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -2591,16 +2591,14 @@ function rcube_webmail() this.init_address_input_events($("[name='_cc']")); this.init_address_input_events($("[name='_bcc']")); - if (!html_mode) + if (!html_mode) { + // add signature according to selected identity + // if we have HTML editor, signature is added in callback + if (input_from.attr('type') == 'select-one' && $("input[name='_draft_saveid']").val() == '') { + this.change_identity(input_from[0]); + } this.set_caret_pos(input_message, this.env.top_posting ? 0 : $(input_message).val().length); - - // add signature according to selected identity - if (input_from.attr('type') == 'select-one' && $("input[name='_draft_saveid']").val() == '' - && !html_mode) { // if we have HTML editor, signature is added in callback - this.change_identity(input_from[0]); } - else if (!html_mode) - this.set_caret_pos(input_message, this.env.top_posting ? 0 : $(input_message).val().length); if (input_to.val() == '') input_to.focus(); @@ -2635,21 +2633,19 @@ function rcube_webmail() var input_message = $("[name='_message']"); // check sender (if have no identities) - if (input_from.attr('type') == 'text' && !rcube_check_email(input_from.val(), true)) - { + if (input_from.attr('type') == 'text' && !rcube_check_email(input_from.val(), true)) { alert(this.get_label('nosenderwarning')); input_from.focus(); return false; - } + } // check for empty recipient var recipients = input_to.val() ? input_to.val() : (input_cc.val() ? input_cc.val() : input_bcc.val()); - if (!rcube_check_email(recipients.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true)) - { + if (!rcube_check_email(recipients.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true)) { alert(this.get_label('norecipientwarning')); input_to.focus(); return false; - } + } // check if all files has been uploaded for (var key in this.env.attachments) { @@ -2711,31 +2707,31 @@ function rcube_webmail() this.stop_spellchecking(); $(this.env.spellcheck.spell_container).css('visibility', vis ? 'visible' : 'hidden'); - } + } }; this.set_spellcheck_state = function(s) - { + { this.spellcheck_ready = (s == 'ready' || s == 'no_error_found'); this.enable_command('spellcheck', this.spellcheck_ready); - }; + }; this.set_draft_id = function(id) - { + { $("input[name='_draft_saveid']").val(id); - }; + }; this.auto_save_start = function() - { + { if (this.env.draft_autosave) this.save_timer = self.setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); // Unlock interface now that saving is complete this.busy = false; - }; + }; this.compose_field_hash = function(save) - { + { // check input fields var value_to = $("[name='_to']").val(); var value_cc = $("[name='_cc']").val(); @@ -2766,7 +2762,7 @@ function rcube_webmail() this.cmp_hash = str; return str; - }; + }; this.change_identity = function(obj, show_sig) { @@ -2898,22 +2894,20 @@ function rcube_webmail() }; this.show_attachment_form = function(a) - { + { if (!this.gui_objects.uploadbox) return false; var elm, list; - if (elm = this.gui_objects.uploadbox) - { - if (a && (list = this.gui_objects.attachmentlist)) - { + if (elm = this.gui_objects.uploadbox) { + if (a && (list = this.gui_objects.attachmentlist)) { var pos = $(list).offset(); elm.style.top = (pos.top + list.offsetHeight + 10) + 'px'; elm.style.left = pos.left + 'px'; - } + } $(elm).toggle(); - } + } // clear upload form try { @@ -2923,38 +2917,34 @@ function rcube_webmail() catch(e){} // ignore errors return true; - }; + }; // upload attachment file this.upload_file = function(form) - { + { if (!form) return false; // get file input fields var send = false; for (var n=0; n