fix for #29568 - automatically disable other ISP accounts when newsgroup is selected

(skinned to make it work) r=putterman
This commit is contained in:
alecf%netscape.com 2000-07-07 22:33:45 +00:00
Родитель 4f9e090be4
Коммит 50a81aecec
6 изменённых файлов: 189 добавлений и 69 удалений

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

@ -51,6 +51,7 @@ custreceipt.xul
pref-diskspace.xul
AccountWizard.xul
AccountWizard.js
aw-wizardAdapter.js
aw-accounttype.xul
aw-accounttype.js
aw-identity.xul

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

@ -61,6 +61,7 @@ CHROME_CONTENT = \
pref-diskspace.xul \
AccountWizard.xul \
AccountWizard.js \
aw-wizardAdapter.js \
aw-accounttype.xul \
aw-accounttype.js \
aw-identity.xul \

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- Mode: Java; 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
@ -24,9 +24,35 @@
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
@ -36,58 +62,61 @@ function fixLabels(box) {
if (!box) return;
var child = box.firstChild;
dump("starting looking with " + child + "\n");
var haveDynamicInputs = false;
while (child) {
dump("Checking <" + child.localName + ">\n");
if (child.localName.toLowerCase() == "box") {
var input = child.childNodes[0];
var label = child.childNodes[1];
if (input.localName.toLowerCase() == "input" &&
label.localName.toLowerCase() == "label") {
var fakeid = input.getAttribute("fakeid");
if (fakeid && fakeid != "") {
input.setAttribute("id", fakeid);
dump("Found dynamic inputs!\n");
haveDynamicInputs = true;
}
}
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("mailSubButtons");
dump("hiding " + subButtons + "\n");
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 onMailChanged(event) {
// enableControls(document.getElementById("ispBox"),
// event.target.checked);
function onTypeChanged() {
var ispBox = document.getElementById("ispBox");
var mailaccount = document.getElementById("mailaccount");
enableControls(ispBox, mailaccount.checked);
}
function enableControls(node, enabled)
function enableControls(container, enabled)
{
var localName = node.localName.toLowerCase();
if (localName == "input" || localName == "label") {
if (enabled)
node.setAttribute("disabled", "true");
else
node.removeAttribute("disabled");
}
var child = node.firstChild();
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");
}
function onUnload() {
dump("OnUnload!\n");
parent.UpdateWizardMap();
initializeIspData();
@ -105,21 +134,21 @@ function initializeIspData()
var ispName;
// now reflect the datasource up into the parent
var controls = document.controls;
var controls = document.getElementsByAttribute("wsm_persist", "true");
for (var i=0; i<controls.length ;i++) {
var formElement = controls[i];
if (formElement.name == "ispchoice" &&
if (formElement.getAttribute("group") == "ispchoice" &&
formElement.checked) {
dump("ispName = " + formElement.parentNode.id + "\n");
ispName = formElement.parentNode.id;
dump("ispName = " + formElement.id + "\n");
ispName = formElement.id;
break;
}
}
dump("initializing ISP data for " + ispName + "\n");
if (!ispName || ispName == "") return;
dump("initializing ISP data for " + ispName + "\n");
parent.PrefillAccountForIsp(ispName);
parent.UpdateWizardMap();

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

@ -24,49 +24,49 @@ Rights Reserved.
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/aw-accounttype.dtd" >
<window id="accounttype" xmlns:html="http://www.w3.org/1999/xhtml"
<window id="accounttype"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="dialog"
onload="parent.wizardManager.onPageLoad('accounttype');"
onload="dump('** acctype onload\n'); parent.wizardManager.onPageLoad('accounttype');"
orient="vertical"
onunload="onUnload();">
<script src="aw-accounttype.js"/>
<script src="aw-wizardAdapter.js"/>
<script src="resource:/res/samples/DumpDOM.js"/>
<box class="box-header" value="&accountTypeTitle.label;"/>
<html class="desc">&accountTypeDesc.label;</html>
<spring class="spacer"/>
<html class="desc">&accountTypeDirections.label;</html>
<box align="vertical">
<box>
<html:input type="radio" name="acctyperadio" id="mailaccount" onclick="onMailChanged(event);" value="mail" checked="1"/>
<html:label for="mailaccount">&accountTypeMail.label;</html:label>
</box>
<box orient="vertical" style="margin-left: 10px" id="mailSubButtons" hidden="true">
<box orient="vertical"
datasources="rdf:ispdefaults"
containment="http://home.netscape.com/NC-rdf#providers"
id="ispBox"
ref="NC:ispinfo">
<template>
<rule>
<box uri="...">
<html:input type="radio" name="ispchoice" value="rdf:http://home.netscape.com/NC-rdf#wizardShortName" fakeid="rdf:http://home.netscape.com/NC-rdf#wizardShortName"/>
<html:label for="rdf:http://home.netscape.com/NC-rdf#wizardShortName">
<text value="rdf:http://home.netscape.com/NC-rdf#wizardLongName"/>
</html:label>
<radiogroup align="vertical" name="acctyperadio" id="acctyperadio">
<radio id="mailaccount" group="acctyperadio"
wsm_persist="true"
oncommand="onTypeChanged()"
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"
id="ispBox"
ref="NC:ispinfo">
<template>
<radio group="ispchoice" uri="..."
wsm_persist="true"
fakeid="rdf:http://home.netscape.com/NC-rdf#wizardShortName"
value="rdf:http://home.netscape.com/NC-rdf#wizardLongName"/>
</template>
</box>
</rule>
</template>
</box>
<box id="otherIsp">
<html:input type="radio" name="ispchoice" value="otherIsp" id="otherIspRadio"/>
<html:label for="otherIspRadio">&accountTypeISP.label;</html:label>
</box>
</box>
<box>
<html:input type="radio" name="acctyperadio" id="newsaccount" value="news"/>
<html:label for="newsaccount">&accountTypeNews.label;</html:label>
</box>
</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()"
value="&accountTypeNews.label;"/>
</radiogroup>
</window>

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

@ -0,0 +1,88 @@
/* -*- Mode: Java; 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.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
*/
var gFieldList;
function GetFields()
{
dump("wizardAdapter: GetFields()\n");
if (!gFieldList)
gFieldList = document.getElementsByAttribute("wsm_persist", "true");
var fields = new Object;
for (var i=0; i<gFieldList.length; i++) {
var field=gFieldList[i];
if (field.parentNode.tagName == "template") continue;
dump(" for field <" + field.tagName + ">\n");
var obj = new Object;
obj.id = field.id;
if (field.tagName == "radio" ||
field.tagName == "checkbox")
obj.value = field.checked;
else if (field.tagName == "menulist")
obj.value = field.selectedItem.data;
else
obj.value = field.value;
dump(" returning " + obj.id + " and " + obj.value + " value=" + field.value + "\n");
fields[field.id] = obj;
}
return fields;
}
function SetFields(id, value)
{
dump("wizardAdapter: SetFields(" + id + ", " + value + ")\n");
var field = document.getElementById(id);
if (!field) {
dump(" Unknown field with id " + id + "\n");
dump(" Trying to find it in the ispbox \n");
var ispBox = document.getElementById("ispBox");
var fields = document.getElementsByAttribute("id", id);
if (!fields) {
dump("still couldn't find it!\n");
return;
} else
field = fields[0];
DumpDOM(ispBox);
return;
}
dump(" SetFields(<" + field.tagName + ">);\n");
if (field.tagName == "radio" ||
field.tagName == "checkbox")
field.checked = value;
else if (field.tagName == "menulist") {
var menuitems = field.getElementsByAttribute("data", value);
if (menuitems && menuitems.length)
field.selectedItem = menuitems[0];
}
else
field.value = value;
}

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

@ -54,6 +54,7 @@ CHROME_CONTENT = \
.\pref-diskspace.xul \
.\AccountWizard.xul \
.\AccountWizard.js \
.\aw-wizardAdapter.js \
.\aw-accounttype.xul \
.\aw-accounttype.js \
.\aw-identity.xul \