From 72c36135ff19f7e125f3483f9ee1f0bac072d099 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 22 Jul 2003 18:19:07 +0000 Subject: [PATCH] Due to popular demand, Add back the View / Messages as Simple HTML, origianl HTML or plain text options. --- mail/base/content/mailWindowOverlay.js | 70 +++++++++++++++++++++++++ mail/base/content/mailWindowOverlay.xul | 12 +++++ 2 files changed, 82 insertions(+) diff --git a/mail/base/content/mailWindowOverlay.js b/mail/base/content/mailWindowOverlay.js index e1c242c109f..50e9cef99c6 100644 --- a/mail/base/content/mailWindowOverlay.js +++ b/mail/base/content/mailWindowOverlay.js @@ -418,6 +418,49 @@ function InitViewHeadersMenu() menuitem.setAttribute("checked", "true"); } +function InitViewBodyMenu() +{ + var html_as = 0; + var prefer_plaintext = false; + var disallow_classes = 0; + try + { + prefer_plaintext = pref.getBoolPref("mailnews.display.prefer_plaintext"); + html_as = pref.getIntPref("mailnews.display.html_as"); + disallow_classes = pref.getIntPref("mailnews.display.disallow_mime_handlers"); + if (disallow_classes > 0) + disallow_classes_no_html = disallow_classes; + // else disallow_classes_no_html keeps its inital value (see top) + } + catch (ex) + { + dump("failed to get the body plaintext vs. HTML prefs\n"); + } + + var AllowHTML_checked = false; + var Sanitized_checked = false; + var AsPlaintext_checked = false; + if (!prefer_plaintext && !html_as && !disallow_classes) + AllowHTML_checked = true; + else if (!prefer_plaintext && html_as == 3 && disallow_classes > 0) + Sanitized_checked = true; + else if (prefer_plaintext && html_as == 1 && disallow_classes > 0) + AsPlaintext_checked = true; + // else (the user edited prefs/user.js) check none of the radio menu items + + var AllowHTML_menuitem = document.getElementById("bodyAllowHTML"); + var Sanitized_menuitem = document.getElementById("bodySanitized"); + var AsPlaintext_menuitem = document.getElementById("bodyAsPlaintext"); + if (AllowHTML_menuitem && Sanitized_menuitem && AsPlaintext_menuitem) + { + AllowHTML_menuitem.setAttribute("checked", AllowHTML_checked ? "true" : "false"); + Sanitized_menuitem.setAttribute("checked", Sanitized_checked ? "true" : "false"); + AsPlaintext_menuitem.setAttribute("checked", AsPlaintext_checked ? "true" : "false"); + } + else + dump("Where is my View|Body menu?\n"); +} + function IsNewsMessage(messageUri) { return (/^news-message:/.test(messageUri)); @@ -1392,6 +1435,33 @@ function MsgViewBriefHeaders() return true; } +function MsgBodyAllowHTML() +{ + gPrefs.setBoolPref("mailnews.display.prefer_plaintext", false); + gPrefs.setIntPref("mailnews.display.html_as", 0); + gPrefs.setIntPref("mailnews.display.disallow_mime_handlers", 0); + MsgReload(); + return true; +} + +function MsgBodySanitized() +{ + gPrefs.setBoolPref("mailnews.display.prefer_plaintext", false); + gPrefs.setIntPref("mailnews.display.html_as", 3); + gPrefs.setIntPref("mailnews.display.disallow_mime_handlers", + disallow_classes_no_html); + MsgReload(); + return true; +} + +function MsgBodyAsPlaintext() +{ + gPrefs.setBoolPref("mailnews.display.prefer_plaintext", true); + gPrefs.setIntPref("mailnews.display.html_as", 1); + gPrefs.setIntPref("mailnews.display.disallow_mime_handlers", disallow_classes_no_html); + MsgReload(); + return true; +} function ToggleInlineAttachment(target) { diff --git a/mail/base/content/mailWindowOverlay.xul b/mail/base/content/mailWindowOverlay.xul index 8179218e5bb..a8b31b10e64 100644 --- a/mail/base/content/mailWindowOverlay.xul +++ b/mail/base/content/mailWindowOverlay.xul @@ -1168,6 +1168,18 @@ + + + + + + + +