Bug 265232 Make sure we respect locked prefs throughout Mailnews UI

p=me r=neil.parkwaycc.co.uk sr=bienvenu
This commit is contained in:
bugzilla%arlen.demon.co.uk 2005-01-17 12:18:25 +00:00
Родитель 1f6bfed465
Коммит d30068e627
7 изменённых файлов: 47 добавлений и 176 удалений

Просмотреть файл

@ -20,6 +20,7 @@
*
* Contributor(s):
* Sean Su <ssu@netscape.com>
* Ian Neal <bugzilla@arlen.demon.co.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -35,68 +36,27 @@
*
* ***** END LICENSE BLOCK ***** */
function setColorWell(aPicker)
{
var colorRef;
colorRef = aPicker.nextSibling; // colour value is held here
colorRef.setAttribute( "value", aPicker.color );
}
function getColorFromWellAndSetValue(aPickerId)
{
var picker;
var colorRef;
var color;
picker = document.getElementById(aPickerId);
colorRef = picker.nextSibling;
color = colorRef.getAttribute("value");
picker.color = color;
return color;
}
function Startup()
{
getColorFromWellAndSetValue("labelColorPicker1");
getColorFromWellAndSetValue("labelColorPicker2");
getColorFromWellAndSetValue("labelColorPicker3");
getColorFromWellAndSetValue("labelColorPicker4");
getColorFromWellAndSetValue("labelColorPicker5");
return true;
}
/* Function to restore pref values to application defaults */
function restoreColorAndDescriptionToDefaults()
{
var prefColor;
var description;
var pickerColor;
var dataColor;
var labelDescription;
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getDefaultBranch(null);
var prefDescription = prefService.getDefaultBranch("mailnews.labels.description.");
var prefColor = prefService.getDefaultBranch("mailnews.labels.color.");
/* there are only 5 labels */
for(var i = 1; i <= 5; i++)
for (var i = 1; i <= 5; i++)
{
/* set the default description from prefs */
description = prefs.getComplexValue("mailnews.labels.description." + i,
Components.interfaces.nsIPrefLocalizedString).data;
labelDescription = document.getElementById("label" + i + "TextBox");
labelDescription.value = description;
if (!labelDescription.disabled)
labelDescription.value = prefDescription.getComplexValue(i, Components.interfaces.nsIPrefLocalizedString).data;
/* set the default color from prefs */
prefColor = prefs.getCharPref("mailnews.labels.color." + i);
pickerColor = document.getElementById("labelColorPicker" + i);
pickerColor.color = prefColor;
// need to call setColorWell() so that the default pref value will be updated
// in the preferences file.
setColorWell(pickerColor);
pickerColor = document.getElementById("label" + i + "Color");
if (!pickerColor.disabled)
pickerColor.color = prefColor.getCharPref(i);
}
}

Просмотреть файл

@ -22,6 +22,7 @@
-
- Contributor(s):
- Sean Su <ssu@netscape.com>
- Ian Neal <bugzilla@arlen.demon.co.uk>
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
@ -75,16 +76,9 @@
<colorpicker
class="small-margin"
type="button"
id="labelColorPicker1"
palettename="standard"
onchange="setColorWell(this);"/>
<data
id="label1Color"
pref="true"
preftype="color"
prefstring="mailnews.labels.color.1"
prefattribute="value"
wsm_attributes="value"/>
prefstring="mailnews.labels.color.1"/>
</hbox>
<!-- label color: 2 (default orange) -->
@ -98,16 +92,9 @@
<colorpicker
class="small-margin"
type="button"
id="labelColorPicker2"
palettename="standard"
onchange="setColorWell(this);"/>
<data
id="label2Color"
pref="true"
preftype="color"
prefstring="mailnews.labels.color.2"
prefattribute="value"
wsm_attributes="value"/>
prefstring="mailnews.labels.color.2"/>
</hbox>
<!-- label color: 3 (default green) -->
@ -121,16 +108,9 @@
<colorpicker
class="small-margin"
type="button"
id="labelColorPicker3"
palettename="standard"
onchange="setColorWell(this);"/>
<data
id="label3Color"
pref="true"
preftype="color"
prefstring="mailnews.labels.color.3"
prefattribute="value"
wsm_attributes="value"/>
prefstring="mailnews.labels.color.3"/>
</hbox>
<!-- label color: 4 (default blue) -->
@ -144,16 +124,9 @@
<colorpicker
class="small-margin"
type="button"
id="labelColorPicker4"
palettename="standard"
onchange="setColorWell(this);"/>
<data
id="label4Color"
pref="true"
preftype="color"
prefstring="mailnews.labels.color.4"
prefattribute="value"
wsm_attributes="value"/>
prefstring="mailnews.labels.color.4"/>
</hbox>
<!-- label color: 5 (default purple) -->
@ -167,16 +140,9 @@
<colorpicker
class="small-margin"
type="button"
id="labelColorPicker5"
palettename="standard"
onchange="setColorWell(this);"/>
<data
id="label5Color"
pref="true"
preftype="color"
prefstring="mailnews.labels.color.5"
prefattribute="value"
wsm_attributes="value"/>
prefstring="mailnews.labels.color.5"/>
</hbox>
<hbox pack="end">
@ -187,4 +153,3 @@
</groupbox>
</page>

