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