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