Bug 58986 The find dialog should autocomplete recently searched items r=Neil.

This commit is contained in:
Philip Chee 2013-11-17 22:21:55 +08:00
parent b993a04a12
commit bb05fba625
2 changed files with 26 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/FormHistory.jsm");
var dialog; // Quick access to document/form elements.
var gFindInst; // nsIWebBrowserFind that we're going to use
@ -100,6 +101,7 @@ function onAccept()
// Transfer dialog contents to the find service.
saveFindData();
updateFormHistory();
// set up the find instance
gFindInst.searchString = dialog.findKey.value;
@ -126,3 +128,22 @@ function doEnabling()
{
dialog.find.disabled = !dialog.findKey.value;
}
function updateFormHistory()
{
if (window.opener.PrivateBrowsingUtils &&
window.opener.PrivateBrowsingUtils.isWindowPrivate(window.opener) ||
!dialog.findKey.value)
return;
FormHistory.update({
op: "bump",
fieldname: "find-dialog",
value: dialog.findKey.value
}, {
handleError: function(aError) {
Components.utils.reportError("Saving find to form history failed: " +
aError.message);
}
});
}

View File

@ -25,7 +25,11 @@
<vbox>
<hbox align="center">
<label value="&findField.label;" accesskey="&findField.accesskey;" control="dialog.findKey"/>
<textbox id="dialog.findKey" flex="1" oninput="doEnabling();"/>
<textbox id="dialog.findKey" flex="1"
type="autocomplete"
autocompletesearch="form-history"
autocompletesearchparam="find-dialog"
oninput="doEnabling();"/>
</hbox>
<hbox align="center">
<vbox>