Bug 445010 – Migrate MailNews Junk Mail to the new prefwindow
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sat, 02 Aug 2008 00:01:32 +0100
changeset 54 647ef8ec4896
parent 53 74b5b7c1efce
child 55 b1979b7b3fbb
push id49
push useriann_cvs@blueyonder.co.uk
push date2008-08-01 23:01 +0000
treeherdercomm-central@647ef8ec4896 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs445010
Bug 445010 – Migrate MailNews Junk Mail to the new prefwindow p=me r/sr=neil
mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
mailnews/base/prefs/resources/content/pref-junk.js
mailnews/base/prefs/resources/content/pref-junk.xul
--- a/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
+++ b/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
@@ -66,16 +66,21 @@
               helpTopic="mail_prefs_general">
       <treechildren id="messengerChildren">
         <!-- XXX Move pref panes from below to here as they are migrated -->
         <treeitem id="viewingMessagesItem"
                   label="&viewingMessages.label;"
                   prefpane="viewing_messages_pane"
                   url="chrome://messenger/content/pref-viewing_messages.xul"
                   helpTopic="mail_prefs_display"/>
+        <treeitem id="junkItem"
+                  label="&junk.label;"
+                  prefpane="junk_pane"
+                  url="chrome://messenger/content/pref-junk.xul"
+                  helpTopic="mail-prefs-junk"/>
         <treeitem id="tagsItem"
                   label="&tags.label;"
                   prefpane="tags_pane"
                   url="chrome://messenger/content/pref-tags.xul"
                   helpTopic="mail-prefs-tags"/>
         <treeitem id="receiptsItem"
                   label="&return.label;"
                   prefpane="receipts_pane"
@@ -120,17 +125,17 @@
         </treeitem>
         <treeitem id="mailaddressbookpref">
           <treerow>
             <treecell url="chrome://messenger/content/addressbook/pref-addressing.xul" label="&address.label;"/> 
           </treerow>
         </treeitem>
         <treeitem>
           <treerow>
-            <treecell url="chrome://messenger/content/pref-junk.xul" label="&junk.label;"/>
+            <treecell label="(Migrated: &junk.label;)"/>
           </treerow>
         </treeitem>
         <treeitem id="mailtagspref">
           <treerow>
             <treecell label="(Migrated: &tags.label;)"/>
           </treerow>
         </treeitem>
         <treeitem>
--- a/mailnews/base/prefs/resources/content/pref-junk.js
+++ b/mailnews/base/prefs/resources/content/pref-junk.js
@@ -31,25 +31,24 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 function Startup()
 {
-  UpdateDependentElement(document.getElementById("manualMark"), "manualMarkMode");
-  UpdateDependentElement(document.getElementById("enableJunkLogging"), "openJunkLog");
+  UpdateDependentElement("manualMark", "manualMarkMode");
+  UpdateDependentElement("enableJunkLogging", "openJunkLog");
 }
 
-function UpdateDependentElement(aBaseElement, aDependentElementId)
+function UpdateDependentElement(aBaseId, aDependentId)
 {
-  var element = document.getElementById(aDependentElementId);
-  var isLocked = parent.hPrefWindow.getPrefIsLocked(element.getAttribute("prefstring"));
-  element.disabled = !aBaseElement.checked || isLocked;
+  var pref = document.getElementById(aBaseId).getAttribute("preference");
+  EnableElementById(aDependentId, document.getElementById(pref).value, false);
 }
 
 function OpenJunkLog()
 {
   window.openDialog("chrome://messenger/content/junkLog.xul",
                     "junkLog",
                     "chrome,modal,titlebar,resizable,centerscreen");
 }
--- a/mailnews/base/prefs/resources/content/pref-junk.xul
+++ b/mailnews/base/prefs/resources/content/pref-junk.xul
@@ -32,95 +32,110 @@
    - and other provisions required by the LGPL or the GPL. If you do not delete
    - the provisions above, a recipient may use your version of this file under
    - the terms of any one of the MPL, the GPL or the LGPL.
    -
    - ***** END LICENSE BLOCK ***** -->
 
 <?xml-stylesheet href="chrome://messenger/skin/prefPanels.css" type="text/css"?>
 
