Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | var gContentPane = { |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | * Initializes the fonts dropdowns displayed in this pane. |
michael@0 | 9 | */ |
michael@0 | 10 | init: function () |
michael@0 | 11 | { |
michael@0 | 12 | this._rebuildFonts(); |
michael@0 | 13 | var menulist = document.getElementById("defaultFont"); |
michael@0 | 14 | if (menulist.selectedIndex == -1) { |
michael@0 | 15 | menulist.insertItemAt(0, "", "", ""); |
michael@0 | 16 | menulist.selectedIndex = 0; |
michael@0 | 17 | } |
michael@0 | 18 | }, |
michael@0 | 19 | |
michael@0 | 20 | // UTILITY FUNCTIONS |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * Utility function to enable/disable the button specified by aButtonID based |
michael@0 | 24 | * on the value of the Boolean preference specified by aPreferenceID. |
michael@0 | 25 | */ |
michael@0 | 26 | updateButtons: function (aButtonID, aPreferenceID) |
michael@0 | 27 | { |
michael@0 | 28 | var button = document.getElementById(aButtonID); |
michael@0 | 29 | var preference = document.getElementById(aPreferenceID); |
michael@0 | 30 | button.disabled = preference.value != true; |
michael@0 | 31 | return undefined; |
michael@0 | 32 | }, |
michael@0 | 33 | |
michael@0 | 34 | // BEGIN UI CODE |
michael@0 | 35 | |
michael@0 | 36 | /* |
michael@0 | 37 | * Preferences: |
michael@0 | 38 | * |
michael@0 | 39 | * dom.disable_open_during_load |
michael@0 | 40 | * - true if popups are blocked by default, false otherwise |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | // POP-UPS |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * Displays the popup exceptions dialog where specific site popup preferences |
michael@0 | 47 | * can be set. |
michael@0 | 48 | */ |
michael@0 | 49 | showPopupExceptions: function () |
michael@0 | 50 | { |
michael@0 | 51 | var bundlePreferences = document.getElementById("bundlePreferences"); |
michael@0 | 52 | var params = { blockVisible: false, sessionVisible: false, allowVisible: true, |
michael@0 | 53 | prefilledHost: "", permissionType: "popup" } |
michael@0 | 54 | params.windowTitle = bundlePreferences.getString("popuppermissionstitle"); |
michael@0 | 55 | params.introText = bundlePreferences.getString("popuppermissionstext"); |
michael@0 | 56 | |
michael@0 | 57 | openDialog("chrome://browser/content/preferences/permissions.xul", |
michael@0 | 58 | "Browser:Permissions", "resizable=yes", params); |
michael@0 | 59 | }, |
michael@0 | 60 | |
michael@0 | 61 | // FONTS |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * Populates the default font list in UI. |
michael@0 | 65 | */ |
michael@0 | 66 | _rebuildFonts: function () |
michael@0 | 67 | { |
michael@0 | 68 | var langGroupPref = document.getElementById("font.language.group"); |
michael@0 | 69 | this._selectDefaultLanguageGroup(langGroupPref.value, |
michael@0 | 70 | this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif"); |
michael@0 | 71 | }, |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * |
michael@0 | 75 | */ |
michael@0 | 76 | _selectDefaultLanguageGroup: function (aLanguageGroup, aIsSerif) |
michael@0 | 77 | { |
michael@0 | 78 | const kFontNameFmtSerif = "font.name.serif.%LANG%"; |
michael@0 | 79 | const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%"; |
michael@0 | 80 | const kFontNameListFmtSerif = "font.name-list.serif.%LANG%"; |
michael@0 | 81 | const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%"; |
michael@0 | 82 | const kFontSizeFmtVariable = "font.size.variable.%LANG%"; |
michael@0 | 83 | |
michael@0 | 84 | var prefs = [{ format : aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif, |
michael@0 | 85 | type : "fontname", |
michael@0 | 86 | element : "defaultFont", |
michael@0 | 87 | fonttype : aIsSerif ? "serif" : "sans-serif" }, |
michael@0 | 88 | { format : aIsSerif ? kFontNameListFmtSerif : kFontNameListFmtSansSerif, |
michael@0 | 89 | type : "unichar", |
michael@0 | 90 | element : null, |
michael@0 | 91 | fonttype : aIsSerif ? "serif" : "sans-serif" }, |
michael@0 | 92 | { format : kFontSizeFmtVariable, |
michael@0 | 93 | type : "int", |
michael@0 | 94 | element : "defaultFontSize", |
michael@0 | 95 | fonttype : null }]; |
michael@0 | 96 | var preferences = document.getElementById("contentPreferences"); |
michael@0 | 97 | for (var i = 0; i < prefs.length; ++i) { |
michael@0 | 98 | var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup)); |
michael@0 | 99 | if (!preference) { |
michael@0 | 100 | preference = document.createElement("preference"); |
michael@0 | 101 | var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup); |
michael@0 | 102 | preference.id = name; |
michael@0 | 103 | preference.setAttribute("name", name); |
michael@0 | 104 | preference.setAttribute("type", prefs[i].type); |
michael@0 | 105 | preferences.appendChild(preference); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | if (!prefs[i].element) |
michael@0 | 109 | continue; |
michael@0 | 110 | |
michael@0 | 111 | var element = document.getElementById(prefs[i].element); |
michael@0 | 112 | if (element) { |
michael@0 | 113 | element.setAttribute("preference", preference.id); |
michael@0 | 114 | |
michael@0 | 115 | if (prefs[i].fonttype) |
michael@0 | 116 | FontBuilder.buildFontList(aLanguageGroup, prefs[i].fonttype, element); |
michael@0 | 117 | |
michael@0 | 118 | preference.setElementValue(element); |
michael@0 | 119 | } |
michael@0 | 120 | } |
michael@0 | 121 | }, |
michael@0 | 122 | |
michael@0 | 123 | /** |
michael@0 | 124 | * Returns the type of the current default font for the language denoted by |
michael@0 | 125 | * aLanguageGroup. |
michael@0 | 126 | */ |
michael@0 | 127 | _readDefaultFontTypeForLanguage: function (aLanguageGroup) |
michael@0 | 128 | { |
michael@0 | 129 | const kDefaultFontType = "font.default.%LANG%"; |
michael@0 | 130 | var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup); |
michael@0 | 131 | var preference = document.getElementById(defaultFontTypePref); |
michael@0 | 132 | if (!preference) { |
michael@0 | 133 | preference = document.createElement("preference"); |
michael@0 | 134 | preference.id = defaultFontTypePref; |
michael@0 | 135 | preference.setAttribute("name", defaultFontTypePref); |
michael@0 | 136 | preference.setAttribute("type", "string"); |
michael@0 | 137 | preference.setAttribute("onchange", "gContentPane._rebuildFonts();"); |
michael@0 | 138 | document.getElementById("contentPreferences").appendChild(preference); |
michael@0 | 139 | } |
michael@0 | 140 | return preference.value; |
michael@0 | 141 | }, |
michael@0 | 142 | |
michael@0 | 143 | /** |
michael@0 | 144 | * Displays the fonts dialog, where web page font names and sizes can be |
michael@0 | 145 | * configured. |
michael@0 | 146 | */ |
michael@0 | 147 | configureFonts: function () |
michael@0 | 148 | { |
michael@0 | 149 | openDialog("chrome://browser/content/preferences/fonts.xul", |
michael@0 | 150 | "Browser:FontPreferences", null); |
michael@0 | 151 | }, |
michael@0 | 152 | |
michael@0 | 153 | /** |
michael@0 | 154 | * Displays the colors dialog, where default web page/link/etc. colors can be |
michael@0 | 155 | * configured. |
michael@0 | 156 | */ |
michael@0 | 157 | configureColors: function () |
michael@0 | 158 | { |
michael@0 | 159 | openDialog("chrome://browser/content/preferences/colors.xul", |
michael@0 | 160 | "Browser:ColorPreferences", null); |
michael@0 | 161 | }, |
michael@0 | 162 | |
michael@0 | 163 | // LANGUAGES |
michael@0 | 164 | |
michael@0 | 165 | /** |
michael@0 | 166 | * Shows a dialog in which the preferred language for web content may be set. |
michael@0 | 167 | */ |
michael@0 | 168 | showLanguages: function () |
michael@0 | 169 | { |
michael@0 | 170 | openDialog("chrome://browser/content/preferences/languages.xul", |
michael@0 | 171 | "Browser:LanguagePreferences", null); |
michael@0 | 172 | } |
michael@0 | 173 | }; |