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 pref-diskspace.xul
AccountWizard.xul AccountWizard.xul
AccountWizard.js AccountWizard.js
aw-wizardAdapter.js
aw-accounttype.xul aw-accounttype.xul
aw-accounttype.js aw-accounttype.js
aw-identity.xul aw-identity.xul

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

@ -61,6 +61,7 @@ CHROME_CONTENT = \
pref-diskspace.xul \ pref-diskspace.xul \
AccountWizard.xul \ AccountWizard.xul \
AccountWizard.js \ AccountWizard.js \
aw-wizardAdapter.js \
aw-accounttype.xul \ aw-accounttype.xul \
aw-accounttype.js \ aw-accounttype.js \
aw-identity.xul \ 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 * The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file * License Version 1.1 (the "License"); you may not use this file
@ -24,9 +24,35 @@
function onInit() { function onInit() {
fixLabels(document.getElementById("ispBox")); 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. // this is a workaround for a template shortcoming.
// basically: templates can't set the "id" attribute on a node, so we // basically: templates can't set the "id" attribute on a node, so we
@ -36,58 +62,61 @@ function fixLabels(box) {
if (!box) return; if (!box) return;
var child = box.firstChild; var child = box.firstChild;
dump("starting looking with " + child + "\n");
var haveDynamicInputs = false; var haveDynamicInputs = false;
while (child) { 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" && dump("found child: " + child + "\n");
label.localName.toLowerCase() == "label") { if (child.localName.toLowerCase() == "radio") {
dump("Found dynamic inputs!\n");
var fakeid = input.getAttribute("fakeid"); haveDynamicInputs = true;
if (fakeid && fakeid != "") {
input.setAttribute("id", fakeid);
dump("Found dynamic inputs!\n");
haveDynamicInputs = true;
}
}
} }
child = child.nextSibling; child = child.nextSibling;
} }
if (haveDynamicInputs) { if (haveDynamicInputs) {
var subButtons = document.getElementById("mailSubButtons"); var subButtons = document.getElementById("ispchoice");
dump("hiding " + subButtons + "\n"); dump("** Have dynamic inputs: showing " + subButtons + "\n");
subButtons.removeAttribute("hidden"); subButtons.removeAttribute("hidden");
var otherIspRadio = document.getElementById("otherIspRadio");
dump("** Also showing the other ISP button\n");
otherIspRadio.removeAttribute("hidden");
} }
} }
function onMailChanged(event) { function onTypeChanged() {
// enableControls(document.getElementById("ispBox"), var ispBox = document.getElementById("ispBox");
// event.target.checked);
var mailaccount = document.getElementById("mailaccount");
enableControls(ispBox, mailaccount.checked);
} }
function enableControls(node, enabled) function enableControls(container, enabled)
{ {
var localName = node.localName.toLowerCase(); if (!container) return;
if (localName == "input" || localName == "label") { var child = container.firstChild;
if (enabled)
node.setAttribute("disabled", "true");
else
node.removeAttribute("disabled");
}
var child = node.firstChild();
while (child) { while (child) {
enableIspButtons(child, enabled); enableIspButtons(child, enabled);
child = child.nextSibling; 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() { function onUnload() {
dump("OnUnload!\n");
parent.UpdateWizardMap(); parent.UpdateWizardMap();
initializeIspData(); initializeIspData();
@ -105,21 +134,21 @@ function initializeIspData()
var ispName; var ispName;
// now reflect the datasource up into the parent // 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++) { for (var i=0; i<controls.length ;i++) {
var formElement = controls[i]; var formElement = controls[i];
if (formElement.name == "ispchoice" && if (formElement.getAttribute("group") == "ispchoice" &&
formElement.checked) { formElement.checked) {
dump("ispName = " + formElement.parentNode.id + "\n"); dump("ispName = " + formElement.id + "\n");
ispName = formElement.parentNode.id; ispName = formElement.id;
break; break;
} }
} }
dump("initializing ISP data for " + ispName + "\n");
if (!ispName || ispName == "") return; if (!ispName || ispName == "") return;
dump("initializing ISP data for " + ispName + "\n");
parent.PrefillAccountForIsp(ispName); parent.PrefillAccountForIsp(ispName);
parent.UpdateWizardMap(); parent.UpdateWizardMap();

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

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