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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     2 /**
     3  * Manage the contents of the Windows 8 "Settings" charm.
     4  */
     5 var SettingsCharm = {
     6   _entries: new Map(),
     7   _nextId: 0,
     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   },
    24   init: function SettingsCharm_init() {
    25     Services.obs.addObserver(this, "metro-settings-entry-selected", false);
    27     // Options
    28     this.addEntry({
    29         label: Strings.browser.GetStringFromName("optionsCharm"),
    30         onselected: function() FlyoutPanelsUI.show('PrefsFlyoutPanel')
    31     });
    33     // Search providers
    34     this.addEntry({
    35         label: Strings.browser.GetStringFromName("searchCharm"),
    36         onselected: function() FlyoutPanelsUI.show('SearchFlyoutPanel')
    37     });
    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 */
    49     // About
    50     this.addEntry({
    51         label: Strings.browser.GetStringFromName("aboutCharm1"),
    52         onselected: function() FlyoutPanelsUI.show('AboutFlyoutPanel')
    53     });
    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     });
    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   },
    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   },
    83   uninit: function SettingsCharm_uninit() {
    84     Services.obs.removeObserver(this, "metro-settings-entry-selected");
    85   }
    86 };

mercurial