Просмотреть файл

@ -13,21 +13,11 @@ function Startup()
StartPageCheck();
}
function setColorWell(menu)
{
// Find the colorWell and colorPicker in the hierarchy.
var colorWell = menu.firstChild.nextSibling;
var colorPicker = menu.firstChild.nextSibling.nextSibling.firstChild;
// Extract color from colorPicker and assign to colorWell.
var color = colorPicker.getAttribute('color');
colorWell.style.backgroundColor = color;
}
function StartPageCheck()
{
var checked = document.getElementById("mailnewsStartPageEnabled").checked;
document.getElementById("mailnewsStartPageUrl").disabled = !checked;
var startPageLocked = parent.hPrefWindow.getPrefIsLocked("mailnews.start_page.url");
document.getElementById("mailnewsStartPageUrl").disabled = !checked || startPageLocked;
}
function setHomePageToDefaultPage(folderFieldId)

Просмотреть файл

@ -25,6 +25,7 @@
Mohan Bhamidipati (mohanb@netscape.com)
Diego Biurrun (diego@biurrun.de)
David Bienvenu (bienvenu@nventure.com)
Ian Neal (bugzilla@arlen.demon.co.uk)
Alternatively, the contents of this file may be used under the terms of
either of the GNU General Public License Version 2 or later (the "GPL"),
@ -54,20 +55,17 @@
function Startup()
{
var aCheckbox = document.getElementById("offlineCompactFolder");
enableField(aCheckbox, "offlineCompactFolderMin", false);
enableField(document.getElementById("offlineCompactFolder"), false);
}
function enableField(aCheckbox, aNodeID, setFocus)
function enableField(aCheckbox, setFocus)
{
var aField = document.getElementById(aNodeID);
if (aCheckbox.checked)
aField.removeAttribute("disabled");
else
aField.setAttribute("disabled", "true");
var folderMin = document.getElementById("offlineCompactFolderMin");
folderMin.disabled = (!aCheckbox.checked ||
parent.hPrefWindow.getPrefIsLocked(folderMin.getAttribute("prefstring")));
if (!aField.disabled && setFocus)
aField.focus();
if (!folderMin.disabled && setFocus)
folderMin.focus();
}
]]>
</script>
@ -119,7 +117,7 @@
<hbox align="center">
<checkbox id="offlineCompactFolder" label="&offlineCompact.label;" accesskey="&offlineCompact.accesskey;"
prefstring="mail.prompt_purge_threshhold"
oncommand="enableField(this,'offlineCompactFolderMin',true);"/>
oncommand="enableField(this, true);"/>
<textbox id="offlineCompactFolderMin" size="5" value="100"
preftype="int" prefstring="mail.purge_threshhold"/>
<label value="&kb.label;"/>

Просмотреть файл

