b=28127 r=matt,ben,ftang,erik a=bobj Font prefs don't list all fonts - changed UI for Beta1 and fixed a radio-button problem in pref.js

This commit is contained in:
jbetak%netscape.com 2000-03-08 06:24:25 +00:00
Родитель 97c63bcd77
Коммит 242a3bb70c
4 изменённых файлов: 137 добавлений и 55 удалений

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

@ -6,17 +6,28 @@ fonts = enumerator.EnumerateAllFonts(fontCount);
generics = [
"serif",
// "sans-serif",
"sans-serif",
"cursive",
"fantasy",
"monospace"
];
selects = [
"serif",
"sans-serif",
// "cursive",
// "fantasy",
"monospace"
];
function startUp()
{
selectLangs = document.getElementById("selectLangs");
selectLangs.value = "x-western";
selectLang();
}
@ -116,44 +127,77 @@ function selectLang()
dump(fixedFont + "\n");
var faceList = new String();
var combinedFonts = new Array();
for (i = 0; i < generics.length; i++) {
var select = document.getElementById(generics[i]);
var selectParent = select.parentNode;
//create name of font prefstring
var fontPrefstring = 'font.name.' + generics[i] + '.' + lang;
select.setAttribute('prefstring', fontPrefstring);
//Clear the select list
ClearList(select);
for (i = 0; i < generics.length; i++) {
fonts = enumerator.EnumerateFonts(lang, generics[i], fontCount);
//Append to the select list. Build the new select list
for (j = 0; j < fonts.length; j++) {
AppendStringToList(select, fonts[j])
}
//Get the pref value of the font
var fixedFont = null;
try
{
if (pref)
{
var selectVal = pref.CopyUnicharPref(fontPrefstring);
}
}
catch(ex)
{
selectVal = fonts[0];
}
dump(fixedFont + "\n");
//select the value of the string
select.value = selectVal;
dump('select:' + select.getAttribute('prefstring') + "\n");
}
for (j = 0; j < fonts.length; j++) {
if (faceList.indexOf(fonts[j]+',') == -1) {
faceList += fonts[j]+',';
}
} //for fonts
} //for generics
//strip trailing delimiter
if (faceList.length > 0) faceList = faceList.substring(0,faceList.length-1);
dump('faceList: ' + faceList + '\n');
combinedFonts = faceList.split(',');
//sort serif and sans serif fonts
combinedFonts.sort();
dump('Combined fonts: \n');
for (i = 0; i < combinedFonts.length; i++) {
dump(combinedFonts[i] + '\n');
}
for (i = 0; i < selects.length; i++) {
var fontList = selects[i];
var select = document.getElementById(fontList);
//Clear the select list
ClearList(select);
//create name of font prefstring
var fontPrefstring = 'font.name.' + fontList + '.' + lang;
select.setAttribute('prefstring', fontPrefstring);
for (j = 0; j < combinedFonts.length; j++) {
AppendStringToList(select, combinedFonts[j]);
}
try
{
if (pref)
{
var selectVal = pref.CopyUnicharPref(fontPrefstring);
}
}
catch(ex)
{
selectVal = '';
}
//select the value of the string
select.value = selectVal;
dump('fontPrefstring:' + fontPrefstring + "\n");
dump('selectVal:' + selectVal + "\n");
dump('select:' + select.getAttribute('prefstring') + "\n");
} //for select
//set the value of the sizes
sizeVar.value = fontVarInt;
sizeFix.value = fontfixInt;

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

