1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/content/flyoutpanels/SettingsCharm.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 + 1.5 +/** 1.6 + * Manage the contents of the Windows 8 "Settings" charm. 1.7 + */ 1.8 +var SettingsCharm = { 1.9 + _entries: new Map(), 1.10 + _nextId: 0, 1.11 + 1.12 + /** 1.13 + * Add a new item to the "Settings" menu in the Windows 8 charms. 1.14 + * @param aEntry Object with a "label" property (string that will appear in the UI) 1.15 + * and an "onselected" property (function to be called when the user chooses this entry) 1.16 + */ 1.17 + addEntry: function addEntry(aEntry) { 1.18 + try { 1.19 + let id = Services.metro.addSettingsPanelEntry(aEntry.label); 1.20 + this._entries.set(id, aEntry); 1.21 + } catch (e) { 1.22 + // addSettingsPanelEntry does not work on non-Metro platforms 1.23 + Cu.reportError(e); 1.24 + } 1.25 + }, 1.26 + 1.27 + init: function SettingsCharm_init() { 1.28 + Services.obs.addObserver(this, "metro-settings-entry-selected", false); 1.29 + 1.30 + // Options 1.31 + this.addEntry({ 1.32 + label: Strings.browser.GetStringFromName("optionsCharm"), 1.33 + onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel') 1.34 + }); 1.35 + 1.36 + // Search providers 1.37 + this.addEntry({ 1.38 + label: Strings.browser.GetStringFromName("searchCharm"), 1.39 + onselected: function() FlyoutPanelsUI.show('SearchFlyoutPanel') 1.40 + }); 1.41 + 1.42 +/* 1.43 + * Temporarily disabled until we can have sync prefs together with the 1.44 + * Desktop browser's sync prefs. 1.45 + // Sync 1.46 + this.addEntry({ 1.47 + label: Strings.brand.GetStringFromName("syncBrandShortName"), 1.48 + onselected: function() FlyoutPanelsUI.show('SyncFlyoutPanel') 1.49 + }); 1.50 +*/ 1.51 + 1.52 + // About 1.53 + this.addEntry({ 1.54 + label: Strings.browser.GetStringFromName("aboutCharm1"), 1.55 + onselected: function() FlyoutPanelsUI.show('AboutFlyoutPanel') 1.56 + }); 1.57 + 1.58 + // Feedback 1.59 + this.addEntry({ 1.60 + label: Strings.browser.GetStringFromName("feedbackCharm"), 1.61 + onselected: function() { 1.62 + let url = Services.urlFormatter.formatURLPref("app.support.inputURL"); 1.63 + BrowserUI.addAndShowTab(url, Browser.selectedTab); 1.64 + } 1.65 + }); 1.66 + 1.67 + // Help 1.68 + this.addEntry({ 1.69 + label: Strings.browser.GetStringFromName("helpOnlineCharm"), 1.70 + onselected: function() { 1.71 + let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + 1.72 + "firefox-help"; 1.73 + BrowserUI.addAndShowTab(url, Browser.selectedTab); 1.74 + } 1.75 + }); 1.76 + }, 1.77 + 1.78 + observe: function SettingsCharm_observe(aSubject, aTopic, aData) { 1.79 + if (aTopic == "metro-settings-entry-selected") { 1.80 + let entry = this._entries.get(parseInt(aData, 10)); 1.81 + if (entry) 1.82 + entry.onselected(); 1.83 + } 1.84 + }, 1.85 + 1.86 + uninit: function SettingsCharm_uninit() { 1.87 + Services.obs.removeObserver(this, "metro-settings-entry-selected"); 1.88 + } 1.89 +};