2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2000-04-29 00:55:44 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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/
|
2000-04-29 00:55:44 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
2000-04-29 00:55:44 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-04-29 00:55:44 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2001-01-05 03:37:30 +03:00
|
|
|
* Alec Flett <alecf@netscape.com>
|
2000-06-03 05:03:23 +04:00
|
|
|
* Ben Goodger <ben@netscape.com>
|
2001-01-05 03:37:30 +03:00
|
|
|
* Blake Ross <blakeross@telocity.com>
|
2002-02-02 01:18:59 +03:00
|
|
|
* Joe Hewitt <hewitt@netscape.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-04-29 00:55:44 +04:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
// parameters to gCommonDialogParam.Get() are defined in nsPIPromptService.idl
|
|
|
|
var gCommonDialogParam =
|
|
|
|
window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
|
|
|
|
|
|
|
|
function showControls()
|
|
|
|
{
|
|
|
|
// This is called before onload fires, so we can't be certain that any elements
|
|
|
|
// in the document have their bindings ready, so don't call any methods/properties
|
|
|
|
// here on xul elements that come from xbl bindings.
|
|
|
|
|
|
|
|
// show the required textboxes and set their initial values
|
|
|
|
var nTextBoxes = gCommonDialogParam.GetInt(3);
|
|
|
|
if (nTextBoxes == 2) {
|
|
|
|
if (gCommonDialogParam.GetInt(4) == 1) {
|
|
|
|
initTextbox("password1", 4, 6, false);
|
|
|
|
initTextbox("password2", 5, 7, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
initTextbox("login", 4, 6, false);
|
|
|
|
initTextbox("password1", 5, 7, false);
|
|
|
|
}
|
|
|
|
} else if (nTextBoxes == 1) {
|
|
|
|
if (gCommonDialogParam.GetInt(4) == 1)
|
|
|
|
initTextbox("password1", -1, 6, true);
|
|
|
|
else
|
|
|
|
initTextbox("login", 4, 6, true);
|
|
|
|
}
|
|
|
|
}
|
2000-11-03 01:15:41 +03:00
|
|
|
|
1999-08-11 03:29:43 +04:00
|
|
|
function commonDialogOnLoad()
|
|
|
|
{
|
2002-02-02 01:18:59 +03:00
|
|
|
// set the window title
|
|
|
|
window.title = gCommonDialogParam.GetString(12);
|
|
|
|
|
|
|
|
// set the number of command buttons
|
|
|
|
var nButtons = gCommonDialogParam.GetInt(2);
|
|
|
|
var dialog = document.documentElement;
|
|
|
|
switch (nButtons) {
|
|
|
|
case 1:
|
|
|
|
dialog.getButton("cancel").hidden = true;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
dialog.getButton("extra2").hidden = false;
|
|
|
|
case 3:
|
|
|
|
dialog.getButton("extra1").hidden = false;
|
|
|
|
}
|
2001-03-22 03:59:29 +03:00
|
|
|
|
2000-06-03 05:03:23 +04:00
|
|
|
// display the main text
|
2001-01-05 03:37:30 +03:00
|
|
|
var messageText = gCommonDialogParam.GetString(0);
|
2000-06-03 05:03:23 +04:00
|
|
|
var messageParent = document.getElementById("info.box");
|
|
|
|
var messageParagraphs = messageText.split("\n");
|
2001-03-22 03:59:29 +03:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
for (var i = 0; i < messageParagraphs.length; i++) {
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 07:17:02 +03:00
|
|
|
var descriptionNode = document.createElement("description");
|
2001-01-05 03:37:30 +03:00
|
|
|
var text = document.createTextNode(messageParagraphs[i]);
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 07:17:02 +03:00
|
|
|
descriptionNode.appendChild(text);
|
|
|
|
messageParent.appendChild(descriptionNode);
|
2001-01-05 03:37:30 +03:00
|
|
|
}
|
2001-03-22 03:59:29 +03:00
|
|
|
|
|
|
|
setElementText("info.header", gCommonDialogParam.GetString(3), true);
|
|
|
|
|
|
|
|
// set the icon
|
2000-06-03 05:03:23 +04:00
|
|
|
var iconElement = document.getElementById("info.icon");
|
2001-04-12 09:42:05 +04:00
|
|
|
var iconClass = gCommonDialogParam.GetString(2);
|
|
|
|
if (!iconClass)
|
|
|
|
iconClass = "message-icon";
|
|
|
|
iconElement.setAttribute("class", iconElement.getAttribute("class") + " " + iconClass);
|
2001-03-22 03:59:29 +03:00
|
|
|
|
2000-06-03 05:03:23 +04:00
|
|
|
// set the number of command buttons
|
2002-02-07 09:48:06 +03:00
|
|
|
nButtons = gCommonDialogParam.GetInt(2);
|
2001-01-05 03:37:30 +03:00
|
|
|
switch (nButtons) {
|
|
|
|
case 4:
|
2002-02-02 01:18:59 +03:00
|
|
|
document.documentElement.getButton("extra2").label = gCommonDialogParam.GetString(11);
|
2001-01-05 03:37:30 +03:00
|
|
|
// fall through
|
|
|
|
case 3:
|
2002-02-02 01:18:59 +03:00
|
|
|
document.documentElement.getButton("extra1").label = gCommonDialogParam.GetString(10);
|
2001-01-05 03:37:30 +03:00
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
case 2:
|
2001-11-29 23:52:48 +03:00
|
|
|
var string = gCommonDialogParam.GetString(8);
|
2001-01-05 03:37:30 +03:00
|
|
|
if (string)
|
2002-02-02 01:18:59 +03:00
|
|
|
document.documentElement.getButton("accept").label = string;
|
2001-01-05 03:37:30 +03:00
|
|
|
// fall through
|
|
|
|
case 1:
|
2001-11-29 23:52:48 +03:00
|
|
|
string = gCommonDialogParam.GetString(9);
|
2001-01-05 03:37:30 +03:00
|
|
|
if (string)
|
2002-02-02 01:18:59 +03:00
|
|
|
document.documentElement.getButton("cancel").label = string;
|
2001-01-05 03:37:30 +03:00
|
|
|
break;
|
|
|
|
}
|
2000-06-03 05:03:23 +04:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
// set default result to cancelled
|
|
|
|
gCommonDialogParam.SetInt(0, 1);
|
|
|
|
|
2000-06-03 05:03:23 +04:00
|
|
|
// initialize the checkbox
|
2000-11-03 01:15:41 +03:00
|
|
|
setCheckbox(gCommonDialogParam.GetString(1), gCommonDialogParam.GetInt(1));
|
2001-03-22 03:59:29 +03:00
|
|
|
|
2002-02-09 06:36:55 +03:00
|
|
|
getAttention();
|
2000-06-03 05:03:23 +04:00
|
|
|
}
|
2000-04-29 00:55:44 +04:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
function initTextbox(aName, aLabelIndex, aValueIndex, aAlwaysLabel)
|
|
|
|
{
|
|
|
|
unHideElementById(aName+"Container");
|
|
|
|
|
|
|
|
var label = aLabelIndex < 0 ? "" : gCommonDialogParam.GetString(aLabelIndex);
|
|
|
|
if (label || aAlwaysLabel && !label)
|
|
|
|
setElementText(aName+"Label", label);
|
|
|
|
|
|
|
|
var value = aValueIndex < 0 ? "" : gCommonDialogParam.GetString(aValueIndex);
|
|
|
|
var textbox = document.getElementById(aName + "Textbox");
|
|
|
|
textbox.setAttribute("value", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setElementText(aElementID, aValue, aChildNodeFlag)
|
|
|
|
{
|
|
|
|
var element = document.getElementById(aElementID);
|
|
|
|
if (!aChildNodeFlag && element)
|
|
|
|
element.setAttribute("value", aValue);
|
|
|
|
else if (aChildNodeFlag && element)
|
|
|
|
element.appendChild(document.createTextNode(aValue));
|
|
|
|
}
|
|
|
|
|
2001-01-05 03:37:30 +03:00
|
|
|
function setCheckbox(aChkMsg, aChkValue)
|
2000-06-03 05:03:23 +04:00
|
|
|
{
|
2001-03-22 03:59:29 +03:00
|
|
|
if (aChkMsg) {
|
2002-02-02 01:18:59 +03:00
|
|
|
// XXX Would love to use hidden instead of collapsed, but the checkbox
|
|
|
|
// fails to size itself properly when I do this.
|
|
|
|
document.getElementById("checkboxContainer").removeAttribute("collapsed");
|
|
|
|
|
2000-06-02 17:06:39 +04:00
|
|
|
var checkboxElement = document.getElementById("checkbox");
|
2001-03-22 03:59:29 +03:00
|
|
|
checkboxElement.label = aChkMsg;
|
2002-02-02 01:18:59 +03:00
|
|
|
checkboxElement.checked = aChkValue > 0;
|
2000-06-02 17:06:39 +04:00
|
|
|
}
|
2000-06-03 05:03:23 +04:00
|
|
|
}
|
2000-01-06 03:23:24 +03:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
function unHideElementById(aElementID)
|
2000-06-03 05:03:23 +04:00
|
|
|
{
|
|
|
|
var element = document.getElementById(aElementID);
|
2002-02-02 01:18:59 +03:00
|
|
|
element.hidden = false;
|
2000-06-03 05:03:23 +04:00
|
|
|
}
|
1999-10-08 08:51:19 +04:00
|
|
|
|
2001-01-05 03:37:30 +03:00
|
|
|
function hideElementById(aElementID)
|
2000-06-03 05:03:23 +04:00
|
|
|
{
|
|
|
|
var element = document.getElementById(aElementID)
|
2002-02-02 01:18:59 +03:00
|
|
|
element.hidden = true;
|
1999-08-11 03:29:43 +04:00
|
|
|
}
|
|
|
|
|
2001-01-05 03:37:30 +03:00
|
|
|
function isVisible(aElementId)
|
|
|
|
{
|
2002-02-02 01:18:59 +03:00
|
|
|
return document.getElementById(aElementId).hasAttribute("hidden");
|
2001-01-05 03:37:30 +03:00
|
|
|
}
|
|
|
|
|
2000-06-03 05:03:23 +04:00
|
|
|
function onCheckboxClick(aCheckboxElement)
|
1999-08-11 03:29:43 +04:00
|
|
|
{
|
2000-11-03 01:15:41 +03:00
|
|
|
gCommonDialogParam.SetInt(1, aCheckboxElement.checked);
|
1999-08-11 03:29:43 +04:00
|
|
|
}
|
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
function commonDialogOnAccept()
|
1999-08-11 03:29:43 +04:00
|
|
|
{
|
2002-02-02 01:18:59 +03:00
|
|
|
gCommonDialogParam.SetInt(0, 0); // say that ok was pressed
|
|
|
|
|
|
|
|
var numTextBoxes = gCommonDialogParam.GetInt(3);
|
|
|
|
var textboxIsPassword1 = gCommonDialogParam.GetInt(4) == 1;
|
|
|
|
|
|
|
|
if (numTextBoxes >= 1) {
|
|
|
|
var editField1;
|
|
|
|
if (textboxIsPassword1)
|
|
|
|
editField1 = document.getElementById("password1Textbox");
|
|
|
|
else
|
|
|
|
editField1 = document.getElementById("loginTextbox");
|
|
|
|
gCommonDialogParam.SetString(6, editField1.value);
|
|
|
|
}
|
1999-08-11 03:29:43 +04:00
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
if (numTextBoxes == 2) {
|
2001-02-06 05:13:54 +03:00
|
|
|
var editField2;
|
2002-02-02 01:18:59 +03:00
|
|
|
if (textboxIsPassword1)
|
|
|
|
// we had two password fields
|
|
|
|
editField2 = document.getElementById("password2Textbox");
|
2001-02-06 05:13:54 +03:00
|
|
|
else
|
2002-02-02 01:18:59 +03:00
|
|
|
// we only had one password field (and one login field)
|
|
|
|
editField2 = document.getElementById("password1Textbox");
|
2001-01-05 03:37:30 +03:00
|
|
|
gCommonDialogParam.SetString(7, editField2.value);
|
|
|
|
}
|
1999-09-02 04:17:03 +04:00
|
|
|
}
|
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
function commonDialogOnExtra1()
|
1999-09-02 04:17:03 +04:00
|
|
|
{
|
2001-01-05 03:37:30 +03:00
|
|
|
gCommonDialogParam.SetInt(0, 2);
|
2002-02-02 01:18:59 +03:00
|
|
|
window.close();
|
1999-09-02 04:17:03 +04:00
|
|
|
}
|
|
|
|
|
2002-02-02 01:18:59 +03:00
|
|
|
function commonDialogOnExtra2()
|
1999-09-02 04:17:03 +04:00
|
|
|
{
|
2001-01-05 03:37:30 +03:00
|
|
|
gCommonDialogParam.SetInt(0, 3);
|
2002-02-02 01:18:59 +03:00
|
|
|
window.close();
|
1999-10-08 08:51:19 +04:00
|
|
|
}
|