@ -65,6 +65,14 @@
<html:option value="ar">&font.langGroup.arabic;</html:option>
</html:select>
</html:td>
</html:tr>
<html:tr>
<html:td>&serif.select;</html:td>
<html:td>
<html:select class="Font" id="serif" pref="true" preftype="string" prefstring="">
</html:select>
</html:td>
<html:td>&varFont.select;</html:td>
<html:td>
@ -79,26 +87,17 @@
<html:option value="24" >24</html:option>
</html:select>
</html:td>
</html:tr>
<html:tr>
<html:td>&serif.select;</html:td>
<html:td>
<html:select class="Font" id="serif" pref="true" preftype="string">
</html:select>
</html:td>
</html:tr>
<!-- <html:tr>
<html:tr>
<html:td>&sans-serif.select;</html:td>
<html:td>
<html:select id="sans-serif" pref="true" preftype="string" prefstring="">
<html:select class="Font" id="sans-serif" pref="true" preftype="string" prefstring="">
</html:select>
</html:td>
</html:tr>
<html:tr>
<!-- <html:tr>
<html:td>&cursive.select;</html:td>
<html:td>
<html:select id="cursive" pref="true" preftype="string" prefstring="">
@ -135,10 +134,32 @@
</html:select>
</html:td>
</html:tr>
<html:tr>
<html:td>
<box align="vertical" flex="1">
<html:div class="vertical-gap">
</html:div>
</box>
</html:td>
</html:tr>
<html:tr>
<html:td>
<html:label>&default.type.label;</html:label>
</html:td>
<html:td>
<html:input name="DefaultFontRadio" type="radio" id="DefaultFontSerif" pref="true" prefindex="serif" preftype="string" prefstring="font.default"/>
<html:label for="DefaultFontSerif" accesskey="t" tabindex="0">
&useDefaultFontSerif;
</html:label>
<html:input name="DefaultFontRadio" type="radio" id="DefaultFontSansSerif" pref="true" prefindex="sans-serif" preftype="string" prefstring="font.default"/>
<html:label for="DefaultFontSansSerif" accesskey="t" tabindex="0">
&useDefaultFontSansSerif;
</html:label>
</html:td>
</html:tr>
</html:table>
</html:div>
</titledbox>
<!-- fonts with webpages -->
<titledbox orient="vertical">
<title><text value="&header2;"/></title>
@ -157,6 +178,4 @@
</html:label>
</html:div>
</titledbox>
</window>

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

@ -191,6 +191,7 @@ function PREF_ParsePref( elementID, elementObject )
case "int":
dump("*** elementObject.elType = " + elementObject.elType + "\n");
if( elementObject.elType.toLowerCase() == "radio" && !elementObject.value )
return false; // ignore, go to next
if( !elementObject.prefindex ) {
@ -227,14 +228,28 @@ function PREF_ParsePref( elementID, elementObject )
dump("*** empty string color pref was going to be set, but we're avoiding this just in the nick of time...\n");
break;
}
if( charPref != elementObject.value ) // do we care about whitespace?
if( elementObject.elType.toLowerCase() == "radio") {
if (!elementObject.value) {
return false; // ignore, go to next
}
else {
var prefvalue = elementObject.prefindex; // element object has prefindex attribute (e.g. radio buttons)
}
}
else {
var prefvalue = elementObject.value; // element object does not have a prefindex (e.g. select widgets)
}
if( charPref != prefvalue ) { // do we care about whitespace?
try {
whp.SetUnicharPref( elementObject.prefstring, elementObject.value ); // string pref
whp.SetUnicharPref( elementObject.prefstring, prefvalue ); // string pref
}
catch (ex) {
dump("*** failure when calling SetCharPref: " + ex + "\n");
dump("*** failure when calling SetUnicharPref: " + ex + "\n");
}
}
break;
default:
// TODO: insert implementation for other pref types;
break;

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

@ -10,7 +10,7 @@
<!ENTITY size.select "Size">
<!ENTITY fontsFor.select "Fonts for:">
<!ENTITY serif.select "Serif:">
<!ENTITY sans-serif.select "Sans-Serif:">
<!ENTITY sans-serif.select "Sans Serif:">
<!ENTITY monospace.select "Monospace:">
<!-- LOCALIZATION NOTE (fantasy.select): 'Fantasy' means 'Ornate' -->
<!ENTITY fantasy.select "Fantasy:">
@ -34,6 +34,10 @@
<!ENTITY size1.option "10">
<!ENTITY varFont.select "Variable Width Font:">
<!ENTITY fixedFont.Select "Fixed Width Font">
<!-- default font type -->
<!ENTITY default.type.label "Default Type:">
<!ENTITY useDefaultFontSerif "Serif">
<!ENTITY useDefaultFontSansSerif "Sans Serif">
<!-- LOCALIZATION NOTE (fixedFont.option): DONT_TRANSLATE -->
<!ENTITY fixedFont.option "Filler">
<!ENTITY header2 "When a webpage chooses its own fonts">