rewrite the first page of the account wizard to show a single level of radio
buttons instead of the old multi-level appearance
This commit is contained in:
alecf%netscape.com 2000-09-12 01:50:23 +00:00
Родитель 8fc4197f5b
Коммит 85cbadc95b
2 изменённых файлов: 24 добавлений и 132 удалений

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

@ -22,97 +22,8 @@
*/
function onInit() {
fixLabels(document.getElementById("ispBox"));
preselectRadioButtons();
onTypeChanged();
}
// this is a workaround for #44713 - I can't preselect radio buttons
// by marking them with checked="true"
function preselectRadioButtons()
{
try {
// select the first item in the outer group (mail account)
var radiogroup = document.getElementById("acctyperadio");
if (!radiogroup.selectedItem) {
radiogroup.selectedItem =
radiogroup.getElementsByAttribute("group", radiogroup.id)[0];
}
// select the last item in the inner group (other ISP)
radiogroup = document.getElementById("ispchoice");
if (!radiogroup.selectedItem) {
var radiobuttons =
radiogroup.getElementsByAttribute("group", radiogroup.id);
radiogroup.selectedItem = radiobuttons[radiobuttons.length-1];
}
} catch (ex) {
dump("Error preselecting a radio button: " + ex + "!\n");
}
}
// this is a workaround for a template shortcoming.
// basically: templates can't set the "id" attribute on a node, so we
// have to set "fakeid" and then transfer it manually
function fixLabels(box) {
dump("Fixing labels on " + box + "\n");
if (!box) return;
var child = box.firstChild;
dump("starting looking with " + child + "\n");
var haveDynamicInputs = false;
while (child) {
dump("found child: " + child + "\n");
if (child.localName.toLowerCase() == "radio") {
dump("Found dynamic inputs!\n");
haveDynamicInputs = true;
}
child = child.nextSibling;
}
if (haveDynamicInputs) {
var subButtons = document.getElementById("ispchoice");
dump("** Have dynamic inputs: showing " + subButtons + "\n");
subButtons.removeAttribute("hidden");
var otherIspRadio = document.getElementById("otherIspRadio");
dump("** Also showing the other ISP button\n");
otherIspRadio.removeAttribute("hidden");
}
}
function onTypeChanged() {
var ispBox = document.getElementById("ispBox");
var mailaccount = document.getElementById("mailaccount");
enableControls(ispBox, mailaccount.checked);
}
function enableControls(container, enabled)
{
if (!container) return;
var child = container.firstChild;
while (child) {
enableIspButtons(child, enabled);
child = child.nextSibling;
}
var otherIspRadio = document.getElementById("otherIspRadio");
enableIspButtons(otherIspRadio, enabled);
}
function enableIspButtons(child, enabled)
{
dump("disabling " + child.id + "\n");
if (enabled)
child.removeAttribute("disabled");
else
child.setAttribute("disabled", "true");
// select the first radio button
document.getElementById("mailaccount").checked=true;
}
function onUnload() {
@ -129,22 +40,12 @@ function initializeIspData()
{
if (!document.getElementById("mailaccount").checked) {
parent.SetCurrentAccountData(null);
return;
}
var ispName;
// now reflect the datasource up into the parent
var controls = document.getElementsByAttribute("wsm_persist", "true");
var accountSelection = document.getElementById("acctyperadio");
for (var i=0; i<controls.length ;i++) {
var formElement = controls[i];
if (formElement.getAttribute("group") == "ispchoice" &&
formElement.checked) {
dump("ispName = " + formElement.id + "\n");
ispName = formElement.id;
break;
}
}
var ispName = accountSelection.selectedItem.id;
dump("initializing ISP data for " + ispName + "\n");

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

@ -27,7 +27,7 @@ Rights Reserved.
<window id="accounttype"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:nc="http://home.netscape.com/NC-rdf#"
class="dialog"
class="color-dialog"
onload="dump('** acctype onload\n'); parent.wizardManager.onPageLoad('accounttype');"
orient="vertical"
onunload="onUnload();">
@ -40,13 +40,12 @@ Rights Reserved.
<spring class="spacer"/>
<html class="desc">&accountTypeDirections.label;</html>
<radiogroup align="vertical" name="acctyperadio" id="acctyperadio">
<radio id="mailaccount" group="acctyperadio"
wsm_persist="true"
oncommand="onTypeChanged()"
<radiogroup orient="vertical"
name="acctyperadio" id="acctyperadio" >
<radio id="mailaccount" group="acctyperadio" data="mailaccount"
checked="true"
value="&accountTypeMail.label;"/>
<radiogroup orient="vertical" style="margin-left: 10px"
id="ispchoice" >
<box orient="vertical"
datasources="rdf:ispdefaults"
containment="http://home.netscape.com/NC-rdf#providers"
@ -54,21 +53,13 @@ Rights Reserved.
ref="NC:ispinfo">
<template>
<rule nc:wizardShow="true">
<radio group="ispchoice" uri="..."
wsm_persist="true"
fakeid="rdf:http://home.netscape.com/NC-rdf#wizardShortName"
<radio group="acctyperadio" uri="..."
data="rdf:http://home.netscape.com/NC-rdf#wizardShortName"
value="rdf:http://home.netscape.com/NC-rdf#wizardLongName"/>
</rule>
</template>
</box>
<radio group="ispchoice" value="&accountTypeISP.label;"
wsm_persist="true" hidden="true"
id="otherIspRadio"/>
</radiogroup>
<radio group="acctyperadio" id="newsaccount"
wsm_persist="true"
oncommand="onTypeChanged()"
<radio group="acctyperadio" id="newsaccount" data="newsaccount"
value="&accountTypeNews.label;"/>
</radiogroup>
</window>