зеркало из https://github.com/mozilla/pjs.git
fix for bug#37928;adding domains section to sendformat pref panel;r=ducarroz;sr=mscott
This commit is contained in:
Родитель
20ddcf056a
Коммит
16dd48a05c
|
@ -0,0 +1,237 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*/
|
||||
|
||||
//Html Domain object
|
||||
var htmlobj = null //new Object();
|
||||
//htmlobj.tree_node = void 0; // the dom element of the htmldomain tree
|
||||
//htmlobj.treeroot_node = void 0; // dom element of the htmldomain treechildren
|
||||
//htmlobj.domain_pref = void 0; // dom element of the broadcaster mailhtmldomain
|
||||
|
||||
//Plain Text Domain object
|
||||
var plainobj = null //new Object();
|
||||
//plainobj.tree_node = void 0; // dom element of plaintextdomain tree
|
||||
//plainobj.treeroot_node = void 0; //dom element of plaintextdomain treechildren
|
||||
//plainobj.domain_pref = void 0; // dom element of the broadcaster mailplaintextdomain
|
||||
|
||||
var commonDialogsService = Components.classes["@mozilla.org/appshell/commonDialogs;1"].getService();
|
||||
commonDialogsService = commonDialogsService.QueryInterface(Components.interfaces.nsICommonDialogs);
|
||||
|
||||
|
||||
function Init()
|
||||
{
|
||||
try {
|
||||
parent.initPanel('chrome://messenger/content/messengercompose/pref-formatting.xul');
|
||||
}
|
||||
catch(ex) {
|
||||
dump("*** Couldn't initialize page switcher and pref loader.\n");
|
||||
//pref service backup
|
||||
} //catch
|
||||
//Initialize the objects
|
||||
htmlobj = new Object();
|
||||
plainobj = new Object();
|
||||
//Initialize the broadcaster value so that you can use it later
|
||||
htmlobj.domain_pref = document.getElementById('mailhtmldomain');
|
||||
plainobj.domain_pref = document.getElementById('mailplaintextdomain');
|
||||
htmlobj.tree_node = document.getElementById('html_domains');
|
||||
htmlobj.treeroot_node = document.getElementById('html_domains_root');
|
||||
plainobj.tree_node = document.getElementById('plaintext_domains');
|
||||
plainobj.treeroot_node = document.getElementById('plaintext_domains_root');
|
||||
|
||||
//Get the values of the Add Domain Dlg boxes and store it in the objects
|
||||
var AddDomainDlg = document.getElementById('domaindlg');
|
||||
htmlobj.DlgTitle = AddDomainDlg.getAttribute("htmldlg_title");
|
||||
htmlobj.DlgMsg = AddDomainDlg.getAttribute("htmldlg_msg");
|
||||
plainobj.DlgTitle = AddDomainDlg.getAttribute("plaintextdlg_title");
|
||||
plainobj.DlgMsg = AddDomainDlg.getAttribute("plaintextdlg_msg");
|
||||
//Id values for the objects for comparison
|
||||
htmlobj.id = "html";
|
||||
plainobj.id = "plain";
|
||||
LoadDomains(htmlobj);
|
||||
LoadDomains(plainobj);
|
||||
}
|
||||
|
||||
function AddDomain(obj)
|
||||
{
|
||||
var DomainName;
|
||||
if (commonDialogsService)
|
||||
{
|
||||
var result = {value:0};
|
||||
if (commonDialogsService.Prompt(
|
||||
window,
|
||||
obj.DlgTitle,
|
||||
obj.DlgMsg,
|
||||
null,
|
||||
result
|
||||
))
|
||||
DomainName = result.value.replace(/ /g,"");
|
||||
}
|
||||
|
||||
if (DomainName) {
|
||||
var objPrime;
|
||||
if (obj.id == "html")
|
||||
objPrime = plainobj;
|
||||
else
|
||||
objPrime = htmlobj;
|
||||
if (!DomainAlreadyPresent(obj, DomainName, true))
|
||||
if(!DomainAlreadyPresent(objPrime, DomainName, false)) {
|
||||
AddTreeItem(obj.treeroot_node, DomainName);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSavePrefString(obj);
|
||||
}
|
||||
|
||||
function AddTreeItem(treeRoot, domainTitle)
|
||||
{
|
||||
try {
|
||||
|
||||
// Create a treerow for the new Domain
|
||||
var item = document.createElement('treeitem');
|
||||
var row = document.createElement('treerow');
|
||||
var cell = document.createElement('treecell');
|
||||
|
||||
// Copy over the attributes
|
||||
cell.setAttribute('value', domainTitle);
|
||||
|
||||
// Add it to the active languages tree
|
||||
item.appendChild(row);
|
||||
row.appendChild(cell);
|
||||
treeRoot.appendChild(item);
|
||||
|
||||
} //try
|
||||
|
||||
catch (ex) {
|
||||
dump("*** Failed to add item: " + domainTitle + "\n");
|
||||
} //catch
|
||||
|
||||
}
|
||||
|
||||
function DomainAlreadyPresent(obj, domain_name, dup)
|
||||
{
|
||||
var errorTitle;
|
||||
var errorMsg;
|
||||
var pref_string = obj.domain_pref.getAttribute('value');
|
||||
var found = false;
|
||||
try {
|
||||
var arrayOfPrefs = pref_string.split(',');
|
||||
if (arrayOfPrefs)
|
||||
for (var i = 0; i < arrayOfPrefs.length; i++) {
|
||||
var str = arrayOfPrefs[i].replace(/ /g,"");
|
||||
if (str == domain_name) {
|
||||
dump("###ERROR DOMAIN ALREADY EXISTS\n");
|
||||
errorTitle = document.getElementById("domainerrdlg").getAttribute("domainerrdlg_title");
|
||||
if(dup)
|
||||
errorMsg = document.getElementById("domainerrdlg").getAttribute("duperr");
|
||||
else
|
||||
errorMsg = document.getElementById("domainerrdlg").getAttribute("dualerr");
|
||||
var errorMessage = errorMsg.replace(/@string@/, domain_name);
|
||||
if (commonDialogsService)
|
||||
commonDialogsService.Alert(window, errorTitle, errorMessage);
|
||||
else
|
||||
window.alert(errorMessage);
|
||||
found = true;
|
||||
break;
|
||||
}//if
|
||||
}//for
|
||||
|
||||
return found;
|
||||
}//try
|
||||
|
||||
catch(ex){
|
||||
return false;
|
||||
}//catch
|
||||
}
|
||||
|
||||
function RemoveDomains(obj)
|
||||
{
|
||||
var nextNode = null;
|
||||
var numSelected = obj.tree_node.selectedItems.length;
|
||||
var deleted_all = false;
|
||||
|
||||
while (obj.tree_node.selectedItems.length > 0) {
|
||||
|
||||
var selectedNode = obj.tree_node.selectedItems[0];
|
||||
nextNode = selectedNode.nextSibling;
|
||||
|
||||
if (!nextNode)
|
||||
|
||||
if (selectedNode.previousSibling)
|
||||
nextNode = selectedNode.previousSibling;
|
||||
|
||||
var row = selectedNode.firstChild;
|
||||
var cell = row.firstChild;
|
||||
|
||||
row.removeChild(cell);
|
||||
selectedNode.removeChild(row);
|
||||
obj.treeroot_node.removeChild(selectedNode);
|
||||
|
||||
} //while
|
||||
|
||||
if (nextNode) {
|
||||
obj.tree_node.selectItem(nextNode)
|
||||
} //if
|
||||
|
||||
UpdateSavePrefString(obj);
|
||||
}
|
||||
|
||||
function LoadDomains(obj)
|
||||
{
|
||||
try {
|
||||
var arrayOfPrefs = obj.domain_pref.getAttribute('value').split(',');
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to split the preference string!\n");
|
||||
}
|
||||
|
||||
if (arrayOfPrefs)
|
||||
for (var i = 0; i < arrayOfPrefs.length; i++) {
|
||||
|
||||
var str = arrayOfPrefs[i].replace(/ /g,"");
|
||||
if (str) {
|
||||
AddTreeItem(obj.treeroot_node, str);
|
||||
} //if
|
||||
} //for
|
||||
}
|
||||
|
||||
function UpdateSavePrefString(obj)
|
||||
{
|
||||
var num_domains = 0;
|
||||
pref_string = "";
|
||||
|
||||
for (var item = obj.treeroot_node.firstChild; item != null; item = item.nextSibling) {
|
||||
|
||||
var row = item.firstChild;
|
||||
var cell = row.firstChild;
|
||||
var domainid = cell.getAttribute('value');
|
||||
if (domainid.length > 1) {
|
||||
|
||||
num_domains++;
|
||||
|
||||
//separate >1 domains by commas
|
||||
if (num_domains > 1) {
|
||||
pref_string = pref_string + "," + domainid;
|
||||
} else {
|
||||
pref_string = domainid;
|
||||
} //if
|
||||
} //if
|
||||
}//for
|
||||
|
||||
obj.domain_pref.setAttribute("value", pref_string);
|
||||
}
|
|
@ -6,16 +6,37 @@
|
|||
|
||||
<window xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="parent.initPanel('chrome://messenger/content/messengercompose/pref-formatting.xul');"
|
||||
onload="Init()"
|
||||
orient="vertical"
|
||||
class="color-dialog">
|
||||
|
||||
<script language="javascript">
|
||||
<![CDATA[
|
||||
var _elementIDs = ["mailDefaultHTMLAction"];
|
||||
var _elementIDs = ["mailDefaultHTMLAction","mailhtmldomain","mailplaintextdomain"];
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<script language="javascript" src="chrome://messenger/content/messengercompose/pref-formatting.js"></script>
|
||||
|
||||
<!-- we are using these DTD values for localization -->
|
||||
|
||||
<html id="domaindlg" htmldlg_title="&add.htmltitle;" htmldlg_msg="&add.htmldomain;"
|
||||
plaintextdlg_title="&add.plaintexttitle;" plaintextdlg_msg="&add.plaintextdomain;"/>
|
||||
<html id="domainerrdlg" domainerrdlg_title="&domainnameError.title;" duperr="&duplicationError.label;"
|
||||
dualerr="&dualEntryError.label;"/>
|
||||
|
||||
<broadcaster id="mailhtmldomain"
|
||||
pref="true"
|
||||
preftype="string"
|
||||
prefstring="mailnews.html_domains"
|
||||
prefattribute="value"
|
||||
wsm_attributes="value"/>
|
||||
<broadcaster id="mailplaintextdomain"
|
||||
pref="true"
|
||||
preftype="string"
|
||||
prefstring="mailnews.plaintext_domains"
|
||||
prefattribute="value"
|
||||
wsm_attributes="value"/>
|
||||
|
||||
<box class="box-smallheader" title="&pane.title;"/>
|
||||
|
||||
<titledbox orient="vertical">
|
||||
|
@ -38,5 +59,49 @@
|
|||
<html>&receiveHTML.label;</html>
|
||||
|
||||
</titledbox>
|
||||
<titledbox orient="vertical" flex="1">
|
||||
<title><text value="&domain.title;"/></title>
|
||||
|
||||
<html>&domaindesc.label;</html>
|
||||
<box orient="horizontal" flex="1">
|
||||
<titledbox orient="vertical" id="html_box" flex="1">
|
||||
<title>
|
||||
<text value = "&HTMLdomaintitle.label;"/>
|
||||
</title>
|
||||
<tree class="inset" id="html_domains" flex="1"
|
||||
datasources="rdf:null" multiple="true"
|
||||
onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(htmlobj);">
|
||||
<treecolgroup>
|
||||
<treecol flex="1"/>
|
||||
</treecolgroup>
|
||||
<treechildren id="html_domains_root" flex="1"/>
|
||||
</tree>
|
||||
<box orient="horizontal">
|
||||
<spring flex="1"/>
|
||||
<button class="dialog" value="&AddButton.label;" oncommand="AddDomain(htmlobj);"/>
|
||||
<button class="dialog" value="&DeleteButton.label;" oncommand="RemoveDomains(htmlobj);"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
</titledbox>
|
||||
<titledbox orient="vertical" id="plaintext_box" flex="1">
|
||||
<title>
|
||||
<text value = "&PlainTexttitle.label;"/>
|
||||
</title>
|
||||
<tree class="inset" id="plaintext_domains" flex="1"
|
||||
datasources="rdf:null" multiple="true"
|
||||
onkeypress="if (event.keyCode == 8 || event.keyCode == 46) RemoveDomains(plainobj);">
|
||||
<treecolgroup>
|
||||
<treecol flex="1"/>
|
||||
</treecolgroup>
|
||||
<treechildren id="plaintext_domains_root" flex="1"/>
|
||||
</tree>
|
||||
<box orient="horizontal">
|
||||
<spring flex="1"/>
|
||||
<button class="dialog" value="&AddButton.label;" oncommand="AddDomain(plainobj);"/>
|
||||
<button class="dialog" value="&DeleteButton.label;" oncommand="RemoveDomains(plainobj);"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
</titledbox>
|
||||
</box>
|
||||
</titledbox>
|
||||
</window>
|
||||
|
|
|
@ -31,4 +31,33 @@ Rights Reserved.
|
|||
<!ENTITY sendBoth.label "Send the message in both plain text and HTML (larger message size)">
|
||||
<!ENTITY sendBoth.accesskey "e">
|
||||
<!ENTITY override.label "You can override these settings for individual messages by using the Options menu in the Mail Compose window.">
|
||||
<!ENTITY receiveHTML.label "If you know a particular recipient can receive HTML mail, uncheck the 'Send email as plain text (no HTML)' checkbox on the recipient's Address Book card.">
|
||||
<!ENTITY receiveHTML.label "If you know a particular recipient can receive HTML mail, uncheck the 'Send email as plain text (no HTML)' checkbox on the recipient's Address Book card.">
|
||||
|
||||
<!-- Html and Plain Text Domains -->
|
||||
<!ENTITY domain.title "HTML and Plain Text Domains">
|
||||
<!ENTITY domaindesc.label "You can specify those mail domain names(for example netscape.net) that you know can receive HTML messages, as well as those that can receive plain text only.When you send a message to an address that has one of those domain names listed below, Mail automatically sends the message in the correct format.">
|
||||
<!ENTITY HTMLdomaintitle.label "HTML domains.">
|
||||
<!ENTITY HTMLdomaintitle.accesskey "h">
|
||||
<!ENTITY PlainTexttitle.label "Plain Text domains.">
|
||||
<!ENTITY PlainTexttitle.accesskey "p">
|
||||
<!ENTITY AddButton.label "Add...">
|
||||
<!ENTITY AddHtmlDomain.accesskey "a">
|
||||
<!ENTITY AddPlainText.accesskey "d">
|
||||
<!ENTITY DeleteButton.label "Delete">
|
||||
<!ENTITY DeleteHtmlDomain.accesskey "l">
|
||||
<!ENTITY DeletePlainText.accesskey "t">
|
||||
|
||||
<!-- Add HTML Domain Name -->
|
||||
<!ENTITY add.htmltitle "Add HTML Domain Name">
|
||||
<!ENTITY add.htmldomain "HTML Domain Name:">
|
||||
<!ENTITY add.htmldomain.accesskey "d">
|
||||
<!ENTITY add.plaintexttitle "Add Plain Text Domain Name">
|
||||
<!ENTITY add.plaintextdomain "Plain Text Domain Name:">
|
||||
<!ENTITY add.plaintext.accesskey "d">
|
||||
|
||||
<!-- LOCALIZATION NOTE: do not translate @string@ -->
|
||||
<!ENTITY domainnameError.title "Domain Name Error">
|
||||
<!ENTITY duplicationError.label "The domain name @string@ already exists in this list.">
|
||||
|
||||
<!-- LOCALIZATION NOTE: do not translate @string@ -->
|
||||
<!ENTITY dualEntryError.label "A domain name cannot appear in both the HTML and Plain Text lists. The domain name @string@ already exists.">
|
||||
|
|
|
@ -132,6 +132,7 @@ messenger.jar:
|
|||
content/messenger/FilterEditor.js (base/search/resources/content/FilterEditor.js)
|
||||
content/messenger/messengercompose/pref-composing_messages.xul (compose/prefs/resources/content/pref-composing_messages.xul)
|
||||
content/messenger/messengercompose/pref-formatting.xul (compose/prefs/resources/content/pref-formatting.xul)
|
||||
content/messenger/messengercompose/pref-formatting.js (compose/prefs/resources/content/pref-formatting.js)
|
||||
content/messenger/messengercompose/messengercompose.xul (compose/resources/content/messengercompose.xul)
|
||||
content/messenger/messengercompose/MsgComposeCommands.js (compose/resources/content/MsgComposeCommands.js)
|
||||
content/messenger/messengercompose/addressingWidgetOverlay.js (compose/resources/content/addressingWidgetOverlay.js)
|
||||
|
|
Загрузка…
Ссылка в новой задаче