Bug 941292 - Add search provider options flyout. r=sfoster

This commit is contained in:
Jim Mathies 2013-12-04 05:46:10 -06:00
parent 4022cc0793
commit 210775829d
8 changed files with 86 additions and 0 deletions

View File

@ -21,6 +21,8 @@
%prefsDTD;
<!ENTITY % aboutPanelDTD SYSTEM "chrome://browser/locale/aboutPanel.dtd">
%aboutPanelDTD;
<!ENTITY % searchPanelDTD SYSTEM "chrome://browser/locale/searchPanel.dtd">
%searchPanelDTD;
#ifdef MOZ_SERVICES_SYNC
<!ENTITY % syncBrandDTD SYSTEM "chrome://browser/locale/syncBrand.dtd">
%syncBrandDTD;
@ -686,6 +688,10 @@ Desktop browser's sync prefs.
<label class="text-link" href="https://www.mozilla.org/dnt">&doNotTrack.learnMoreLink;</label>
</settings>
</flyoutpanel>
<flyoutpanel id="search-flyoutpanel" class="flyout-narrow" headertext="&searchFlyoutHeader.title;">
<settings id="search-options" label="&searchSetting.title;">
</settings>
</flyoutpanel>
<!-- Chrome touch selection overlay -->
<box class="selection-overlay-hidden" id="chrome-selection-overlay"/>

View File

@ -22,6 +22,7 @@ let FlyoutPanelsUI = {
[
['AboutFlyoutPanel', 'chrome://browser/content/flyoutpanels/AboutFlyoutPanel.js'],
['PrefsFlyoutPanel', 'chrome://browser/content/flyoutpanels/PrefsFlyoutPanel.js'],
['SearchFlyoutPanel', 'chrome://browser/content/flyoutpanels/SearchFlyoutPanel.js'],
#ifdef MOZ_SERVICES_SYNC
['SyncFlyoutPanel', 'chrome://browser/content/flyoutpanels/SyncFlyoutPanel.js'],
#endif

View File

@ -0,0 +1,60 @@
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
"use strict";
Components.utils.import("resource://gre/modules/Services.jsm");
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let SearchFlyoutPanel = {
_isInitialized: false,
_hasShown: false,
init: function pv_init() {
if (this._isInitialized) {
Cu.reportError("Attempting to re-initialize PreferencesPanelView");
return;
}
this._topmostElement = document.getElementById("search-flyoutpanel");
this._isInitialized = true;
},
checked: function checked(aId) {
aId = aId.replace("search-", "");
Services.search.defaultEngine = this._engines[parseInt(aId)];
this.updateSearchEngines();
},
updateSearchEngines: function () {
// Clear the list
let setting = document.getElementById("search-options");
while(setting.hasChildNodes()) {
setting.removeChild(setting.firstChild);
}
// Build up the list and check the default
this._engines = Services.search.getVisibleEngines();
let defaultEngine = Services.search.defaultEngine;
this._engines.forEach(function (aEngine, aIndex) {
let radio = document.createElementNS(XUL_NS, "radio");
radio.setAttribute("id", "search-" + aIndex);
radio.setAttribute("label", aEngine.name);
radio.setAttribute("oncommand", "FlyoutPanelsUI.SearchFlyoutPanel.checked(this.id)");
if (defaultEngine == aEngine) {
radio.setAttribute("selected", true);
}
setting.appendChild(radio);
}.bind(this));
},
_show: function() {
if (!this._hasShown) {
this._hasShown = true;
this.updateSearchEngines();
}
this._topmostElement.show();
}
};

View File

@ -29,6 +29,13 @@ var SettingsCharm = {
label: Strings.browser.GetStringFromName("optionsCharm"),
onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel')
});
// Search providers
this.addEntry({
label: Strings.browser.GetStringFromName("searchCharm"),
onselected: function() FlyoutPanelsUI.show('SearchFlyoutPanel')
});
/*
* Temporarily disabled until we can have sync prefs together with the
* Desktop browser's sync prefs.
@ -38,11 +45,13 @@ var SettingsCharm = {
onselected: function() FlyoutPanelsUI.show('SyncFlyoutPanel')
});
*/
// About
this.addEntry({
label: Strings.browser.GetStringFromName("aboutCharm1"),
onselected: function() FlyoutPanelsUI.show('AboutFlyoutPanel')
});
// Help
this.addEntry({
label: Strings.browser.GetStringFromName("helpOnlineCharm"),

View File

@ -34,6 +34,7 @@ chrome.jar:
* content/flyoutpanels/FlyoutPanelsUI.js (content/flyoutpanels/FlyoutPanelsUI.js)
* content/flyoutpanels/AboutFlyoutPanel.js (content/flyoutpanels/AboutFlyoutPanel.js)
content/flyoutpanels/PrefsFlyoutPanel.js (content/flyoutpanels/PrefsFlyoutPanel.js)
content/flyoutpanels/SearchFlyoutPanel.js (content/flyoutpanels/SearchFlyoutPanel.js)
#ifdef MOZ_SERVICES_SYNC
content/flyoutpanels/SyncFlyoutPanel.js (content/flyoutpanels/SyncFlyoutPanel.js)
#endif

View File

@ -44,6 +44,7 @@ clearPrivateData.message=Clear your private data?
# Settings Charms
aboutCharm1=About
optionsCharm=Options
searchCharm=Search
helpOnlineCharm=Help (online)
# General

View File

@ -0,0 +1,7 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- 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/. -->
<!ENTITY searchFlyoutHeader.title "Search">
<!ENTITY searchSetting.title "Default Search Provider">

View File

@ -16,6 +16,7 @@
locale/browser/config.dtd (%chrome/config.dtd)
locale/browser/preferences.dtd (%chrome/preferences.dtd)
locale/browser/aboutPanel.dtd (%chrome/aboutPanel.dtd)
locale/browser/searchPanel.dtd (%chrome/searchPanel.dtd)
locale/browser/checkbox.dtd (%chrome/checkbox.dtd)
locale/browser/sync.dtd (%chrome/sync.dtd)
locale/browser/sync.properties (%chrome/sync.properties)