2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @extends {WebInspector.HelpScreen}
35 WebInspector.SettingsScreen = function()
37 WebInspector.HelpScreen.call(this, WebInspector.UIString("Settings"));
39 this._leftColumnElement = document.createElement("td");
40 this._rightColumnElement = document.createElement("td");
42 var p = this._appendSection(WebInspector.UIString("Elements"));
43 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
45 p = this._appendSection(WebInspector.UIString("Styles"));
46 p.appendChild(this._createRadioSetting(WebInspector.UIString("Color format"), [
47 [ WebInspector.StylesSidebarPane.ColorFormat.Original, WebInspector.UIString("As authored") ],
48 [ WebInspector.StylesSidebarPane.ColorFormat.HEX, "HEX: #DAC0DE" ],
49 [ WebInspector.StylesSidebarPane.ColorFormat.RGB, "RGB: rgb(128, 255, 255)" ],
50 [ WebInspector.StylesSidebarPane.ColorFormat.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
51 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
53 if (Preferences.canDisableCache) {
54 p = this._appendSection(WebInspector.UIString("Network"), true);
55 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
58 p = this._appendSection(WebInspector.UIString("Scripts"), true);
59 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show script folders"), WebInspector.settings.showScriptFolders));
61 p = this._appendSection(WebInspector.UIString("Console"), true);
62 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
63 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
65 if (Preferences.haveExtensions) {
66 var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
67 p = this._appendSection(WebInspector.UIString("Extensions"), true);
68 p.appendChild(this._createCustomSetting(WebInspector.UIString("Open links in..."), handlerSelector.element));
70 var table = document.createElement("table");
71 table.className = "help-table";
72 var tr = document.createElement("tr");
73 tr.appendChild(this._leftColumnElement);
74 tr.appendChild(this._rightColumnElement);
75 table.appendChild(tr);
76 this.contentElement.appendChild(table);
79 WebInspector.SettingsScreen.prototype = {
81 * @param {string} name
82 * @param {boolean=} right
84 _appendSection: function(name, right)
86 var p = document.createElement("p");
87 p.className = "help-section";
88 var title = document.createElement("div");
89 title.className = "help-section-title";
90 title.textContent = name;
92 this._columnElement(right).appendChild(p);
96 _columnElement: function(right)
98 return right ? this._rightColumnElement : this._leftColumnElement;
101 _createCheckboxSetting: function(name, setting)
103 var input = document.createElement("input");
104 input.type = "checkbox";
106 input.checked = setting.get();
109 setting.set(input.checked);
111 input.addEventListener("click", listener, false);
113 var p = document.createElement("p");
114 var label = document.createElement("label");
115 label.appendChild(input);
116 label.appendChild(document.createTextNode(name));
117 p.appendChild(label);
121 _createRadioSetting: function(name, options, setting)
123 var pp = document.createElement("p");
124 var fieldsetElement = document.createElement("fieldset");
125 var legendElement = document.createElement("legend");
126 legendElement.textContent = name;
127 fieldsetElement.appendChild(legendElement);
129 function clickListener(e)
131 setting.set(e.target.value);
134 var settingValue = setting.get();
135 for (var i = 0; i < options.length; ++i) {
136 var p = document.createElement("p");
137 var label = document.createElement("label");
138 p.appendChild(label);
140 var input = document.createElement("input");
141 input.type = "radio";
142 input.name = setting.name;
143 input.value = options[i][0];
144 input.addEventListener("click", clickListener, false);
145 if (settingValue == input.value)
146 input.checked = true;
148 label.appendChild(input);
149 label.appendChild(document.createTextNode(options[i][1]));
151 fieldsetElement.appendChild(p);
154 pp.appendChild(fieldsetElement);
158 _createCustomSetting: function(name, element)
160 var div = document.createElement("div");
161 var p = div.createChild("p");
162 p.textContent = name;
163 div.appendChild(element);
168 WebInspector.SettingsScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype;