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
Родитель 99283d0dc7
Коммит 8cc9cbadae
2 изменённых файлов: 26 добавлений и 1 удалений

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * 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/Services.jsm");
Components.utils.import("resource://gre/modules/FormHistory.jsm");
var dialog; // Quick access to document/form elements. var dialog; // Quick access to document/form elements.
var gFindInst; // nsIWebBrowserFind that we're going to use var gFindInst; // nsIWebBrowserFind that we're going to use
@ -100,6 +101,7 @@ function onAccept()
// Transfer dialog contents to the find service. // Transfer dialog contents to the find service.
saveFindData(); saveFindData();
updateFormHistory();
// set up the find instance // set up the find instance
gFindInst.searchString = dialog.findKey.value; gFindInst.searchString = dialog.findKey.value;
@ -126,3 +128,22 @@ function doEnabling()
{ {
dialog.find.disabled = !dialog.findKey.value; 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);
}
});
}

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

@ -25,7 +25,11 @@
<vbox> <vbox>
<hbox align="center"> <hbox align="center">
<label value="&findField.label;" accesskey="&findField.accesskey;" control="dialog.findKey"/> <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>
<hbox align="center"> <hbox align="center">
<vbox> <vbox>