32477 Accept-Language UI

This commit is contained in:
jbetak%netscape.com 2000-05-12 03:19:50 +00:00
parent 2dc6942953
commit 09834afbcd
5 changed files with 408 additions and 589 deletions

View File

@ -26,14 +26,12 @@
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="main-box"
id="addlang-box"
title="&languages.customize.add.title.label;"
class="dialog"
windowtype="sidebar:customize"
onload="InitAvailable();"
align="vertical"
persist="width height"
width="340" height="383">
class="color-dialog"
onload="Init();"
orient="vertical"
width="340" height="379">
<html:script language="javascript" src="pref-languages.js"/>
<html:script language="javascript" src="chrome://global/content/strres.js" />
@ -52,16 +50,18 @@
<!-- vert 1 -->
<box align="vertical" flex="1">
<html:div class="vertical-gap">
&languages.customize.prefAddLangDescript;
</html:div>
<separator/>
<html:div class="vertical-gap">
&languages.customize.current.label;
</html:div>
<html>
&languages.customize.prefAddLangDescript;
</html>
<spring style="height:8px"/>
<html>
&languages.customize.available.label;
</html>
<!-- horz 2 -->
<box align="horizontal" class="box-group" flex="1">
@ -82,20 +82,14 @@
<spring style="height:16px"/>
<!--
<html:table>
<html:tr>
<html:td>
<html:label>&languages.customize.others.label;</html:label>
</html:td>
<html:td>
<html:input size="30" type="text" id="languages.other"/>
</html:td>
</html:tr>
</html:table>
<box autostretch="never">
<text class="label" value="&languages.customize.others.label;" for="languages.other"/>
<textfield id="languages.other" size="7" maxlength="5"/>
<text class="label" value="&languages.customize.others.examples;" for="languages.other"/>
</box>
<spring style="height:8px"/>
<spring style="height:16px"/>
-->
</box>
<!-- vert 1 -->
@ -105,20 +99,26 @@
</box>
<!-- horiz 1 -->
<separator class="groove"/>
<spring style="width:1em"/>
<!-- The 'Save' and 'Cancel' buttons -->
<!-- horz 2 -->
<box align="horizontal">
<spring flex="48%"/>
<titledbutton id="save_button" onclick="AddAvailableLanguage()"
<button id="save_button" onclick="AddAvailableLanguage()"
class="dialog push"
value="&languages.customize.ok.label;"/>
<spring flex="4%"/>
<titledbutton onclick="window.close()"
<button onclick="window.close()"
class="dialog push"
value="&languages.customize.cancel.label;" />
<spring flex="48%"/>
</box>
<!-- horz 2 -->
<spring style="width:1em"/>
</window>

View File

