Fix for bug 12080, 16730: I cannot modify the window from a JS listenner function, therefore I use a timer function to do the job. Also, I've implemented support for pref "mailnews.reply_on_top". And add a space to the standard signature separator, now it's "-- ". R=jefft

git-svn-id: svn://10.0.0.236/trunk@53370 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ducarroz%netscape.com 1999-11-12 23:44:28 +00:00
parent eecd5ec27f
commit 846f71ee05
2 changed files with 64 additions and 23 deletions

View File

@ -26,6 +26,7 @@ var msgCompose = null;
var MAX_RECIPIENTS = 0;
var currentAttachment = null;
var tabIntoBodyPhase = 0;
var documentLoaded = false;
var other_header = "";
var update_compose_title_as_you_type = true;
@ -50,20 +51,7 @@ if (prefs) {
var editorDocumentListener = {
NotifyDocumentCreated: function() {
CompFields2Recipients(msgCompose.compFields);
if (document.getElementById("msgRecipient#1").value == "")
{
dump("set focus on the recipient\n");
document.getElementById("msgRecipient#1").focus();
}
else
{
dump("set focus on the body\n");
contentWindow.focus();
}
SetComposeWindowTitle(13);
documentLoaded = true;
}
};
@ -118,6 +106,18 @@ function GetArgs()
return args;
}
function WaitFinishLoadingDocument()
{
if (documentLoaded)
{
CompFields2Recipients(msgCompose.compFields);
SetComposeWindowTitle(13);
AdjustFocus();
}
else
setTimeout("WaitFinishLoadingDocument();", 200);
}
function ComposeStartup()
{
dump("Compose: ComposeStartup\n");
@ -236,8 +236,7 @@ function ComposeStartup()
// Now that we have an Editor AppCore, we can finish to initialize the Compose AppCore
msgCompose.editor = window.editorShell;
document.getElementById("msgRecipient#1").focus();
WaitFinishLoadingDocument();
}
}
}
@ -572,6 +571,20 @@ function getIdentityForKey(key)
return accountManager.getIdentity(key);
}
function AdjustFocus()
{
if (document.getElementById("msgRecipient#1").value == "")
{
dump("set focus on the recipient\n");
document.getElementById("msgRecipient#1").focus();
}
else
{
dump("set focus on the body\n");
contentWindow.focus();
}
}
function SetComposeWindowTitle(event)
{
/* dump("event = " + event + "\n"); */

View File

@ -44,7 +44,8 @@
#include "nsMsgPrompts.h"
#include "nsMimeTypes.h"
#include "nsICharsetConverterManager.h"
#include "nsTextFormater.h"
#include "nsTextFormater.h"
#include "nsIEditor.h"
// XXX temporary so we can use the current identity hack -alecf
#include "nsIMsgMailSession.h"
@ -58,6 +59,16 @@ static NS_DEFINE_CID(kMsgQuoteCID, NS_MSGQUOTE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID);
static PRInt32 GetReplyOnTop()
{
PRInt32 reply_on_top = 1;
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
if (NS_SUCCEEDED(rv))
prefs->GetIntPref("mailnews.reply_on_top", &reply_on_top);
return reply_on_top;
}
nsMsgCompose::nsMsgCompose()
{
NS_INIT_REFCNT();
@ -110,17 +121,33 @@ NS_IMPL_ISUPPORTS(nsMsgCompose, nsCOMTypeInfo<nsMsgCompose>::GetIID());
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
nsresult
ConvertAndLoadComposeWindow(nsIEditorShell *aEditor, nsString aBuf, PRBool aQuoted, PRBool aHTMLEditor)
ConvertAndLoadComposeWindow(nsIEditorShell *aEditorShell, nsString aBuf, PRBool aQuoted, PRBool aHTMLEditor)
{
// Now, insert it into the editor...
if ( (aQuoted) )
aEditor->InsertAsQuotation(aBuf.GetUnicode());
aEditorShell->InsertAsQuotation(aBuf.GetUnicode());
else
{
if (aHTMLEditor)
aEditor->InsertSource(aBuf.GetUnicode());
aEditorShell->InsertSource(aBuf.GetUnicode());
else
aEditor->InsertText(aBuf.GetUnicode());
aEditorShell->InsertText(aBuf.GetUnicode());
}
nsCOMPtr<nsIEditor> editor;
aEditorShell->GetEditor(getter_AddRefs(editor));
if (editor)
{
switch (GetReplyOnTop())
{
/* TODO: in case of the user want the insertion point at the end of the body,
we need to be smarter than just doing editor->EndOfDocument() because
if we have a signature, we need to put the cursor just before it.
*/
case 0 : editor->EndOfDocument(); break;
case 2 : editor->SelectAll(); break;
default : editor->BeginningOfDocument(); break;
}
}
return NS_OK;
@ -752,7 +779,8 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const PRUnichar * origi
}
if (NS_SUCCEEDED(rv))
{
mMsgBody = "<br><br>";
if (GetReplyOnTop() == 1)
mMsgBody = "<br><br>";
mMsgBody += author;
mMsgBody += " wrote:<br><BLOCKQUOTE TYPE=CITE><html>";
}
@ -1457,7 +1485,7 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
// looking manner
//
char *htmlBreak = "<BR>";
char *dashes = "--";
char *dashes = "-- ";
if (sigData != "")
{
if (m_composeHTML)