-<!DOCTYPE page [
+<!DOCTYPE overlay [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % prefJunkDTD SYSTEM "chrome://messenger/locale/pref-junk.dtd">
 %prefJunkDTD;
 ]>
 
-<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      onload="parent.initPanel('chrome://messenger/content/pref-junk.xul');"
-      headertitle="&pref.junk.title;">
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <prefpane id="junk_pane"
+            label="&pref.junk.title;"
+            script="chrome://messenger/content/pref-junk.js">
+    <preferences id="junk_preferences">
+      <preference id="mail.spam.manualMark"
+                  name="mail.spam.manualMark"
+                  type="bool"
+                  onchange="EnableElementById('manualMarkMode', this.value, false);"/>
+      <preference id="mail.spam.manualMarkMode"
+                  name="mail.spam.manualMarkMode"
+                  type="int"/>
+      <preference id="mail.spam.markAsReadOnSpam"
+                  name="mail.spam.markAsReadOnSpam"
+                  type="bool"/>
+      <preference id="mailnews.ui.junk.manualMarkAsJunkMarksRead"
+                  name="mailnews.ui.junk.manualMarkAsJunkMarksRead"
+                  type="bool"/>
+      <preference id="mail.spam.logging.enabled"
+                  name="mail.spam.logging.enabled"
+                  type="bool"
+                  onchange="EnableElementById('openJunkLog', this.value, false);"/>
+      <preference id="pref.junk.disable_button.openJunkLog"
+                  name="pref.junk.disable_button.openJunkLog"
+                  type="string"/>
+      <preference id="pref.junk.disable_button.resetTrainingData"
+                  name="pref.junk.disable_button.resetTrainingData"
+                  type="string"/>
+    </preferences>
 
-  <script type="application/x-javascript">
-    <![CDATA[
-      var _elementIDs = ["manualMark", "manualMarkMode", 
-                         "autoMarkAsRead", "manualMarkAsRead",
-                         "enableJunkLogging"];
-    ]]>
-  </script>
+    <stringbundle id="bundlePreferences"
+                  src="chrome://messenger/locale/messenger.properties"/>
 
-  <script type="application/x-javascript" src="chrome://messenger/content/pref-junk.js"/>
+    <groupbox>
+      <caption label="&junkSettings.caption;"/>
+      <description>&junkMail.intro;</description>
+      <class separator="thin"/>
 
-  <stringbundle id="bundlePreferences" src="chrome://messenger/locale/messenger.properties"/>
-    
-  <groupbox>
-    <caption label="&junkSettings.caption;"/>
-    <description>&junkMail.intro;</description>
-    <class separator="thin"/>
-          
-    <checkbox id="manualMark" 
+      <checkbox id="manualMark"
               label="&manualMark.label;"
               accesskey="&manualMark.accesskey;"
-              prefstring="mail.spam.manualMark"
-              oncommand="UpdateDependentElement(this, 'manualMarkMode')"/>
-    <radiogroup id="manualMarkMode"
-                class="indent"
-                aria-labelledby="manualMark"
-                prefstring="mail.spam.manualMarkMode">
-      <radio id="manualMarkMode0"
-             label="&manualMarkModeMove.label;"
-             accesskey="&manualMarkModeMove.accesskey;"
-             value="0"/>
-      <radio id="manualMarkMode1"
-             label="&manualMarkModeDelete.label;"
-             accesskey="&manualMarkModeDelete.accesskey;"
-             value="1"/>
-    </radiogroup>
+              preference="mail.spam.manualMark"/>
+      <radiogroup id="manualMarkMode"
+                  class="indent"
+                  aria-labelledby="manualMark"
+                  preference="mail.spam.manualMarkMode">
+        <radio id="manualMarkMode0"
+               label="&manualMarkModeMove.label;"
+               accesskey="&manualMarkModeMove.accesskey;"
+               value="0"/>
+        <radio id="manualMarkMode1"
+               label="&manualMarkModeDelete.label;"
+               accesskey="&manualMarkModeDelete.accesskey;"
+               value="1"/>
+      </radiogroup>
 
-    <separator class="thin"/>
+      <separator class="thin"/>
 
-    <description>&markAsRead.intro;</description>
-    <vbox class="indent">
-      <checkbox id="autoMarkAsRead" 
-                label="&autoMarkAsRead.label;"
-                accesskey="&autoMarkAsRead.accesskey;"
-                prefstring="mail.spam.markAsReadOnSpam"/>
-      <checkbox id="manualMarkAsRead" 
-                label="&manualMarkAsRead.label;"
-                accesskey="&manualMarkAsRead.accesskey;"
-                prefstring="mailnews.ui.junk.manualMarkAsJunkMarksRead"/>
-    </vbox>
+      <description>&markAsRead.intro;</description>
+      <vbox class="indent">
+        <checkbox id="autoMarkAsRead"
+                  label="&autoMarkAsRead.label;"
+                  accesskey="&autoMarkAsRead.accesskey;"
+                  preference="mail.spam.markAsReadOnSpam"/>
+        <checkbox id="manualMarkAsRead"
+                  label="&manualMarkAsRead.label;"
+                  accesskey="&manualMarkAsRead.accesskey;"
+                  preference="mailnews.ui.junk.manualMarkAsJunkMarksRead"/>
+      </vbox>
+
+      <separator class="thin"/>
 
-    <separator class="thin"/>
-  
-    <hbox align="start">
-      <checkbox id="enableJunkLogging"
-                label="&enableJunkLogging.label;"
-                accesskey="&enableJunkLogging.accesskey;"
-                prefstring="mail.spam.logging.enabled" 
-                oncommand="UpdateDependentElement(this, 'openJunkLog')"/>
-      <spacer flex="1"/>
-      <button id="openJunkLog"
-              label="&openJunkLog.label;"
-              accesskey="&openJunkLog.accesskey;" 
-              prefstring="pref.junk.disable_button.openJunkLog"
-              oncommand="OpenJunkLog();"/>
-    </hbox>
-    <hbox align="start">
-      <spacer flex="1"/>
-      <button id="resetTrainingData"
-              label="&resetTrainingData.label;" 
-              accesskey="&resetTrainingData.accesskey;" 
-              prefstring="pref.junk.disable_button.resetTrainingData"
-              oncommand="ResetTrainingData();"/>
-    </hbox>
-  </groupbox>
-
-</page>
+      <hbox align="start">
+        <checkbox id="enableJunkLogging"
+                  label="&enableJunkLogging.label;"
+                  accesskey="&enableJunkLogging.accesskey;"
+                  preference="mail.spam.logging.enabled"/>
+        <spacer flex="1"/>
+        <button id="openJunkLog"
+                label="&openJunkLog.label;"
+                accesskey="&openJunkLog.accesskey;"
+                preference="pref.junk.disable_button.openJunkLog"
+                oncommand="OpenJunkLog();"/>
+      </hbox>
+      <hbox align="start">
+        <spacer flex="1"/>
+        <button id="resetTrainingData"
+                label="&resetTrainingData.label;"
+                accesskey="&resetTrainingData.accesskey;"
+                preference="pref.junk.disable_button.resetTrainingData"
+                oncommand="ResetTrainingData();"/>
+      </hbox>
+    </groupbox>
+  </prefpane>
+</overlay>