@ -1,128 +1,136 @@
//GLOBALS
//pref service and pref string
var prefInt;
//locale bundles
var regionsBundle;
var languagesBundle;
var acceptedBundle;
var activeLanguageList;
var availLanguageList;
var availLanguageDict;
var languages_pref_string;
//dictionary of all supported locales
var availLanguageDict;
//XUL tree handles
var available_languages;
var available_languages_treeroot;
//XUL tree handles
var active_languages;
var active_languages_treeroot;
//XUL window pref window interface object
var prefwindow_proxy_object;
function GetBundles()
{
if (!regionsBundle) regionsBundle = srGetStrBundle("chrome://global/locale/regionNames.properties");
if (!languagesBundle) languagesBundle = srGetStrBundle("chrome://global/locale/languageNames.properties");
if (!acceptedBundle) acceptedBundle = srGetStrBundle("resource:/res/language.properties");
}
function InitAvailable()
function Init()
{
dump("********** Init()\n");
dump("********** InitAvailable()\n");
try
{
if (!prefInt) {
languages_pref_string = new String();
prefInt = Components.classes["component://netscape/preferences"];
if (prefInt) {
prefInt = prefInt.getService();
prefInt = prefInt.QueryInterface(Components.interfaces.nsIPref);
languages_pref_string = prefInt.CopyCharPref("intl.accept_languages");
dump("*** Language PrefString: " + languages_pref_string + "\n");
}
}
try {
GetBundles()
ReadAvailableLanguages();
}
catch(ex)
{
dump("failed to get prefs or Language mgr. services!\n");
prefInt = null;
}
GetBundles()
ReadAvailableLanguages();
LoadAvailableLanguages();
}
catch(ex) {
dump("*** Couldn't get string bundles\n");
}
if (!window.arguments) {
try {
//base window
active_languages = document.getElementById('active_languages');
active_languages_treeroot = document.getElementById('active_languages_root');
prefwindow_proxy_object = document.getElementById('intlAcceptLanguages');
} //try
function InitActive2()
{
catch(ex) {
dump("*** Couldn't get XUL element handles\n");
} //catch
try
{
if (!prefInt) {
prefInt = Components.classes["component://netscape/preferences"];
try {
parent.initPanel('chrome://communicator/content/pref/pref-languages2.xul');
}
if (prefInt) {
catch(ex) {
languages_pref_string = new String();
prefInt = prefInt.getService();
prefInt = prefInt.QueryInterface(Components.interfaces.nsIPref);
languages_pref_string = prefInt.CopyCharPref("intl.accept_languages");
dump("*** Language PrefString: " + languages_pref_string + "\n");
dump("*** Couldn't initialize pref panel\n");
//pref service backup
}
}
catch(ex)
{
dump("failed to get prefs or charset mgr. services!\n");
prefInt = null;
}
GetBundles()
ReadAvailableLanguages();
LoadActiveLanguages2();
}
} //catch
function InitActive()
{
//get pref service as backup
try
{
if (!prefInt) {
prefInt = Components.classes["component://netscape/preferences"];
try
{
if (!prefInt) {
prefInt = Components.classes["component://netscape/preferences"];
}
if (prefInt) {
prefInt = prefInt.getService();
prefInt = prefInt.QueryInterface(Components.interfaces.nsIPref);
prefwindow_proxy_object.value = prefInt.CopyCharPref("intl.accept_languages");
if (!prefwindow_proxy_object.value) prefwindow_proxy_object.value = "en";
} //if
} //if
} //try
if (prefInt) {
catch(ex)
{
dump("failed to get pref service!\n");
prefInt = null;
}
languages_pref_string = new String();
prefInt = prefInt.getService();
prefInt = prefInt.QueryInterface(Components.interfaces.nsIPref);
languages_pref_string = prefInt.CopyCharPref("intl.accept_languages");
dump("*** Language PrefString: " + languages_pref_string + "\n");
}
}
catch(ex)
{
dump("failed to get prefs or charset mgr. services!\n");
prefInt = null;
}
GetBundles()
ReadAvailableLanguages();
LoadActiveLanguages();
try {
dump("*** Language PrefString: " + prefwindow_proxy_object.value + "\n");
} //try
catch(ex) {
dump("*** Pref object doesn't exist\n");
} //catch
LoadActiveLanguages();
} else {
try {
//add language popup
available_languages = document.getElementById('available_languages');
available_languages_treeroot = document.getElementById('available_languages_root');
active_languages = window.opener.document.getElementById('active_languages');
active_languages_treeroot = window.opener.document.getElementById('active_languages_root');
prefwindow_proxy_object = window.opener.document.getElementById('intlAcceptLanguages');
} //try
catch(ex) {
dump("*** Couldn't get XUL element handles\n");
} //catch
LoadAvailableLanguages();
}
}
function AddLanguage()
{
dump("********** AddLanguage()\n");
var SelArray = window.openDialog("chrome://communicator/content/pref/pref-languages-add.xul","","modal=yes,chrome,resizable=no");
dump("********** addLanguage receiving " + SelArray.document + "\n");
dump("********** addLanguage receiving " + SelArray.returnValue + "\n");
window.openDialog("chrome://communicator/content/pref/pref-languages-add.xul","","modal=yes,chrome,resizable=no", "addlangwindow");
UpdatePrefString();
}
@ -130,13 +138,12 @@ function ReadAvailableLanguages()
{
availLanguageDict = new Array();
var visible = new String();
var str = new String();
var i =0;
dump('ReadAvailableLanguages()\n');
acceptedBundleEnum = acceptedBundle.getSimpleEnumeration();
while (acceptedBundleEnum.HasMoreElements()) {
//progress through the bundle
@ -152,42 +159,53 @@ function ReadAvailableLanguages()
if (stringNameProperty[1] == 'accept') {
//dump the UI string (value)
var visible = curItem.getValue();
visible = curItem.getValue();
if (visible == 'true') {
//if (visible == 'true') {
str = stringNameProperty[0];
stringLangRegion = stringNameProperty[0].split('-');
if (stringLangRegion[0]) {
var tit = languagesBundle.GetStringFromName(stringLangRegion[0]);
if (stringLangRegion[1]) {
try {
var tit = tit + "/" + regionsBundle.GetStringFromName(stringLangRegion[1]);
var tit = languagesBundle.GetStringFromName(stringLangRegion[0]);
}
catch (ex) {
dump("No region string for:" + stringLangRegion[1] + "\n");
dump("No language string for:" + stringLangRegion[1] + "\n");
}
} //if region
if (stringLangRegion[1]) {
try {
var tit = tit + "/" + regionsBundle.GetStringFromName(stringLangRegion[1]);
}
catch (ex) {
dump("No region string for:" + stringLangRegion[1] + "\n");
}
} //if region
tit = tit + " [" + str + "]";
} //if language
if (str) if (tit) {
dump("Loading available language:" + str + " = " + tit + ", " + i + "\n");
availLanguageDict[i] = new Array(2);
availLanguageDict[i][0] = tit;
availLanguageDict[i][1] = str;
availLanguageDict[i][2] = true;
availLanguageDict[i][2] = visible;
i++;
if (tit) {}
else dump('Not label for :' + str + ', ' + tit+'\n');
} // if str&tit
} //if visible
//} //if visible
} //if accepted
} //while
@ -197,153 +215,28 @@ function ReadAvailableLanguages()
function LoadAvailableLanguages()
{
availLanguageList = new Array();
var available_languages = document.getElementById('available_languages');
var available_languages_treeroot = document.getElementById('available_languages_root');
dump("Loading available languages!\n");
dump("Dict length: " + availLanguageDict.length + "\n");
if (availLanguageDict) for (i = 0; i < availLanguageDict.length; i++) {
try { //let's beef up our error handling for languages without label / title
if (availLanguageDict[i][2] == 'true') {
dump("*** Creating new row\n");
// Create a treerow for the new Language
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
tit = availLanguageDict[i][0];
str = availLanguageDict[i][1];
dump("*** Tit: " + tit + "\n");
dump("*** Str: " + str + "\n");
// Copy over the attributes
cell.setAttribute('value', tit);
cell.setAttribute('id', str);
// Add it to the active languages tree
dump("*** Append row \n");
item.appendChild(row);
dump("*** Append cell \n");
row.appendChild(cell);
dump("*** Append item \n");
available_languages_treeroot.appendChild(item);
dump("*** Tit: " + tit + "\n");
dump("*** Str: " + str + "\n");
// Select first item
if (i == 0) {
}
dump("*** Added Available Language: " + tit + "\n");
} //try
catch (ex) {
dump("*** Failed to add Avail. Language: " + tit + "\n");
} //catch
AddTreeItem(document, available_languages_treeroot, availLanguageDict[i][1], availLanguageDict[i][0]);
} //if
} //for
}
function GetLanguageTitle(id)
{
dump("looking up title for:" + id + "\n");
if (availLanguageDict) for (j = 0; j < availLanguageDict.length; j++) {
//dump("ID:" + availLanguageDict[j][1] + " ==> " + availLanguageDict[j][0] + "\n");
if ( availLanguageDict[j][1] == id) {
//title =
dump("found title for:" + id + " ==> " + availLanguageDict[j][0] + "\n");
return availLanguageDict[j][0];
}
}
return '';
}
function GetLanguageVisibility(id)
{
dump("looking up visibility for:" + id + "\n");
if (availLanguageDict) for (j = 0; j < availLanguageDict.length; j++) {
//dump("ID:" + availLanguageDict[j][1] + " ==> " + availLanguageDict[j][2] + "\n");
if ( availLanguageDict[j][1] == id) {
//title =
dump("found visibility for:" + id + " ==> " + availLanguageDict[j][2] + "\n");
return availLanguageDict[j][2];
}
}
return false;
}
function AddRemoveLatin1(action)
{
try {
arrayOfPrefs = languages_pref_string.split(', ');
}
catch (ex) {
dump("failed to split the preference string!\n");
}
if (arrayOfPrefs) for (i = 0; i < arrayOfPrefs.length; i++) {
str = arrayOfPrefs[i];
if (str == 'iso-8859-1') {
if (action == 'remove') {
arrayOfPrefs[i]=arrayOfPrefs[arrayOfPrefs.length-1];
arrayOfPrefs.length = arrayOfPrefs.length - 1;
}
languages_pref_string = arrayOfPrefs.join(', ');
return;
}
} //for
if (action == 'add') {
arrayOfPrefs[arrayOfPrefs.length]= 'iso-8859-1';
languages_pref_string = arrayOfPrefs.join(', ');
}
}
function LoadActiveLanguages()
{
activeLanguageList = new Array();
var active_languages = document.getElementById('active_languages');
var active_languages_treeroot = document.getElementById('active_languages_root');
var visible;
dump("Loading: " + languages_pref_string + "!\n");
//dump("Loading: " + prefwindow_proxy_object.value + "!\n");
try {
arrayOfPrefs = languages_pref_string.split(', ');
arrayOfPrefs = prefwindow_proxy_object.value.split(', ');
}
catch (ex) {
@ -356,278 +249,167 @@ function LoadActiveLanguages()
tit = GetLanguageTitle(str);
if (str) if (tit) {
dump("Adding Active Language: " + str + " ==> " + tit + "\n");
// Create a treerow for the new Language
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
// Copy over the attributes
cell.setAttribute('value', tit);
cell.setAttribute('id', str);
// Add it to the active languages tree
item.appendChild(row);
row.appendChild(cell);
active_languages_treeroot.appendChild(item);
dump("*** Added Active Language: " + tit + "\n");
AddTreeItem(document, active_languages_treeroot, str, tit);
} //if
} //for
}
function LoadActiveLanguages2()
function LangAlreadyActive(langId)
{
try {
activeLanguageList = new Array();
var active_languages = document.getElementById('available_languages');
var active_languages_treeroot = document.getElementById('available_languages_root');
var visible;
if (prefwindow_proxy_object.value.indexOf(langId) != -1)
return true;
else
return false;
}
catch (ex) {
dump("Failed to initialize variables\n");
catch(ex){
return false;
}
dump("Loading: " + languages_pref_string + "!\n");
try {
arrayOfPrefs = languages_pref_string.split(', ');
}
catch (ex) {
dump("failed to split the preference string!\n");
}
if (arrayOfPrefs) for (i = 0; i < arrayOfPrefs.length; i++) {
str = arrayOfPrefs[i];
tit = GetLanguageTitle(str);
if (str) if (tit) {
dump("Adding Active Language: " + str + " ==> " + tit + "\n");
// Create a treerow for the new Language
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
// Copy over the attributes
cell.setAttribute('value', tit);
cell.setAttribute('id', str);
// Add it to the active languages tree
item.appendChild(row);
row.appendChild(cell);
active_languages_treeroot.appendChild(item);
dump("*** Added Active Language: " + tit + "\n");
} //if
} //for
}
function SelectAvailableLanguage()
{
//Remove the selection in the active languages list
var active_languages = document.getElementById('active_languages');
if (active_languages.selectedCells.length > 0)
active_languages.clearCellSelection();
if (active_languages.selectedItems.length > 0)
active_languages.clearItemSelection();
enable_add_button();
} //SelectAvailableLanguage
function enable_remove_button()
{
var remove_button = document.getElementById('remove_button');
remove_button.setAttribute('disabled','false');
}
function enable_save()
{
var save_button = document.getElementById('save_button');
save_button.setAttribute('disabled','false');
}
function enable_add_button()
{
var add_button = document.getElementById('add_button');
add_button.setAttribute('disabled','false');
}
function AddActiveLanguage(availSelected)
{
dump("!!!!!! AddActiveLanguage receiving: " + availSelected);
}
function AddAvailableLanguage()
{
var Languagename = new String();
var Languageid = new String();
var active_languages = window.opener.document.getElementById('active_languages');
var active_languages_treeroot = window.opener.document.getElementById('active_languages_root');
var available_languages = document.getElementById('available_languages');
//selected languages
for (var nodeIndex=0; nodeIndex < available_languages.selectedItems.length; nodeIndex++) {
var selItem = available_languages.selectedItems[nodeIndex];
var selRow = selItem.firstChild;
var selCell = selRow.firstChild;
var Languagename = selCell.getAttribute('value');
var Languageid = selCell.getAttribute('id');
var already_active = false;
Languagename = selCell.getAttribute('value');
Languageid = selCell.getAttribute('id');
already_active = false;
if (!LangAlreadyActive(Languageid)) {
AddTreeItem(window.opener.document, active_languages_treeroot, Languageid, Languagename);
for (var item = active_languages_treeroot.firstChild; item != null; item = item.nextSibling) {
var row = item.firstChild;
var cell = row.firstChild;
var active_Languageid = cell.getAttribute('id');
if (active_Languageid == Languageid) {
already_active = true;
break;
}
}
if (already_active == false) {
// Create a treerow for the new Language
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
var cell = document.createElement('treecell');
// Copy over the attributes
cell.setAttribute('value', Languagename);
cell.setAttribute('id', Languageid);
// Add it to the active languages tree
item.appendChild(row);
row.appendChild(cell);
active_languages_treeroot.appendChild(item);
// Select is only if the caller wants to.
active_languages.selectItem(item);
active_languages.ensureElementIsVisible(item);
}//add new item
}//if
} //loop selected languages
available_languages.clearItemSelection();
window.close();
} //AddAvailableLanguage
function AddAvailableLanguageNew()
{
var available_languages = document.getElementById('available_languages');
var availSelected = new Array();
//user-defined languages
var otherField = document.getElementById( "languages.other" );
for (var nodeIndex=0; nodeIndex < available_languages.selectedItems.length; nodeIndex++) {
if (otherField.value) {
dump("Other field: " + otherField.value + "\n");
Languageid = otherField.value;
Languageid = Languageid.toLowerCase();
Languagename = GetLanguageTitle(Languageid);
already_active = false;
var selItem = available_languages.selectedItems[nodeIndex];
var selRow = selItem.firstChild;
var selCell = selRow.firstChild;
if (!LangAlreadyActive(Languageid)) {
var Languagename = selCell.getAttribute('value');
var Languageid = selCell.getAttribute('id');
AddTreeItem(window.opener.document, active_languages_treeroot, Languageid, Languagename);
availSelected[nodeIndex] = new Array(1);
availSelected[nodeIndex][0] = Languagename;
availSelected[nodeIndex][1] = Languageid;
} //loop selected languages
}//if
}
available_languages.clearItemSelection();
enable_save();
dump("********** AddAvailableLanguage returning "+availSelected+"\n");
window.returnValue = availSelected;
dump (window.opener);
UpdatePrefString();
window.close();
return(availSelected);
} //AddAvailableLanguage
function RemoveActiveLanguage()
{
var active_languages_treeroot = document.getElementById('active_languages_root');
var tree = document.getElementById('active_languages');
var nextNode = null;
var numSelected = tree.selectedItems.length;
var numSelected = active_languages.selectedItems.length;
var deleted_all = false;
while (tree.selectedItems.length > 0) {
while (active_languages.selectedItems.length > 0) {
var selectedNode = tree.selectedItems[0];
var selectedNode = active_languages.selectedItems[0];
nextNode = selectedNode.nextSibling;
if (!nextNode)
if (selectedNode.previousSibling)
if (selectedNode.previousSibling)
nextNode = selectedNode.previousSibling;
var row = selectedNode.firstChild;
var cell = row.firstChild;
row.removeChild(cell);
selectedNode.removeChild(row);
row.removeChild(cell);
selectedNode.removeChild(row);
active_languages_treeroot.removeChild(selectedNode);
} //while
if (nextNode) {
tree.selectItem(nextNode)
active_languages.selectItem(nextNode)
} else {
//tree.clearItemSelection();
//active_languages.clearItemSelection();
}
enable_save();
UpdatePrefString();
} //RemoveActiveLanguage
function Save()
function GetLanguageTitle(id)
{
if (availLanguageDict) for (j = 0; j < availLanguageDict.length; j++) {
// Iterate through the 'active languages tree to collect the languages
// that the user has chosen.
if ( availLanguageDict[j][1] == id) {
//title =
dump("found title for:" + id + " ==> " + availLanguageDict[j][0] + "\n");
return availLanguageDict[j][0];
}
}
return '';
}
dump('Entering Save() function.\n');
var active_languages = document.getElementById('active_languages');
var active_languages_treeroot = document.getElementById('active_languages_root');
var row = null;
var cell = null;
var languageid = new String();
function AddTreeItem(doc, treeRoot, langID, langTitle)
{
try { //let's beef up our error handling for languages without label / title
// Create a treerow for the new Language
var item = doc.createElement('treeitem');
var row = doc.createElement('treerow');
var cell = doc.createElement('treecell');
// Copy over the attributes
cell.setAttribute('value', langTitle);
cell.setAttribute('id', langID);
// Add it to the active languages tree
item.appendChild(row);
row.appendChild(cell);
treeRoot.appendChild(item);
dump("*** Added tree item: " + langTitle + "\n");
} //try
catch (ex) {
dump("*** Failed to add item: " + langTitle + "\n");
} //catch
}
function UpdatePrefString()
{
var num_languages = 0;
languages_pref_string = '';
dump("*** UpdatePrefString()\n");
for (var item = active_languages_treeroot.firstChild; item != null; item = item.nextSibling) {
@ -635,67 +417,89 @@ function Save()
cell = row.firstChild;
languageid = cell.getAttribute('id');
if (languageid.length > 1) {
num_languages++;
if (languageid.length > 1) {
num_languages++;
//separate >1 languages by commas
if (num_languages > 1) {
languages_pref_string = languages_pref_string + "," + " " + languageid;
} else {
languages_pref_string = languageid;
}
//separate >1 languages by commas
if (num_languages > 1) {
prefwindow_proxy_object.value = prefwindow_proxy_object.value + "," + " " + languageid;
} else {
prefwindow_proxy_object.value = languageid;
} //if
} //if
}//for
dump("*** Pref string set to: " + prefwindow_proxy_object.value + "\n");
}
function Save()
{
// Iterate through the 'active languages tree to collect the languages
// that the user has chosen.
dump('*** Save()\n');
var row = null;
var cell = null;
var languageid = new String();
UpdatePrefString();
//Save Prefs
try
{
if (!prefInt) {
prefInt = Components.classes["component://netscape/preferences"];
if (prefInt) {
prefInt = prefInt.getService();
prefInt = prefInt.QueryInterface(Components.interfaces.nsIPref);
}
}
}
}
try
{
if (prefInt)
{
//AddRemoveLatin1('remove');
prefInt.SetCharPref("intl.charset_menu.static", languages_pref_string);
//prefInt.SetCharPref("browser.startup.homepage", languages_pref_string);
//prefInt.CopyCharPref("intl.charset_menu.static", languages_pref_string);
//prefInt.SetCharPref("browser.startup.homepage", "www.betak.net");
confirm_text = document.getElementById('confirm_text');
dump('intl.charset_menu.static set to ' + languages_pref_string + '.\n');
window.close();
confirm(confirm_text.getAttribute('value'));
prefInt.SetCharPref("intl.accept_languages", prefwindow_proxy_object.value);
dump('*** saved pref: ' + prefwindow_proxy_object.value + '.\n');
}
}
window.close();
}
catch(ex)
{
confirm('exception' + ex);
//prefInt.SetDefaultCharPref("intl.charset_menu.static", "iso-8859-1, iso-2022-jp, shift_jis, euc-jp");
}
catch(ex)
{
dump("*** Couldn't save!\n");
window.close();
}
} //Save
function MoveUp() {
var tree = document.getElementById('active_languages');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (active_languages.selectedItems.length == 1) {
var selected = active_languages.selectedItems[0];
var before = selected.previousSibling
if (before) {
before.parentNode.insertBefore(selected, before);
tree.selectItem(selected);
tree.ensureElementIsVisible(selected);
active_languages.selectItem(selected);
active_languages.ensureElementIsVisible(selected);
}
}
enable_save();
UpdatePrefString();
} //MoveUp
function MoveDown() {
var tree = document.getElementById('active_languages');
if (tree.selectedItems.length == 1) {
var selected = tree.selectedItems[0];
if (active_languages.selectedItems.length == 1) {
var selected = active_languages.selectedItems[0];
if (selected.nextSibling) {
if (selected.nextSibling.nextSibling) {
selected.parentNode.insertBefore(selected, selected.nextSibling.nextSibling);
@ -703,9 +507,10 @@ function MoveDown() {
else {
selected.parentNode.appendChild(selected);
}
tree.selectItem(selected);
active_languages.selectItem(selected);
}
}
enable_save();
UpdatePrefString();
} //MoveDown

View File

@ -19,55 +19,68 @@
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/sidebar/customize.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-languages2.dtd" >
<window
<window id="langPanel"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="main-box"
title="&languages.customize.title.label;"
class="dialog"
windowtype="sidebar:customize"
onload="InitActive();"
align="vertical"
persist="width height"
width="500" height="381">
class="color-dialog"
title="&languages.customize.window.title;"
onload="Init();">
orient="vertical">
<html:script language="javascript" src="pref-languages.js"/>
<html:script language="javascript" src="chrome://global/content/strres.js"/>
<script language="javascript" src="chrome://communicator/content/pref/pref-languages.js"></script>
<script language="javascript" src="chrome://global/content/strres.js"></script>
<script language="JavaScript">
<![CDATA[
_elementIDs = ["intlAcceptLanguages"];
]]>
</script>
<box type="smallheader"
title="&languages.customize.lHeader;"
description="&languages.customize.rHeader;"/>
id="confirm_text"
value="&languages.customize.save.popup;"/>
<broadcaster id="intlAcceptLanguages"
value="" pref="true"
preftype="string"
prefstring="intl.accept_languages"
prefattribute="value"
wsm_persist="true"/>
<!-- The main pane -->
<!-- horz 1 -->
<box align="horizontal" flex="100%">
<!-- vert 0 -->
<box align="vertical" flex="100%">
<box class="box-smallheader" title="&languages.customize.lHeader;"/>
<!--
description="&languages.customize.rHeader;
-->
<!-- Spacing between the left window border and list box -->
<spring style="width:2em"/>
<!-- The main pane -->
<!-- horz 1 -->
<box align="horizontal" flex="100%">
<!-- Spacing between the left window border and list box -->
<spring style="width:2em"/>
<!-- Active client languages:
list box, reorder, add and remove widgets -->
<!-- vert 1 -->
<box align="vertical" flex="1">
<!-- vert 1 -->
<box align="vertical" flex="1">
<spring style="height:4px"/>
<html:div class="vertical-gap">
&languages.customize.prefLangDescript;
</html:div>
<box align="horizontal" flex="0">
<html class="label" style="width: 370px;">
&languages.customize.prefLangDescript;
</html>
</box>
<spring style="height:8px"/>
<separator/>
<html>
&languages.customize.active.label;
</html>
<!-- horz 2 -->
<box align="horizontal" class="box-group" flex="1">
<!-- horz 2 -->
<box align="horizontal" class="box-group" flex="1">
<!-- Languages list box -->
<!-- Active Charsets Tree -->
@ -76,66 +89,60 @@
indent="false"
multiple="true"
style="height:0px">
<!-- We explicitly create a 'treechildren' so we can refer
<!-- We explicitly create a 'treechildren' so we can refer
to it from the script -->
<treechildren id="active_languages_root">
</treechildren>
<treechildren id="active_languages_root">
</treechildren>
</tree>
<!-- Spacing between the right selector and "Reorder" -->
<spring style="width:8px"/>
<spring style="width:4px"/>
<!-- The Reorder Buttons -->
<!-- vert 2 -->
<box align="vertical">
<spring flex="50%"/>
<titledbutton onclick="MoveUp();" id="up" class="borderless up" />
<html:div>
&languages.customize.reorder.label;
</html:div>
<titledbutton onclick="MoveDown();" id="down"
class="borderless down" />
<spring flex="50%"/>
<spring flex="50%"/>
<box autostretch="never">
<button onclick="MoveUp();" id="up" class="up small" />
</box>
<!--
<html>
&languages.customize.reorder.label;
</html>
-->
<box autostretch="never">
<button onclick="MoveDown();" id="down" class="down small" />
</box>
<spring flex="50%"/>
</box>
<!-- vert 2 -->
<!-- The Add/Remove Buttons -->
<!-- vert 3 -->
<box align="vertical">
<titledbutton class="dialog push" value="&languages.customize.addButton.label;" onclick="AddLanguage();"/>
<titledbutton class="dialog push" value="&languages.customize.deleteButton.label;" onclick="RemoveActiveLanguage();"/>
<button class="dialog push" value="&languages.customize.addButton.label;" onclick="AddLanguage();"/>
<button class="dialog push" value="&languages.customize.deleteButton.label;" onclick="RemoveActiveLanguage();"/>
<button class="dialog push" value="&languages.customize.save.label;" onclick="Save();"/>
<button class="dialog push" value="&languages.customize.cancel.label;" onclick="window.close();"/>
</box>
<!-- vert 3 -->
</box>
<!-- horiz 2 -->
</box>
<!-- horiz 2 -->
<spring style="height:8px"/>
<spring style="height:8px"/>
</box>
<!-- vert 1 -->
</box>
<!-- vert 1 -->
</box>
<!-- horiz 1 -->
</box>
<!-- horiz 1 -->
<!-- vert 0 -->
<html:div>
<html:hr />
</html:div>
<!-- The 'Save' and 'Cancel' buttons -->
<!-- horz 2 -->
<box align="horizontal">
<spring flex="48%"/>
<titledbutton id="save_button" onclick="Save();"
class="dialog push"
value="&languages.customize.save.label;"/>
<spring flex="4%"/>
<titledbutton onclick="window.close()"
class="dialog push"
value="&languages.customize.cancel.label;" />
<spring flex="48%"/>
</box>
<!-- horz 2 -->
</window>

View File

@ -72,7 +72,7 @@
<treechildren>
<treeitem>
<treerow>
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-languages.xul" value="&languages.label;"/>
<treecell class="treecell-indent" url="chrome://communicator/content/pref/pref-languages2.xul" value="&languages.label;"/>
</treerow>
</treeitem>
<treeitem>

View File

@ -1,28 +1,35 @@
<!-- LOCALIZATION NOTE : FILE 'Languages' preferences dialog -->
<!ENTITY languages.customize.prefLangDescript "Choose in order of preference the language(s)
in which you prefer to view web pages. Web pages are sometimes
available in several languages. Navigator presents pages in
the available language you most prefer.">
<!ENTITY languages.customize.prefLangDescript "Choose in order of preference the language(s)
in which you prefer to view web pages. Web
pages are sometimes available in several
languages. Navigator presents pages in the
available language you most prefer.">
<!ENTITY languages.customize.window.title "Languages">
<!ENTITY languages.customize.lHeader "Languages">
<!ENTITY languages.customize.rHeader "Languages in which webpages are displayed">
<!ENTITY languages.customize.prefAddLangDescript "Select the languege you would like to add.">
<!ENTITY languages.customize.prefAddLangDescript "Select the language(s) you would like to add.">
<!ENTITY languages.customize.engOrder.label "1">
<!ENTITY languages.customize.engOption.label "English">
<!ENTITY languages.customize.addButton.label "Add...">
<!ENTITY languages.customize.deleteButton.label "Delete...">
<!ENTITY languages.customize.title.label "Customize Languages">
<!ENTITY languages.customize.add.title.label "Add Languages">
<!ENTITY languages.customize.left.header "Character Coding">
<!ENTITY languages.customize.right.header "Select Supported Charsets">
<!ENTITY languages.customize.current.label "Languages:">
<!ENTITY languages.customize.title.label "Customize Languages">
<!ENTITY languages.customize.add.title.label "Add Languages">
<!ENTITY languages.customize.left.header "Character Coding">
<!ENTITY languages.customize.right.header "Select Supported Charsets">
<!ENTITY languages.customize.available.label "Languages:">
<!ENTITY languages.customize.active.label "Languages in order of preference:">
<!ENTITY languages.customize.reorder.label "Reorder">
<!ENTITY languages.customize.remove.label "Remove">
<!ENTITY languages.customize.additional.label "Available Charactersets">
<!ENTITY languages.customize.add.label "Add">
<!ENTITY languages.customize.others.label "Others:">
<!ENTITY languages.customize.cancel.label "Cancel">
<!-- LOCALIZATION NOTE Charset Coding Preferences Dialog: Do NOT localize the terms "en-bz, ar-jo" -->
<!ENTITY languages.customize.others.examples "e.g.: en-bz, ar-jo">
<!ENTITY languages.customize.cancel.label "Cancel">
<!ENTITY languages.customize.save.label "Save">
<!ENTITY languages.customize.ok.label "OK">
<!ENTITY languages.customize.save.popup "Please restart the browser for changes to take effect...">
<!ENTITY languages.customize.moveUp.label "Up">
<!ENTITY languages.customize.moveUp.accesskey "u">
<!ENTITY languages.customize.moveDown.label "Down">
<!ENTITY languages.customize.moveDown.accesskey "d">