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 * @param {!function()} onHide
34 * @extends {WebInspector.HelpScreen}
36 WebInspector.SettingsScreen = function(onHide)
38 WebInspector.HelpScreen.call(this);
39 this.element.id = "settings-screen";
41 /** @type {function()} */
42 this._onHide = onHide;
44 this._tabbedPane = new WebInspector.TabbedPane();
45 this._tabbedPane.element.addStyleClass("help-window-main");
46 var settingsLabelElement = document.createElement("div");
47 settingsLabelElement.className = "help-window-label";
48 settingsLabelElement.createTextChild(WebInspector.UIString("Settings"));
49 this._tabbedPane.element.insertBefore(settingsLabelElement, this._tabbedPane.element.firstChild);
50 this._tabbedPane.element.appendChild(this._createCloseButton());
51 this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.General, WebInspector.UIString("General"), new WebInspector.GenericSettingsTab());
52 if (!WebInspector.experimentsSettings.showOverridesInDrawer.isEnabled())
53 this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Overrides, WebInspector.UIString("Overrides"), new WebInspector.OverridesSettingsTab());
54 if (WebInspector.experimentsSettings.fileSystemProject.isEnabled())
55 this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Workspace, WebInspector.UIString("Workspace"), new WebInspector.WorkspaceSettingsTab());
56 if (WebInspector.experimentsSettings.experimentsEnabled)
57 this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Experiments, WebInspector.UIString("Experiments"), new WebInspector.ExperimentsSettingsTab());
58 this._tabbedPane.appendTab(WebInspector.SettingsScreen.Tabs.Shortcuts, WebInspector.UIString("Shortcuts"), WebInspector.shortcutsScreen.createShortcutsTabView());
59 this._tabbedPane.shrinkableTabs = false;
60 this._tabbedPane.verticalTabLayout = true;
62 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSelectedSettingsTab", WebInspector.SettingsScreen.Tabs.General);
63 this.selectTab(this._lastSelectedTabSetting.get());
64 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
67 WebInspector.SettingsScreen.Tabs = {
69 Overrides: "overrides",
70 Workspace: "workspace",
71 Experiments: "experiments",
72 Shortcuts: "shortcuts"
75 WebInspector.SettingsScreen.prototype = {
77 * @param {string} tabId
79 selectTab: function(tabId)
81 this._tabbedPane.selectTab(tabId);
85 * @param {WebInspector.Event} event
87 _tabSelected: function(event)
89 this._lastSelectedTabSetting.set(this._tabbedPane.selectedTabId);
97 this._tabbedPane.show(this.element);
98 WebInspector.HelpScreen.prototype.wasShown.call(this);
104 isClosingKey: function(keyCode)
107 WebInspector.KeyboardShortcut.Keys.Enter.code,
108 WebInspector.KeyboardShortcut.Keys.Esc.code,
109 ].indexOf(keyCode) >= 0;
118 WebInspector.HelpScreen.prototype.willHide.call(this);
121 __proto__: WebInspector.HelpScreen.prototype
126 * @extends {WebInspector.View}
127 * @param {string} name
128 * @param {string=} id
130 WebInspector.SettingsTab = function(name, id)
132 WebInspector.View.call(this);
133 this.element.className = "settings-tab-container";
135 this.element.id = id;
136 var header = this.element.createChild("header");
137 header.createChild("h3").appendChild(document.createTextNode(name));
138 this.containerElement = this.element.createChild("div", "help-container-wrapper").createChild("div", "settings-tab help-content help-container");
141 WebInspector.SettingsTab.prototype = {
143 * @param {string=} name
146 _appendSection: function(name)
148 var block = this.containerElement.createChild("div", "help-block");
150 block.createChild("div", "help-section-title").textContent = name;
155 * @param {boolean=} omitParagraphElement
156 * @param {Element=} inputElement
158 _createCheckboxSetting: function(name, setting, omitParagraphElement, inputElement)
160 var input = inputElement || document.createElement("input");
161 input.type = "checkbox";
163 input.checked = setting.get();
167 setting.set(input.checked);
169 input.addEventListener("click", listener, false);
171 var label = document.createElement("label");
172 label.appendChild(input);
173 label.appendChild(document.createTextNode(name));
174 if (omitParagraphElement)
177 var p = document.createElement("p");
178 p.appendChild(label);
182 _createSelectSetting: function(name, options, setting)
184 var fieldsetElement = document.createElement("fieldset");
185 fieldsetElement.createChild("label").textContent = name;
187 var select = document.createElement("select");
188 var settingValue = setting.get();
190 for (var i = 0; i < options.length; ++i) {
191 var option = options[i];
192 select.add(new Option(option[0], option[1]));
193 if (settingValue === option[1])
194 select.selectedIndex = i;
197 function changeListener(e)
199 setting.set(e.target.value);
202 select.addEventListener("change", changeListener, false);
203 fieldsetElement.appendChild(select);
205 var p = document.createElement("p");
206 p.appendChild(fieldsetElement);
210 _createRadioSetting: function(name, options, setting)
212 var pp = document.createElement("p");
213 var fieldsetElement = document.createElement("fieldset");
214 var legendElement = document.createElement("legend");
215 legendElement.textContent = name;
216 fieldsetElement.appendChild(legendElement);
218 function clickListener(e)
220 setting.set(e.target.value);
223 var settingValue = setting.get();
224 for (var i = 0; i < options.length; ++i) {
225 var p = document.createElement("p");
226 var label = document.createElement("label");
227 p.appendChild(label);
229 var input = document.createElement("input");
230 input.type = "radio";
231 input.name = setting.name;
232 input.value = options[i][0];
233 input.addEventListener("click", clickListener, false);
234 if (settingValue == input.value)
235 input.checked = true;
237 label.appendChild(input);
238 label.appendChild(document.createTextNode(options[i][1]));
240 fieldsetElement.appendChild(p);
243 pp.appendChild(fieldsetElement);
247 _createCustomSetting: function(name, element)
249 var p = document.createElement("p");
250 var fieldsetElement = document.createElement("fieldset");
251 fieldsetElement.createChild("label").textContent = name;
252 fieldsetElement.appendChild(element);
253 p.appendChild(fieldsetElement);
257 __proto__: WebInspector.View.prototype
262 * @extends {WebInspector.SettingsTab}
264 WebInspector.GenericSettingsTab = function()
266 WebInspector.SettingsTab.call(this, WebInspector.UIString("General"));
268 var p = this._appendSection();
269 if (Preferences.exposeDisableCache)
270 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
271 var disableJSElement = this._createCheckboxSetting(WebInspector.UIString("Disable JavaScript"), WebInspector.settings.javaScriptDisabled);
272 p.appendChild(disableJSElement);
273 WebInspector.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisabledChanged, this);
274 this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
275 this._updateScriptDisabledCheckbox();
277 p = this._appendSection(WebInspector.UIString("Appearance"));
278 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show toolbar icons"), WebInspector.settings.showToolbarIcons));
280 p = this._appendSection(WebInspector.UIString("Elements"));
281 p.appendChild(this._createRadioSetting(WebInspector.UIString("Color format"), [
282 [ WebInspector.Color.Format.Original, WebInspector.UIString("As authored") ],
283 [ WebInspector.Color.Format.HEX, "HEX: #DAC0DE" ],
284 [ WebInspector.Color.Format.RGB, "RGB: rgb(128, 255, 255)" ],
285 [ WebInspector.Color.Format.HSL, "HSL: hsl(300, 80%, 90%)" ] ], WebInspector.settings.colorFormat));
286 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
287 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
288 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show Shadow DOM"), WebInspector.settings.showShadowDOM));
289 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show rulers"), WebInspector.settings.showMetricsRulers));
291 p = this._appendSection(WebInspector.UIString("Rendering"));
292 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects));
293 WebInspector.settings.showPaintRects.addChangeListener(this._showPaintRectsChanged, this);
295 if (Capabilities.canShowDebugBorders) {
296 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show composited layer borders"), WebInspector.settings.showDebugBorders));
297 WebInspector.settings.showDebugBorders.addChangeListener(this._showDebugBordersChanged, this);
299 if (Capabilities.canShowFPSCounter) {
300 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show FPS meter"), WebInspector.settings.showFPSCounter));
301 WebInspector.settings.showFPSCounter.addChangeListener(this._showFPSCounterChanged, this);
303 if (Capabilities.canContinuouslyPaint) {
304 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable continuous page repainting"), WebInspector.settings.continuousPainting));
305 WebInspector.settings.continuousPainting.addChangeListener(this._continuousPaintingChanged, this);
308 p = this._appendSection(WebInspector.UIString("Sources"));
309 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
310 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show whitespace"), WebInspector.settings.showWhitespaceInEditor));
311 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled));
312 if (WebInspector.experimentsSettings.isEnabled("sass"))
313 p.appendChild(this._createCSSAutoReloadControls());
314 var indentationElement = this._createSelectSetting(WebInspector.UIString("Indentation"), [
315 [ WebInspector.UIString("2 spaces"), WebInspector.TextEditorModel.Indent.TwoSpaces ],
316 [ WebInspector.UIString("4 spaces"), WebInspector.TextEditorModel.Indent.FourSpaces ],
317 [ WebInspector.UIString("8 spaces"), WebInspector.TextEditorModel.Indent.EightSpaces ],
318 [ WebInspector.UIString("Tab character"), WebInspector.TextEditorModel.Indent.TabCharacter ]
319 ], WebInspector.settings.textEditorIndent);
320 indentationElement.firstChild.className = "toplevel";
321 p.appendChild(indentationElement);
323 p = this._appendSection(WebInspector.UIString("Profiler"));
324 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show objects' hidden properties"), WebInspector.settings.showHeapSnapshotObjectsHiddenProperties));
325 if (WebInspector.experimentsSettings.nativeMemorySnapshots.isEnabled())
326 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show uninstrumented native memory"), WebInspector.settings.showNativeSnapshotUninstrumentedSize));
328 if (Capabilities.timelineCanMonitorMainThread) {
329 p = this._appendSection(WebInspector.UIString("Timeline"));
330 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show CPU activity on the ruler"), WebInspector.settings.showCpuOnTimelineRuler));
333 p = this._appendSection(WebInspector.UIString("Console"));
334 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
335 p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
337 if (WebInspector.extensionServer.hasExtensions()) {
338 var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
339 p = this._appendSection(WebInspector.UIString("Extensions"));
340 p.appendChild(this._createCustomSetting(WebInspector.UIString("Open links in"), handlerSelector.element));
344 WebInspector.GenericSettingsTab.prototype = {
345 _showPaintRectsChanged: function()
347 PageAgent.setShowPaintRects(WebInspector.settings.showPaintRects.get());
350 _showDebugBordersChanged: function()
352 PageAgent.setShowDebugBorders(WebInspector.settings.showDebugBorders.get());
355 _showFPSCounterChanged: function()
357 PageAgent.setShowFPSCounter(WebInspector.settings.showFPSCounter.get());
360 _continuousPaintingChanged: function()
362 PageAgent.setContinuousPaintingEnabled(WebInspector.settings.continuousPainting.get());
365 _updateScriptDisabledCheckbox: function()
367 function executionStatusCallback(error, status)
369 if (error || !status)
374 this._disableJSCheckbox.checked = true;
375 this._disableJSCheckbox.disabled = true;
378 this._disableJSCheckbox.checked = true;
381 this._disableJSCheckbox.checked = false;
386 PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this));
389 _javaScriptDisabledChanged: function()
391 // We need to manually update the checkbox state, since enabling JavaScript in the page can actually uncover the "forbidden" state.
392 PageAgent.setScriptExecutionDisabled(WebInspector.settings.javaScriptDisabled.get(), this._updateScriptDisabledCheckbox.bind(this));
395 _createCSSAutoReloadControls: function()
397 var fragment = document.createDocumentFragment();
398 var labelElement = fragment.createChild("label");
399 var checkboxElement = labelElement.createChild("input");
400 checkboxElement.type = "checkbox";
401 checkboxElement.checked = WebInspector.settings.cssReloadEnabled.get();
402 checkboxElement.addEventListener("click", checkboxClicked, false);
403 labelElement.appendChild(document.createTextNode(WebInspector.UIString("Auto-reload CSS upon Sass save")));
405 var fieldsetElement = fragment.createChild("fieldset");
406 fieldsetElement.disabled = !checkboxElement.checked;
407 var p = fieldsetElement.createChild("p");
408 p.appendChild(document.createTextNode(WebInspector.UIString("Timeout (ms)")));
409 p.appendChild(document.createTextNode(" "));
410 var timeoutInput = p.createChild("input");
411 timeoutInput.value = WebInspector.settings.cssReloadTimeout.get();
412 timeoutInput.className = "numeric";
413 timeoutInput.style.width = "60px";
414 timeoutInput.maxLength = 8;
415 timeoutInput.addEventListener("blur", blurListener, false);
418 function checkboxClicked()
420 var reloadEnabled = checkboxElement.checked;
421 WebInspector.settings.cssReloadEnabled.set(reloadEnabled);
422 fieldsetElement.disabled = !reloadEnabled;
425 function blurListener()
427 var value = timeoutInput.value;
428 if (!isFinite(value) || value <= 0) {
429 timeoutInput.value = WebInspector.settings.cssReloadTimeout.get();
432 WebInspector.settings.cssReloadTimeout.set(Number(value));
436 __proto__: WebInspector.SettingsTab.prototype
441 * @extends {WebInspector.SettingsTab}
443 WebInspector.OverridesSettingsTab = function()
445 WebInspector.SettingsTab.call(this, WebInspector.UIString("Overrides"), "overrides-tab-content");
446 this._view = new WebInspector.OverridesView();
447 this.containerElement.parentElement.appendChild(this._view.containerElement);
448 this.containerElement.removeSelf();
449 this.containerElement = this._view.containerElement;
452 WebInspector.OverridesSettingsTab.prototype = {
453 __proto__: WebInspector.SettingsTab.prototype
458 * @extends {WebInspector.SettingsTab}
460 WebInspector.WorkspaceSettingsTab = function()
462 WebInspector.SettingsTab.call(this, WebInspector.UIString("Workspace"), "workspace-tab-content");
463 this._createFileSystemsEditor();
464 this._createFileMappingEditor();
467 WebInspector.WorkspaceSettingsTab.prototype = {
468 _createFileSystemsEditor: function()
470 var p = this._appendSection(WebInspector.UIString("File systems"));
471 this._fileSystemsEditor = p.createChild("p", "file-systems-editor");
473 this._addFileSystemRowElement = this._fileSystemsEditor.createChild("div", "workspace-settings-row");
474 var addFileSystemButton = this._addFileSystemRowElement.createChild("input", "file-system-add-button");
475 addFileSystemButton.type = "button";
476 addFileSystemButton.value = WebInspector.UIString("Add file system");
477 addFileSystemButton.addEventListener("click", this._addFileSystemClicked.bind(this));
479 var fileSystemPaths = WebInspector.isolatedFileSystemModel.mapping().fileSystemPaths();
480 for (var i = 0; i < fileSystemPaths.length; ++i)
481 this._addFileSystemRow(fileSystemPaths[i]);
483 return this._fileSystemsEditor;
489 _createShowTextInput: function(className, value)
491 var inputElement = document.createElement("input");
492 inputElement.addStyleClass(className);
493 inputElement.type = "text";
494 inputElement.value = value;
495 inputElement.title = value;
496 inputElement.disabled = true;
503 _createEditTextInput: function(className, placeHolder)
505 var inputElement = document.createElement("input");
506 inputElement.addStyleClass(className);
507 inputElement.type = "text";
508 inputElement.placeholder = placeHolder;
513 * @param {function(Event)} handler
516 _createRemoveButton: function(handler)
518 var removeButton = document.createElement("button");
519 removeButton.addStyleClass("button");
520 removeButton.addStyleClass("remove-button");
521 removeButton.value = WebInspector.UIString("Remove");
522 removeButton.addEventListener("click", handler, false);
527 * @param {function(Event)} handler
530 _createAddButton: function(handler)
532 var addButton = document.createElement("button");
533 addButton.addStyleClass("button");
534 addButton.addStyleClass("add-button");
535 addButton.value = WebInspector.UIString("Add");
536 addButton.addEventListener("click", handler, false);
541 * @param {string} fileSystemPath
543 _addFileSystemRow: function(fileSystemPath)
545 var fileSystemRow = document.createElement("div");
546 fileSystemRow.addStyleClass("workspace-settings-row");
547 fileSystemRow.addStyleClass("file-system-row");
548 this._fileSystemsEditor.insertBefore(fileSystemRow, this._addFileSystemRowElement);
550 fileSystemRow.appendChild(this._createShowTextInput("file-system-path", fileSystemPath));
551 var removeFileSystemButton = this._createRemoveButton(removeFileSystemClicked.bind(this));
552 fileSystemRow.appendChild(removeFileSystemButton);
554 function removeFileSystemClicked()
556 removeFileSystemButton.disabled = true;
557 WebInspector.isolatedFileSystemModel.removeFileSystem(fileSystemPath, fileSystemRemoved.bind(this));
560 function fileSystemRemoved()
562 this._fileSystemsEditor.removeChild(fileSystemRow);
563 removeFileSystemButton.disabled = false;
567 _addFileSystemClicked: function()
569 WebInspector.isolatedFileSystemModel.addFileSystem(this._fileSystemAdded.bind(this));
573 * @param {?string} fileSystemPath
575 _fileSystemAdded: function(fileSystemPath)
578 this._addFileSystemRow(fileSystemPath);
581 _createFileMappingEditor: function()
583 var p = this._appendSection(WebInspector.UIString("Mappings"));
584 this._fileMappingEditor = p.createChild("p", "file-mappings-editor");
586 this._addMappingRowElement = this._fileMappingEditor.createChild("div", "workspace-settings-row");
588 this._urlInputElement = this._createEditTextInput("file-mapping-url", WebInspector.UIString("File mapping url"));
589 this._addMappingRowElement.appendChild(this._urlInputElement);
590 this._pathInputElement = this._createEditTextInput("file-mapping-path", WebInspector.UIString("File mapping path"));
591 this._addMappingRowElement.appendChild(this._pathInputElement);
593 this._addMappingRowElement.appendChild(this._createAddButton(this._addFileMappingClicked.bind(this)));
595 var mappingEntries = WebInspector.fileMapping.mappingEntries();
596 for (var i = 0; i < mappingEntries.length; ++i)
597 this._addMappingRow(mappingEntries[i]);
599 return this._fileMappingEditor;
603 * @param {WebInspector.FileMapping.Entry} mappingEntry
605 _addMappingRow: function(mappingEntry)
607 var fileMappingRow = document.createElement("div");
608 fileMappingRow.addStyleClass("workspace-settings-row");
609 this._fileMappingEditor.insertBefore(fileMappingRow, this._addMappingRowElement);
611 fileMappingRow.appendChild(this._createShowTextInput("file-mapping-url", mappingEntry.urlPrefix));
612 fileMappingRow.appendChild(this._createShowTextInput("file-mapping-path", mappingEntry.pathPrefix));
614 fileMappingRow.appendChild(this._createRemoveButton(removeMappingClicked.bind(this)));
616 function removeMappingClicked()
618 var index = Array.prototype.slice.call(fileMappingRow.parentElement.childNodes).indexOf(fileMappingRow);
619 var mappingEntries = WebInspector.fileMapping.mappingEntries();
620 mappingEntries.splice(index, 1);
621 WebInspector.fileMapping.setMappingEntries(mappingEntries);
622 this._fileMappingEditor.removeChild(fileMappingRow);
626 _addFileMappingClicked: function()
628 var url = this._urlInputElement.value;
629 var path = this._pathInputElement.value;
632 var mappingEntries = WebInspector.fileMapping.mappingEntries();
633 if (url[url.length - 1] !== "/")
635 if (path[path.length - 1] !== "/")
637 var mappingEntry = new WebInspector.FileMapping.Entry(url, path);
638 mappingEntries.push(mappingEntry);
639 WebInspector.fileMapping.setMappingEntries(mappingEntries);
640 this._addMappingRow(mappingEntry);
641 this._urlInputElement.value = "";
642 this._pathInputElement.value = "";
645 __proto__: WebInspector.SettingsTab.prototype
650 * @extends {WebInspector.SettingsTab}
652 WebInspector.ExperimentsSettingsTab = function()
654 WebInspector.SettingsTab.call(this, WebInspector.UIString("Experiments"), "experiments-tab-content");
656 var experiments = WebInspector.experimentsSettings.experiments;
657 if (experiments.length) {
658 var experimentsSection = this._appendSection();
659 experimentsSection.appendChild(this._createExperimentsWarningSubsection());
660 for (var i = 0; i < experiments.length; ++i)
661 experimentsSection.appendChild(this._createExperimentCheckbox(experiments[i]));
665 WebInspector.ExperimentsSettingsTab.prototype = {
667 * @return {Element} element
669 _createExperimentsWarningSubsection: function()
671 var subsection = document.createElement("div");
672 var warning = subsection.createChild("span", "settings-experiments-warning-subsection-warning");
673 warning.textContent = WebInspector.UIString("WARNING:");
674 subsection.appendChild(document.createTextNode(" "));
675 var message = subsection.createChild("span", "settings-experiments-warning-subsection-message");
676 message.textContent = WebInspector.UIString("These experiments could be dangerous and may require restart.");
680 _createExperimentCheckbox: function(experiment)
682 var input = document.createElement("input");
683 input.type = "checkbox";
684 input.name = experiment.name;
685 input.checked = experiment.isEnabled();
688 experiment.setEnabled(input.checked);
690 input.addEventListener("click", listener, false);
692 var p = document.createElement("p");
693 var label = document.createElement("label");
694 label.appendChild(input);
695 label.appendChild(document.createTextNode(WebInspector.UIString(experiment.title)));
696 p.appendChild(label);
700 __proto__: WebInspector.SettingsTab.prototype
706 WebInspector.SettingsController = function()
708 this._statusBarButton = new WebInspector.StatusBarButton(WebInspector.UIString("Settings"), "settings-status-bar-item");
709 if (WebInspector.experimentsSettings.showOverridesInDrawer.isEnabled())
710 this._statusBarButton.element.addEventListener("mousedown", this._mouseDown.bind(this), false);
712 this._statusBarButton.element.addEventListener("mouseup", this._mouseUp.bind(this), false);
714 /** @type {?WebInspector.SettingsScreen} */
715 this._settingsScreen;
718 WebInspector.SettingsController.prototype =
722 return this._statusBarButton.element;
726 * @param {Event} event
728 _mouseDown: function(event)
730 var contextMenu = new WebInspector.ContextMenu(event);
731 contextMenu.appendItem(WebInspector.UIString("Overrides"), showOverrides.bind(this));
732 contextMenu.appendItem(WebInspector.UIString("Settings"), showSettings.bind(this));
734 function showOverrides()
736 if (this._settingsScreenVisible)
737 this._hideSettingsScreen();
738 WebInspector.OverridesView.showInDrawer();
741 function showSettings()
743 if (!this._settingsScreenVisible)
744 this.showSettingsScreen();
747 contextMenu.showSoftMenu();
751 * @param {Event} event
753 _mouseUp: function(event)
755 this.showSettingsScreen();
758 _onHideSettingsScreen: function()
760 delete this._settingsScreenVisible;
764 * @param {string=} tabId
766 showSettingsScreen: function(tabId)
768 if (!this._settingsScreen)
769 this._settingsScreen = new WebInspector.SettingsScreen(this._onHideSettingsScreen.bind(this));
772 this._settingsScreen.selectTab(tabId);
774 this._settingsScreen.showModal();
775 this._settingsScreenVisible = true;
778 _hideSettingsScreen: function()
780 if (this._settingsScreen)
781 this._settingsScreen.hide();
786 if (this._settingsScreen && this._settingsScreen.isShowing())
787 this._settingsScreen.doResize();