@ -18,6 +18,9 @@
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ian Neal <bugzilla@arlen.demon.co.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@ -55,21 +58,17 @@ function Startup() {
}
function EnableDisableAllowedReceipts() {
if (receiptSend && (receiptSend.getAttribute("value") == "false")) {
notInToCcPref.setAttribute("disabled", "true");
notInToCcLabel.setAttribute("disabled", "true");
outsideDomainPref.setAttribute("disabled", "true");
outsideDomainLabel.setAttribute("disabled", "true");
otherCasesPref.setAttribute("disabled", "true");
otherCasesLabel.setAttribute("disabled", "true");
}
else {
notInToCcPref.removeAttribute("disabled");
notInToCcLabel.removeAttribute("disabled");
outsideDomainPref.removeAttribute("disabled");
outsideDomainLabel.removeAttribute("disabled");
otherCasesPref.removeAttribute("disabled");
otherCasesLabel.removeAttribute("disabled");
}
var prefWindow = parent.hPrefWindow;
var notInToCcLocked = prefWindow.getPrefIsLocked("mail.mdn.report.not_in_to_cc");
var outsideDomainLocked = prefWindow.getPrefIsLocked("mail.mdn.report.outside_domain");
var otherCasesLocked = prefWindow.getPrefIsLocked("mail.mdn.report.other");
var disableAll = receiptSend && (receiptSend.getAttribute("value") == "false");
notInToCcPref.disabled = disableAll || notInToCcLocked;
notInToCcLabel.disabled = disableAll;
outsideDomainPref.disabled = disableAll || outsideDomainLocked;
outsideDomainLabel.disabled = disableAll;
otherCasesPref.disabled = disableAll || otherCasesLocked;
otherCasesLabel.disabled = disableAll;
return true;
}

Просмотреть файл

@ -14,26 +14,6 @@
var _elementIDs = ["mailFixedWidthMessages", "mailQuotedStyle", "mailQuotedSize", "wrapLongLines", "displayGlyph", "mailCitationColor", "sendDefaultCharsetList", "forceCharsetOverride"];
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "charsetmenu-selected", "other");
function Startup()
{
getColorFromPickerAndSetWell('citationmenu', 'mailCitationColor');
}
function getColorFromPickerAndSetWell(menuID, colorfield)
{
var picker = document.getElementById( menuID );
var colorValue = document.getElementById( colorfield );
if (picker) {
picker.color = colorValue.getAttribute("value");
}
}
function setColorWell(aPicker)
{
var colorRef = aPicker.nextSibling;
colorRef.setAttribute("value", aPicker.color );
}
]]>
</script>
@ -73,9 +53,8 @@
</menupopup>
</menulist>
<label value="&color.label;" accesskey="&color.accesskey;" control="citationmenu"/>
<colorpicker type="button" id="citationmenu" palettename="standard" onchange="setColorWell(this);"/>
<broadcaster id="mailCitationColor" pref="true" preftype="color" prefstring="mail.citation_color" prefattribute="value" wsm_attributes="value"/>
<label value="&color.label;" accesskey="&color.accesskey;" control="mailCitationColor"/>
<colorpicker type="button" id="mailCitationColor" palettename="standard" prefstring="mail.citation_color"/>
</hbox>
<description>&viewingPlainText.label;</description>

Просмотреть файл

@ -25,24 +25,6 @@
{
document.getElementById("spellCheckBeforeSend").hidden =
!("@mozilla.org/spellchecker;1" in Components.classes);
getColorFromWellAndSetValue("textColorButton");
getColorFromWellAndSetValue("backgroundColorButton");
}
function setColorWell(aPicker)
{
var colorRef = aPicker.nextSibling;
colorRef.setAttribute( "value", aPicker.color );
}
function getColorFromWellAndSetValue(aPickerId)
{
var picker = document.getElementById(aPickerId);
var colorRef = picker.nextSibling;
var color = colorRef.getAttribute("value");
picker.color = color;
return color;
}
function populateFonts() {
@ -150,12 +132,10 @@
<menuitem value="xx-large" label="&size-xx-largeCmd.label;"/>
</menupopup>
</menulist>
<label control="textColorButton" value="&fontColor.label;" accesskey="&fontColor.accesskey;"/>
<colorpicker type="button" id="textColorButton" onchange="setColorWell(this)"/>
<data id="textColor" preftype="color" prefstring="msgcompose.text_color" prefattribute="value" wsm_attributes="value"/>
<label control="backgroundColorButton" value="&bgColor.label;" accesskey="&bgColor.accesskey;"/>
<colorpicker type="button" id="backgroundColorButton" onchange="setColorWell(this)"/>
<data id="backgroundColor" preftype="color" prefstring="msgcompose.background_color" prefattribute="value" wsm_attributes="value"/>
<label control="textColor" value="&fontColor.label;" accesskey="&fontColor.accesskey;"/>
<colorpicker type="button" id="textColor" prefstring="msgcompose.text_color"/>
<label control="backgroundColor" value="&bgColor.label;" accesskey="&bgColor.accesskey;"/>
<colorpicker type="button" id="backgroundColor" prefstring="msgcompose.background_color"/>
</hbox>
</vbox>
</groupbox>