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