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.
31 WebInspector.SettingsScreen = function()
33 WebInspector.HelpScreen.call(this, WebInspector.UIString("Settings"));
35 this._leftColumnElement = document.createElement("td");
36 this._rightColumnElement = document.createElement("td");
38 var p = this._appendSection(WebInspector.UIString("Elements"));
39 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
41 p = this._appendSection(WebInspector.UIString("Styles"));
42 p.appendChild(this._createRadioSetting(WebInspector.UIString("Color format"), [
43 [ WebInspector.StylesSidebarPane.ColorFormat.Original, WebInspector.UIString("As authored") ],
44 [ WebInspector.StylesSidebarPane.ColorFormat.HEX, "HEX: #DAC0DE" ],
45 [ WebInspector.StylesSidebarPane.ColorFormat.RGB, "RGB: rgb(128, 255, 255)" ],
46 [ WebInspector.StylesSidebarPane.ColorFormat.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
47 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
49 if (Preferences.canDisableCache) {
50 p = this._appendSection(WebInspector.UIString("Network"), true);
51 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
54 p = this._appendSection(WebInspector.UIString("Scripts"), true);
55 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show script folders"), WebInspector.settings.showScriptFolders));
57 p = this._appendSection(WebInspector.UIString("Console"), true);
58 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
59 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
61 var table = document.createElement("table");
62 table.className = "help-table";
63 var tr = document.createElement("tr");
64 tr.appendChild(this._leftColumnElement);
65 tr.appendChild(this._rightColumnElement);
66 table.appendChild(tr);
67 this.contentElement.appendChild(table);
70 WebInspector.SettingsScreen.prototype = {
71 _appendSection: function(name, right)
73 var p = document.createElement("p");
74 p.className = "help-section";
75 var title = document.createElement("div");
76 title.className = "help-section-title";
77 title.textContent = name;
79 this._columnElement(right).appendChild(p);
83 _columnElement: function(right)
85 return right ? this._rightColumnElement : this._leftColumnElement;
88 _createCheckboxSetting: function(name, setting)
90 var input = document.createElement("input");
91 input.type = "checkbox";
93 input.checked = setting.get();
96 setting.set(input.checked);
98 input.addEventListener("click", listener, false);
100 var p = document.createElement("p");
101 var label = document.createElement("label");
102 label.appendChild(input);
103 label.appendChild(document.createTextNode(name));
104 p.appendChild(label);
108 _createRadioSetting: function(name, options, setting)
110 var pp = document.createElement("p");
111 var fieldsetElement = document.createElement("fieldset");
112 var legendElement = document.createElement("legend");
113 legendElement.textContent = name;
114 fieldsetElement.appendChild(legendElement);
116 function clickListener(e)
118 setting.set(e.target.value);
121 var settingValue = setting.get();
122 for (var i = 0; i < options.length; ++i) {
123 var p = document.createElement("p");
124 var label = document.createElement("label");
125 p.appendChild(label);
127 var input = document.createElement("input");
128 input.type = "radio";
129 input.name = setting.name;
130 input.value = options[i][0];
131 input.addEventListener("click", clickListener, false);
132 if (settingValue == input.value)
133 input.checked = true;
135 label.appendChild(input);
136 label.appendChild(document.createTextNode(options[i][1]));
138 fieldsetElement.appendChild(p);
141 pp.appendChild(fieldsetElement);
146 WebInspector.SettingsScreen.prototype.__proto__ = WebInspector.HelpScreen.prototype;