Updated to match nsFindComponent.cpp

This commit is contained in:
law%netscape.com 1999-04-22 01:59:14 +00:00
parent 4bcbfb9104
commit 37974c7c72

View File

@ -1,6 +1,5 @@
<?xml version="1.0"?>
<?xml-stylesheet href="platform.css" type="text/css"?>
<?xml-stylesheet href="dialogs.css" type="text/css"?>
<?xml-stylesheet href="xul.css" type="text/css"?>
<!DOCTYPE window>
@ -9,41 +8,117 @@
onload="onLoad()" title="Search">
<data>
<broadcaster id="data.searchTerm" type="string" value=""/>
<broadcaster id="data.execute" command=""/>
<broadcaster id="data.key" type="string" value=""/>
<broadcaster id="data.ignoreCase" type="boolean" value="true"/>
<broadcaster id="data.searchBackwards" type="boolean" value="false"/>
<broadcaster id="data.wrap" type="boolean" value="false"/>
<broadcaster id="data.execute" command="" key="" ignoreCase="" searchBackwards="" wrap=""/>
</data>
<html:script>
var data;
var dialog;
function string2Bool( value ) {
return value != "false";
}
function bool2String( value ) {
if ( value ) {
return "true";
} else {
return "false";
}
}
function initData() {
// Create data object and initialize.
data = new Object;
data.searchTerm = document.getElementById("data.searchTerm");
data.caseSensitive = document.getElementById("data.caseSensitive");
data.wrap = document.getElementById("data.wrap");
data.backwards = document.getElementById("data.backwards");
data.execute = document.getElementById("data.execute");
data.key = document.getElementById("data.key");
data.ignoreCase = document.getElementById("data.ignoreCase");
data.wrap = document.getElementById("data.wrap");
data.searchBackwards = document.getElementById("data.searchBackwards");
data.execute = document.getElementById("data.execute");
dumpData();
}
function initDialog() {
// Create dialog object and initialize.
dialog = new Object;
dialog.searchTerm = document.getElementById("dialog.searchTerm");
dialog.caseSensitive = document.getElementById("dialog.caseSensitive");
dialog.wrap = document.getElementById("dialog.wrap");
dialog.backwards = document.getElementById("dialog.backwards");
dialog.ok = document.getElementById("dialog.ok");
dialog.enabled = false;
dialog.key = document.getElementById("dialog.key");
dialog.ignoreCase = document.getElementById("dialog.ignoreCase");
dialog.wrap = document.getElementById("dialog.wrap");
dialog.searchBackwards = document.getElementById("dialog.searchBackwards");
dialog.ok = document.getElementById("dialog.ok");
dialog.cancel = document.getElementById("dialog.cancel");
dialog.enabled = false;
}
function loadDialog() {
// Set initial dialog field contents.
dialog.searchTerm.setAttribute( "value", "");
dialog.caseSensitive.setAttribute( "value", false );
dialog.wrap.setAttribute( "value", true);
dialog.backwards.setAttribute( "value", false);
dialog.key.setAttribute( "value", data.key.getAttribute("value") );
// Note: dialog.ignoreCase is actually "Case Sensitive" so
// we must reverse things when getting the data.
if ( data.ignoreCase.getAttribute("value") == "true" ) {
dialog.ignoreCase.removeAttribute( "checked" );
} else {
dialog.ignoreCase.setAttribute( "checked", "" );
}
if ( data.wrap.getAttribute("value") == "true" ) {
dialog.wrap.setAttribute( "checked", "" );
} else {
dialog.wrap.removeAttribute( "checked" );
}
if ( data.searchBackwards.getAttribute("value") == "true" ) {
dialog.searchBackwards.setAttribute( "checked", "" );
} else {
dialog.searchBackwards.removeAttribute( "checked" );
}
}
function loadData() {
// Set data attributes per user input.
data.key.setAttribute( "value", dialog.key.value );
// Note: dialog.ignoreCase is actually "Case Sensitive" so
// we must reverse things when storing the data.
if ( dialog.ignoreCase.checked ) {
data.ignoreCase.setAttribute( "value", "false" );
} else {
data.ignoreCase.setAttribute( "value", "true" );
}
if ( dialog.wrap.checked ) {
data.wrap.setAttribute( "value", "true" );
} else {
data.wrap.setAttribute( "value", "false" );
}
if ( dialog.searchBackwards.checked ) {
data.searchBackwards.setAttribute( "value", "true" );
} else {
data.searchBackwards.setAttribute( "value", "false" );
}
dumpData();
}
function dumpData() {
dump( "data.key = " + data.key + "\n" );
dump( "\tvalue=" + data.key.getAttribute("value") + "\n" );
dump( "data.ignoreCase = " + data.ignoreCase + "\n" );
dump( "\tvalue=" + data.ignoreCase.getAttribute("value") + "\n" );
dump( "data.searchBackwards = " + data.searchBackwards + "\n" );
dump( "\tvalue=" + data.searchBackwards.getAttribute("value") + "\n" );
dump( "data.wrap = " + data.wrap + "\n" );
dump( "\tvalue=" + data.wrap.getAttribute("value") + "\n" );
dump( "data.execute = " + data.execute + "\n" );
dump( "\tkey=" + data.execute.getAttribute("key") + "\n" );
dump( "\tignoreCase=" + data.execute.getAttribute("ignorecase") + "\n" );
dump( "\tsearchBackwards=" + data.execute.getAttribute("searchBackwards") + "\n" );
dump( "\twrap=" + data.execute.getAttribute("wrap") + "\n" );
}
function onLoad() {
@ -58,14 +133,27 @@
}
function ok() {
// Proceed with find.
data.execute.setAttribute("searchTerm", dialog.searchTerm.value );
data.execute.setAttribute("command", "ok");
// Note: This is broken! We must detect whether the user has changed
// the dialog contents and only trigger "find" if they have.
// Otherwise, trigger "next."
// Transfer dialog contents to data elements.
loadData();
// Set data.execute argument attributes from data.
data.execute.setAttribute( "key", data.key.getAttribute("value") );
data.execute.setAttribute( "ignoreCase", data.ignoreCase.getAttribute("value") );
data.execute.setAttribute( "searchBackwards", data.searchBackwards.getAttribute("value") );
data.execute.setAttribute( "wrap", data.wrap.getAttribute("value") );
// Fire command.
dumpData();
data.execute.setAttribute( "command", "find" );
}
function cancel() {
// Close the window.
data.execute.setAttribute("command","close");
data.execute.setAttribute( "command", "cancel" );
}
function onTyping( key ) {
@ -74,13 +162,13 @@
} else {
if ( dialog.enabled ) {
// Disable OK if they delete all the text.
if ( dialog.searchTerm.value == "" ) {
if ( dialog.key.value == "" ) {
dialog.enabled = false;
dialog.ok.setAttribute( "disabled", "" );
}
} else {
// Enable OK once the user types something.
if ( dialog.searchTerm.value != "" ) {
if ( dialog.key.value != "" ) {
dialog.enabled = true;
dialog.ok.removeAttribute( "disabled" );
}
@ -89,14 +177,13 @@
}
</html:script>
<html:form>
<html:table border="0" style="width:400px;">
<html:tr>
<html:td class="fieldlabel">
Find:
</html:td>
<html:td align="left">
<html:input id="dialog.searchTerm" readonly="" style="background-color:lightgray;width:300px;" onkeyup="onTyping(event.which)"/>
<html:input id="dialog.key" style="width:300px;" onkeyup="onTyping(event.which)"/>
</html:td>
</html:tr>
@ -104,7 +191,7 @@
<html:td align="right">
</html:td>
<html:td class="buttonlabel">
<html:input type="checkbox" id="dialog.caseSensitive" readonly=""/>
<html:input type="checkbox" id="dialog.ignoreCase"/>
Case Sensitive
</html:td>
</html:tr>
@ -113,7 +200,7 @@
<html:td align="right">
</html:td>
<html:td class="buttonlabel" align="left">
<html:input type="checkbox" id="dialog.wrap" value=""/>
<html:input type="checkbox" id="dialog.wrap"/>
Wrap
</html:td>
</html:tr>
@ -122,16 +209,15 @@
<html:td align="right">
</html:td>
<html:td class="buttonlabel" align="left">
<html:input type="checkbox" id="dialog.backwards" value=""/>
<html:input type="checkbox" id="dialog.searchBackwards"/>
Backwards
</html:td>
</html:tr>
<html:tr>
<html:td align="right" colspan="2">
<html:button class="cancelbutton" id="dialog.cancel" onclick="cancel()" disabled="">Cancel</html:button>
<html:button class="cancelbutton" id="dialog.cancel" onclick="cancel()">Cancel</html:button>
<html:button class="defaultbutton" id="dialog.ok" onclick="ok()" disabled="">OK</html:button>
</html:td>
</html:tr>
</html:table>
</html:form>
</window>