From 099d2b9fd4af3c7e7f1568af3c01c0b2e52cd9c3 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 26 Mar 2013 14:38:07 -0400
Subject: [PATCH] Remove sig_above configuration option, use reply_mode only (#1489001)

---
 program/js/app.js |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 87cdf3b..a530864 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -950,7 +950,7 @@
         clearTimeout(this.save_timer);
 
         // compose form did not change (and draft wasn't saved already)
-        if (this.draft_saved && this.cmp_hash == this.compose_field_hash()) {
+        if (this.env.draft_id && this.cmp_hash == this.compose_field_hash()) {
           this.auto_save_start();
           break;
         }
@@ -3345,7 +3345,15 @@
 
   this.set_draft_id = function(id)
   {
-    this.draft_saved = id;
+    var rc;
+
+    if (!this.env.draft_id && id && (rc = this.opener())) {
+      // refresh the drafts folder in opener window
+      if (rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == this.env.drafts_mailbox)
+        rc.command('checkmail');
+    }
+
+    this.env.draft_id = id;
     $("input[name='_draft_saveid']").val(id);
   };
 
@@ -3411,7 +3419,7 @@
         sig = this.env.signatures[sig].text;
         sig = sig.replace(/\r\n/g, '\n');
 
-        p = this.env.sig_above ? message.indexOf(sig) : message.lastIndexOf(sig);
+        p = this.env.top_posting ? message.indexOf(sig) : message.lastIndexOf(sig);
         if (p >= 0)
           message = message.substring(0, p) + message.substring(p+sig.length, message.length);
       }
@@ -3420,7 +3428,7 @@
         sig = this.env.signatures[id].text;
         sig = sig.replace(/\r\n/g, '\n');
 
-        if (this.env.sig_above) {
+        if (this.env.top_posting) {
           if (p >= 0) { // in place of removed signature
             message = message.substring(0, p) + sig + message.substring(p, message.length);
             cursor_pos = p - 1;
@@ -3464,7 +3472,7 @@
         sigElem = doc.createElement('div');
         sigElem.setAttribute('id', '_rc_sig');
 
-        if (this.env.sig_above) {
+        if (this.env.top_posting) {
           // if no existing sig and top posting then insert at caret pos
           editor.getWin().focus(); // correct focus in IE & Chrome
 
@@ -3721,15 +3729,19 @@
     this.env.search_id = null;
   };
 
-  this.sent_successfully = function(type, msg)
+  this.sent_successfully = function(type, msg, target)
   {
     this.display_message(msg, type);
 
     if (this.env.extwin) {
-      var opener_rc = this.opener();
+      var rc = this.opener();
       this.lock_form(this.gui_objects.messageform);
-      if (opener_rc)
-        opener_rc.display_message(msg, type);
+      if (rc) {
+        rc.display_message(msg, type);
+        // refresh the folder where sent message was saved
+        if (target && rc.env.task == 'mail' && rc.env.action == '' && rc.env.mailbox == target)
+          rc.command('checkmail');
+      }
       setTimeout(function(){ window.close() }, 1000);
     }
     else {

--
Gitblit v1.9.1