This commit is contained in:
davidm%netscape.com 1999-08-10 23:29:43 +00:00
Родитель 523d6db630
Коммит 1979cf1e5c
3 изменённых файлов: 236 добавлений и 0 удалений

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

@ -0,0 +1,132 @@
function commonDialogOnLoad()
{
dump("commonDialogOnLoad \n");
doSetOKCancel( commonDialogOnOK, commonDialogOnCancel );
param = window.arguments[0].QueryInterface( Components.interfaces.nsIDialogParamBlock );
if( !param )
dump( " error getting param block interface\n" );
var msg = param.GetString( 0 );
dump("message: "+ msg +"\n");
SetElementText("info.txt", msg );
msg = param.GetString( 3 );
dump("title message: "+ msg +"\n");
SetElementText("info.header", msg );
var iconURL = param.GetString(2 );
var element = document.getElementById("info.icon");
if( element )
element.src = iconURL;
else
dump("couldn't find icon element \n");
// Adjust number buttons
var numButtons = param.GetInt( 2 );
if ( numButtons == 1 )
{
var element = document.getElementById("cancel");
if ( element )
{
dump( "hide button \n" );
element.setAttribute("style", "display:none;" );
}
else
{
dump( "couldn't find button \n");
}
}
// Set the Checkbox
dump(" set checkbox \n");
var checkMsg = param.GetString( 1 );
if ( checkMsg != "" )
{
var prompt = (document.getElementById("checkboxLabel"));
if ( prompt )
{
dump(" setting message \n" );
prompt.childNodes[1].nodeValue = checkMsg;
}
var checkValue = param.GetInt( 1 );
var element=document.getElementById("checkbox" );
var checkbool = checkValue > 0 ? true : false;
element.checked = checkbool;
}
else
{
var element = document.getElementById("checkboxLabel");
element.setAttribute("style","display: none;" );
}
// handle the edit fields
dump("set editfields \n");
var element = document.getElementById("dialog.password");
element.value = param.GetString( 7 );
element = document.getElementById("dialog.loginname");
element.value = param.GetString( 6 );
var numEditFields = param.GetInt( 3 );
switch( numEditFields )
{
case 1:
dump("hiding password");
var element = document.getElementById("passwordEditfield");
element.setAttribute("style","display: none;" );
// Now hide the meanless text
var element = document.getElementById("login.text","");
element.setAttribute("style", "display:none;" );
break;
case 0:
dump("show password");
var element = document.getElementById("editFields");
element.setAttribute("style","display: none;" );
break;
}
}
function onCheckboxClick()
{
var element = document.getElementById("checkbox" );
param.SetInt( 1, element.checked );
dump("setting checkbox to "+ element.checked+"\n");
}
function SetElementText( elementID, text )
{
dump("setting "+elementID+" to "+text +"\n");
var element = document.getElementById(elementID);
if( element )
element.childNodes[0].nodeValue = text;
else
dump("couldn't find element \n");
}
function commonDialogOnOK()
{
dump("commonDialogOnOK \n");
param.SetInt(0, 0 );
var element = document.getElementById("dialog.loginname");
param.SetInt( 6, element.value );
dump(" login name - "+ element.value+ "\n");
element = document.getElementById("dialog.password");
param.SetInt( 7, element.value );
dump(" password - "+ element.value+ "\n");
return true;
}
function commonDialogOnCancel()
{
dump("commonDialogOnCancel \n");
param.SetInt(0, 1 );
return true;
}

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

@ -0,0 +1,97 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://global/locale/commonDialog.dtd">
<window
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
align="vertical"
onload="commonDialogOnLoad()"
class="dialog">
<html:script language="JavaScript" src="chrome://global/content/commonDialog.js" />
<box align="horizontal" flex="100%" style="width: 36em;">
<html:div style="width: 40px; margin: 5px;">
<html:img id="info.icon" src="chrome://global/skin/message-icon.gif" width="32" height="32" border="0"/>
</html:div>
<box align="vertical" flex="100%">
<html:div id="info.header" style="margin-left:2em; margin-right:2em; margin-top:5px; font-size: 110%; font-weight: bold;">
&header.label;
</html:div>
<html:div id="info.txt" style="margin-left:2em; margin-right:2em; margin-top:5px;" flex="100%">
&message.label;
</html:div>
</box>
</box>
<box id="editFields" align="vertical" >
<box align="horizontal" >
<html:div style="min-width: 6em;" id="login.text">&editfield1.label;</html:div>
<html:input accesskey="u" tabindex="0" type="text" id="dialog.loginname" flex="100%"/>
</box>
<box align="horizontal" id ="passwordEditfield">
<html:div style="min-width: 6em;">&editfield2.label;</html:div>
<html:input accesskey="p" tabindex="1" type="password" id="dialog.password" flex="100%"/>
</box>
</box>
<html:label id="checkboxLabel" onclick="onCheckboxClick()" >
<html:input type="checkbox" id="checkbox" />
&checkbox.label;
</html:label>
<box id="okCancelButtons"/>
</window>

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

@ -0,0 +1,7 @@
<!-- extracted from dialogOverlay.xul -->
<!-- OK Cancel Buttons -->
<!ENTITY header.label "Brief Title">
<!ENTITY message.label "Some sample Text goes here.">
<!ENTITY editfield1.label "User Name:">
<!ENTITY editfield2.label "Password:">
<!ENTITY checkbox.label "check">