Bug 271299: Help Viewer search results should be updated with every keystroke (live search). r=jan

This commit is contained in:
steffen.wilberg%web.de 2005-02-08 22:05:09 +00:00
Родитель e6e1eca2d1
Коммит ac44cfa4a2
3 изменённых файлов: 12 добавлений и 23 удалений

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

@ -620,15 +620,19 @@ function doFind() {
// clear any previous results. // clear any previous results.
clearDatabases(searchTree.database); clearDatabases(searchTree.database);
// split search string into separate terms and compile into regexp's // if the search string is empty or contains only whitespace, purge the results tree and return
RE = findText.value.split(/\s+/); RE = findText.value.match(/\S+/g);
for (var i=0; i < RE.length; ++i) { if (!RE) {
if (RE[i] == "") searchTree.builder.rebuild();
continue; return;
}
RE[i] = new RegExp(RE[i], "i"); // compile the search string, which has already been split up above, into regexp's
for (var i=0; i < RE.length; ++i) {
RE[i] = new RegExp(RE[i], "i");
} }
emptySearch = true; emptySearch = true;
// search TOC // search TOC
var resultsDS = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"] var resultsDS = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"]
.createInstance(Components.interfaces.nsIRDFDataSource); .createInstance(Components.interfaces.nsIRDFDataSource);
@ -661,12 +665,6 @@ function doFind() {
searchTree.builder.rebuild(); searchTree.builder.rebuild();
} }
function doEnabling() {
var findButton = document.getElementById("findButton");
var findTextbox = document.getElementById("findText");
findButton.disabled = !findTextbox.value;
}
function clearDatabases(compositeDataSource) { function clearDatabases(compositeDataSource) {
var enumDS = compositeDataSource.GetDataSources() var enumDS = compositeDataSource.GetDataSources()
while (enumDS.hasMoreElements()) { while (enumDS.hasMoreElements()) {

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

@ -315,16 +315,8 @@
accesskey="&searchtab.accesskey;"/> accesskey="&searchtab.accesskey;"/>
<vbox id="help-search-panel" hidden="true" flex="1"> <vbox id="help-search-panel" hidden="true" flex="1">
<hbox align="center"> <textbox id="findText" type="timed" timeout="500"
<textbox id="findText" flex="1" oninput="doEnabling();" oncommand="doFind();"/>
onkeypress="if ((event.keyCode
== KeyEvent.DOM_VK_ENTER) || (event.keyCode
== KeyEvent.DOM_VK_RETURN))
doFind();"/>
<button id="findButton" default="true" disabled="true"
label="&gobtn.label;" oncommand="doFind()"
flex="0"/>
</hbox>
<tree id="help-search-tree" class="focusring" <tree id="help-search-tree" class="focusring"
flex="1" hidecolumnpicker="true" flex="1" hidecolumnpicker="true"
datasources="rdf:null" datasources="rdf:null"

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

@ -48,7 +48,6 @@
<!ENTITY glossarytab.label "Glossary"> <!ENTITY glossarytab.label "Glossary">
<!ENTITY glossarytab.accesskey "G"> <!ENTITY glossarytab.accesskey "G">
<!ENTITY glossname.label "Name"> <!ENTITY glossname.label "Name">
<!ENTITY gobtn.label "Search">
<!ENTITY name.label "Item"> <!ENTITY name.label "Item">
<!ENTITY textZoomReduceCmd.commandkey "-"> <!ENTITY textZoomReduceCmd.commandkey "-">