From 50a81aecec4d297ac9f7c9293c98fcf2d069b185 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Fri, 7 Jul 2000 22:33:45 +0000 Subject: [PATCH] fix for #29568 - automatically disable other ISP accounts when newsgroup is selected (skinned to make it work) r=putterman --- .../base/prefs/resources/content/MANIFEST | 1 + .../base/prefs/resources/content/Makefile.in | 1 + .../prefs/resources/content/aw-accounttype.js | 101 +++++++++++------- .../resources/content/aw-accounttype.xul | 66 ++++++------ .../resources/content/aw-wizardAdapter.js | 88 +++++++++++++++ .../base/prefs/resources/content/makefile.win | 1 + 6 files changed, 189 insertions(+), 69 deletions(-) create mode 100644 mailnews/base/prefs/resources/content/aw-wizardAdapter.js diff --git a/mailnews/base/prefs/resources/content/MANIFEST b/mailnews/base/prefs/resources/content/MANIFEST index 7816736b633a..6cb1f0dd368f 100644 --- a/mailnews/base/prefs/resources/content/MANIFEST +++ b/mailnews/base/prefs/resources/content/MANIFEST @@ -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 diff --git a/mailnews/base/prefs/resources/content/Makefile.in b/mailnews/base/prefs/resources/content/Makefile.in index d4513f7a0aad..fa0f97092c8b 100644 --- a/mailnews/base/prefs/resources/content/Makefile.in +++ b/mailnews/base/prefs/resources/content/Makefile.in @@ -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 \ diff --git a/mailnews/base/prefs/resources/content/aw-accounttype.js b/mailnews/base/prefs/resources/content/aw-accounttype.js index c824e659c47b..8755d53a926e 100644 --- a/mailnews/base/prefs/resources/content/aw-accounttype.js +++ b/mailnews/base/prefs/resources/content/aw-accounttype.js @@ -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 -