browser/metro/base/content/flyoutpanels/SettingsCharm.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1
michael@0 2 /**
michael@0 3 * Manage the contents of the Windows 8 "Settings" charm.
michael@0 4 */
michael@0 5 var SettingsCharm = {
michael@0 6 _entries: new Map(),
michael@0 7 _nextId: 0,
michael@0 8
michael@0 9 /**
michael@0 10 * Add a new item to the "Settings" menu in the Windows 8 charms.
michael@0 11 * @param aEntry Object with a "label" property (string that will appear in the UI)
michael@0 12 * and an "onselected" property (function to be called when the user chooses this entry)
michael@0 13 */
michael@0 14 addEntry: function addEntry(aEntry) {
michael@0 15 try {
michael@0 16 let id = Services.metro.addSettingsPanelEntry(aEntry.label);
michael@0 17 this._entries.set(id, aEntry);
michael@0 18 } catch (e) {
michael@0 19 // addSettingsPanelEntry does not work on non-Metro platforms
michael@0 20 Cu.reportError(e);
michael@0 21 }
michael@0 22 },
michael@0 23
michael@0 24 init: function SettingsCharm_init() {
michael@0 25 Services.obs.addObserver(this, "metro-settings-entry-selected", false);
michael@0 26
michael@0 27 // Options
michael@0 28 this.addEntry({
michael@0 29 label: Strings.browser.GetStringFromName("optionsCharm"),
michael@0 30 onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel')
michael@0 31 });
michael@0 32
michael@0 33 // Search providers
michael@0 34 this.addEntry({
michael@0 35 label: Strings.browser.GetStringFromName("searchCharm"),
michael@0 36 onselected: function() FlyoutPanelsUI.show('SearchFlyoutPanel')
michael@0 37 });
michael@0 38
michael@0 39 /*
michael@0 40 * Temporarily disabled until we can have sync prefs together with the
michael@0 41 * Desktop browser's sync prefs.
michael@0 42 // Sync
michael@0 43 this.addEntry({
michael@0 44 label: Strings.brand.GetStringFromName("syncBrandShortName"),
michael@0 45 onselected: function() FlyoutPanelsUI.show('SyncFlyoutPanel')
michael@0 46 });
michael@0 47 */
michael@0 48
michael@0 49 // About
michael@0 50 this.addEntry({
michael@0 51 label: Strings.browser.GetStringFromName("aboutCharm1"),
michael@0 52 onselected: function() FlyoutPanelsUI.show('AboutFlyoutPanel')
michael@0 53 });
michael@0 54
michael@0 55 // Feedback
michael@0 56 this.addEntry({
michael@0 57 label: Strings.browser.GetStringFromName("feedbackCharm"),
michael@0 58 onselected: function() {
michael@0 59 let url = Services.urlFormatter.formatURLPref("app.support.inputURL");
michael@0 60 BrowserUI.addAndShowTab(url, Browser.selectedTab);
michael@0 61 }
michael@0 62 });
michael@0 63
michael@0 64 // Help
michael@0 65 this.addEntry({
michael@0 66 label: Strings.browser.GetStringFromName("helpOnlineCharm"),
michael@0 67 onselected: function() {
michael@0 68 let url = Services.urlFormatter.formatURLPref("app.support.baseURL") +
michael@0 69 "firefox-help";
michael@0 70 BrowserUI.addAndShowTab(url, Browser.selectedTab);
michael@0 71 }
michael@0 72 });
michael@0 73 },
michael@0 74
michael@0 75 observe: function SettingsCharm_observe(aSubject, aTopic, aData) {
michael@0 76 if (aTopic == "metro-settings-entry-selected") {
michael@0 77 let entry = this._entries.get(parseInt(aData, 10));
michael@0 78 if (entry)
michael@0 79 entry.onselected();
michael@0 80 }
michael@0 81 },
michael@0 82
michael@0 83 uninit: function SettingsCharm_uninit() {
michael@0 84 Services.obs.removeObserver(this, "metro-settings-entry-selected");
michael@0 85 }
michael@0 86 };

mercurial