Bug 1098350 Support new autocomplete preferences from bug 530209 r=IanN

This commit is contained in:
Neil Rashbrook 2015-05-20 22:17:28 +01:00
Родитель 7e2311e0f6
Коммит 03dbc10973
3 изменённых файлов: 38 добавлений и 37 удалений

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

@ -2,11 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const kBehaviorBit = {
matchOnlyURLs: 16,
matchOnlyTyped: 32
};
function Startup()
{
// On systems that has the file view component, autoFill and showPopup will
@ -21,34 +16,27 @@ function Startup()
document.getElementById("showPopup").removeAttribute("class");
}
updateDependent(document.getElementById("browser.urlbar.autocomplete.enabled").value);
updateDependent();
}
function updateDependent(aValue)
function updateDependent()
{
// The match pref checkboxes always depend on autocomplete.enabled.
updateMatchPrefs();
var matchHistoryPref = document.getElementById("browser.urlbar.suggest.history");
EnableElementById("matchOnlyTyped", matchHistoryPref.value);
var matchBookmarkPref = document.getElementById("browser.urlbar.suggest.bookmark");
var autoCompleteEnabled = matchHistoryPref.value || matchBookmarkPref.value;
EnableElementById("matchBehavior", autoCompleteEnabled);
// If autoFill has a class attribute, we don't have the file view component.
// We then need to update autoFill and showPopup.
if (document.getElementById("autoFill").hasAttribute("class"))
{
EnableElementById("autoFill", aValue);
EnableElementById("showPopup", aValue);
EnableElementById("autoFill", autoCompleteEnabled);
EnableElementById("showPopup", autoCompleteEnabled);
}
}
function updateMatchPrefs()
{
// The various match prefs don't make sense if both autoFill and showPopup
// prefs are false or if autocomplete is turned off.
var autoCompletePref = document.getElementById("browser.urlbar.autocomplete.enabled");
var autoFillPref = document.getElementById("browser.urlbar.autoFill");
var showPopupPref = document.getElementById("browser.urlbar.showPopup");
var matchEnabled = (autoFillPref.value || showPopupPref.value) &&
autoCompletePref.value;
EnableElementById("matchOnlyTyped", matchEnabled);
EnableElementById("matchBehavior", matchEnabled);
// We need to update autocomplete.enabled as the backend still respects it.
document.getElementById("browser.urlbar.autocomplete.enabled").value =
autoCompleteEnabled;
}

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

@ -12,13 +12,22 @@
script="chrome://communicator/content/pref/pref-locationbar.js">
<preferences id="locationBar_preferences">
<preference id="browser.urlbar.autocomplete.enabled"
name="browser.urlbar.autocomplete.enabled"
<!-- The suggest preferences need to come first otherwise the backend
will enable both bookmarks and history if either is enabled -->
<preference id="browser.urlbar.suggest.bookmark"
name="browser.urlbar.suggest.bookmark"
type="bool"
onchange="updateDependent(this.value);"/>
onchange="updateDependent();"/>
<preference id="browser.urlbar.suggest.history"
name="browser.urlbar.suggest.history"
type="bool"
onchange="updateDependent();"/>
<preference id="browser.urlbar.suggest.history.onlyTyped"
name="browser.urlbar.suggest.history.onlyTyped"
type="bool"/>
<preference id="browser.urlbar.autocomplete.enabled"
name="browser.urlbar.autocomplete.enabled"
type="bool"/>
<preference id="browser.urlbar.matchBehavior"
name="browser.urlbar.matchBehavior"
type="int"/>
@ -49,15 +58,19 @@
<groupbox>
<caption label="&autoComplete.label;"/>
<checkbox id="autoCompleteEnabled"
label="&enableAutoComplete.label;"
accesskey="&enableAutoComplete.accesskey;"
preference="browser.urlbar.autocomplete.enabled"/>
<checkbox id="matchHistory"
label="&autoCompleteMatchHistory.label;"
accesskey="&autoCompleteMatchHistory.accesskey;"
preference="browser.urlbar.suggest.history"/>
<checkbox id="matchOnlyTyped"
class="indent"
label="&autoCompleteMatchOnlyTyped.label;"
accesskey="&autoCompleteMatchOnlyTyped.accesskey;"
preference="browser.urlbar.suggest.history.onlyTyped"/>
<checkbox id="matchBookmark"
label="&autoCompleteMatchBookmarks.label;"
accesskey="&autoCompleteMatchBookmarks.accesskey;"
preference="browser.urlbar.suggest.bookmark"/>
<hbox align="center" class="indent">
<label value="&autoCompleteMatch.label;" control="matchBehavior"
accesskey="&autoCompleteMatch.accesskey;"/>

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

@ -6,16 +6,16 @@
<!ENTITY pref.locationBar.title "Location Bar">
<!ENTITY autoComplete.label "Autocomplete">
<!ENTITY enableAutoComplete.label "Autocomplete from your browsing history as you type">
<!ENTITY enableAutoComplete.accesskey "A">
<!ENTITY autoCompleteMatchHistory.label "Automatically suggest websites from History">
<!ENTITY autoCompleteMatchHistory.accesskey "A">
<!ENTITY autoCompleteMatchBookmarks.label "Automatically suggest websites from Bookmarks">
<!ENTITY autoCompleteMatchBookmarks.accesskey "B">
<!ENTITY autoCompleteAutoFill.label "Automatically prefill the best match">
<!ENTITY autoCompleteAutoFill.accesskey "u">
<!ENTITY autoCompleteShowPopup.label "Show list of matching results">
<!ENTITY autoCompleteShowPopup.accesskey "S">
<!ENTITY autoCompleteMatchOnlyTyped.label "Match only websites you've typed previously">
<!ENTITY autoCompleteMatchOnlyTyped.accesskey "o">
<!ENTITY autoCompleteMatchOnlyURLs.label "Only match locations, not website titles">
<!ENTITY autoCompleteMatchOnlyURLs.accesskey "n">
<!--LOCALIZATION NOTE (autoCompleteMatch.label): This is the common leading
part of the menulist items listed below, mainly to make the control available
via the accesskey