diff --git a/browser/metro/base/content/browser-scripts.js b/browser/metro/base/content/browser-scripts.js index bd4d7f3fe84..7ad50905edb 100644 --- a/browser/metro/base/content/browser-scripts.js +++ b/browser/metro/base/content/browser-scripts.js @@ -116,6 +116,7 @@ let ScriptContexts = {}; ["NavButtonSlider", "chrome://browser/content/NavButtonSlider.js"], ["ContextUI", "chrome://browser/content/ContextUI.js"], ["FlyoutPanelsUI", "chrome://browser/content/flyoutpanels/FlyoutPanelsUI.js"], + ["SettingsCharm", "chrome://browser/content/flyoutpanels/SettingsCharm.js"], ["APZCObserver", "chrome://browser/content/apzc.js"], ].forEach(function (aScript) { let [name, script] = aScript; diff --git a/browser/metro/base/content/browser-ui.js b/browser/metro/base/content/browser-ui.js index 7839bbf598f..3e5be3f6e81 100644 --- a/browser/metro/base/content/browser-ui.js +++ b/browser/metro/base/content/browser-ui.js @@ -1276,70 +1276,3 @@ var DialogUI = { return targetNode ? true : false; } }; - -/** - * Manage the contents of the Windows 8 "Settings" charm. - */ -var SettingsCharm = { - _entries: new Map(), - _nextId: 0, - - /** - * Add a new item to the "Settings" menu in the Windows 8 charms. - * @param aEntry Object with a "label" property (string that will appear in the UI) - * and an "onselected" property (function to be called when the user chooses this entry) - */ - addEntry: function addEntry(aEntry) { - try { - let id = Services.metro.addSettingsPanelEntry(aEntry.label); - this._entries.set(id, aEntry); - } catch (e) { - // addSettingsPanelEntry does not work on non-Metro platforms - Cu.reportError(e); - } - }, - - init: function SettingsCharm_init() { - Services.obs.addObserver(this, "metro-settings-entry-selected", false); - - // Options - this.addEntry({ - label: Strings.browser.GetStringFromName("optionsCharm"), - onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel') - }); -/* - * Temporarily disabled until we can have sync prefs together with the - * Desktop browser's sync prefs. - // Sync - this.addEntry({ - label: Strings.brand.GetStringFromName("syncBrandShortName"), - 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"), - onselected: function() { - let url = Services.urlFormatter.formatURLPref("app.support.baseURL"); - BrowserUI.addAndShowTab(url, Browser.selectedTab); - } - }); - }, - - observe: function SettingsCharm_observe(aSubject, aTopic, aData) { - if (aTopic == "metro-settings-entry-selected") { - let entry = this._entries.get(parseInt(aData, 10)); - if (entry) - entry.onselected(); - } - }, - - uninit: function SettingsCharm_uninit() { - Services.obs.removeObserver(this, "metro-settings-entry-selected"); - } -}; diff --git a/browser/metro/base/content/flyoutpanels/SettingsCharm.js b/browser/metro/base/content/flyoutpanels/SettingsCharm.js new file mode 100644 index 00000000000..f42451d7a22 --- /dev/null +++ b/browser/metro/base/content/flyoutpanels/SettingsCharm.js @@ -0,0 +1,67 @@ + +/** + * Manage the contents of the Windows 8 "Settings" charm. + */ +var SettingsCharm = { + _entries: new Map(), + _nextId: 0, + + /** + * Add a new item to the "Settings" menu in the Windows 8 charms. + * @param aEntry Object with a "label" property (string that will appear in the UI) + * and an "onselected" property (function to be called when the user chooses this entry) + */ + addEntry: function addEntry(aEntry) { + try { + let id = Services.metro.addSettingsPanelEntry(aEntry.label); + this._entries.set(id, aEntry); + } catch (e) { + // addSettingsPanelEntry does not work on non-Metro platforms + Cu.reportError(e); + } + }, + + init: function SettingsCharm_init() { + Services.obs.addObserver(this, "metro-settings-entry-selected", false); + + // Options + this.addEntry({ + label: Strings.browser.GetStringFromName("optionsCharm"), + onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel') + }); +/* + * Temporarily disabled until we can have sync prefs together with the + * Desktop browser's sync prefs. + // Sync + this.addEntry({ + label: Strings.brand.GetStringFromName("syncBrandShortName"), + 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"), + onselected: function() { + let url = Services.urlFormatter.formatURLPref("app.support.baseURL"); + BrowserUI.addAndShowTab(url, Browser.selectedTab); + } + }); + }, + + observe: function SettingsCharm_observe(aSubject, aTopic, aData) { + if (aTopic == "metro-settings-entry-selected") { + let entry = this._entries.get(parseInt(aData, 10)); + if (entry) + entry.onselected(); + } + }, + + uninit: function SettingsCharm_uninit() { + Services.obs.removeObserver(this, "metro-settings-entry-selected"); + } +}; diff --git a/browser/metro/base/jar.mn b/browser/metro/base/jar.mn index 1d014484e29..915046df5da 100644 --- a/browser/metro/base/jar.mn +++ b/browser/metro/base/jar.mn @@ -30,9 +30,13 @@ chrome.jar: content/bindings/notification.xml (content/bindings/notification.xml) content/bindings/tabprompts.xml (content/bindings/tabprompts.xml) + content/flyoutpanels/SettingsCharm.js (content/flyoutpanels/SettingsCharm.js) * content/flyoutpanels/FlyoutPanelsUI.js (content/flyoutpanels/FlyoutPanelsUI.js) * content/flyoutpanels/AboutFlyoutPanel.js (content/flyoutpanels/AboutFlyoutPanel.js) content/flyoutpanels/PrefsFlyoutPanel.js (content/flyoutpanels/PrefsFlyoutPanel.js) +#ifdef MOZ_SERVICES_SYNC + content/flyoutpanels/SyncFlyoutPanel.js (content/flyoutpanels/SyncFlyoutPanel.js) +#endif content/helperui/AlertsHelper.js (content/helperui/AlertsHelper.js) content/helperui/IndexedDB.js (content/helperui/IndexedDB.js) @@ -81,9 +85,6 @@ chrome.jar: content/TopSites.js (content/TopSites.js) content/console.js (content/console.js) content/dbg-metro-actors.js (content/dbg-metro-actors.js) -#ifdef MOZ_SERVICES_SYNC - content/flyoutpanels/SyncFlyoutPanel.js (content/flyoutpanels/SyncFlyoutPanel.js) -#endif content/NavButtonSlider.js (content/NavButtonSlider.js) content/ContextUI.js (content/ContextUI.js) content/apzc.js (content/apzc.js)