Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: Source/devtools/front_end/console/ConsoleView.js

Issue 367093003: DevTools: More code reduce via using document.createElementWithClass and document.createChild. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (hideContextSelector) 66 if (hideContextSelector)
67 this._executionContextSelector.element.classList.add("hidden"); 67 this._executionContextSelector.element.classList.add("hidden");
68 68
69 this._filterBar = new WebInspector.FilterBar(); 69 this._filterBar = new WebInspector.FilterBar();
70 70
71 this._preserveLogCheckbox = new WebInspector.StatusBarCheckbox(WebInspector. UIString("Preserve log")); 71 this._preserveLogCheckbox = new WebInspector.StatusBarCheckbox(WebInspector. UIString("Preserve log"));
72 WebInspector.SettingsUI.bindCheckbox(this._preserveLogCheckbox.inputElement, WebInspector.settings.preserveConsoleLog); 72 WebInspector.SettingsUI.bindCheckbox(this._preserveLogCheckbox.inputElement, WebInspector.settings.preserveConsoleLog);
73 this._preserveLogCheckbox.element.title = WebInspector.UIString("Do not clea r log on page reload / navigation."); 73 this._preserveLogCheckbox.element.title = WebInspector.UIString("Do not clea r log on page reload / navigation.");
74 74
75 var statusBarElement = this._contentsElement.createChild("div", "console-sta tus-bar"); 75 var statusBarElement = this._contentsElement.createChild("div", "console-sta tus-bar");
76 statusBarElement.appendChild(this._clearConsoleButton.element); 76 statusBarElement.appendChildren(this._clearConsoleButton.element, this._filt erBar.filterButton().element, this._executionContextSelector.element, this._pres erveLogCheckbox.element);
77 statusBarElement.appendChild(this._filterBar.filterButton().element);
78 statusBarElement.appendChild(this._executionContextSelector.element);
79 statusBarElement.appendChild(this._preserveLogCheckbox.element);
80 77
81 this._filtersContainer = this._contentsElement.createChild("div", "console-f ilters-header hidden"); 78 this._filtersContainer = this._contentsElement.createChild("div", "console-f ilters-header hidden");
82 this._filtersContainer.appendChild(this._filterBar.filtersElement()); 79 this._filtersContainer.appendChild(this._filterBar.filtersElement());
83 this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggle d, this._onFiltersToggled, this); 80 this._filterBar.addEventListener(WebInspector.FilterBar.Events.FiltersToggle d, this._onFiltersToggled, this);
84 this._filterBar.setName("consoleView"); 81 this._filterBar.setName("consoleView");
85 this._filter.addFilters(this._filterBar); 82 this._filter.addFilters(this._filterBar);
86 83
87 this._viewport = new WebInspector.ViewportControl(this); 84 this._viewport = new WebInspector.ViewportControl(this);
88 this._viewport.setStickToBottom(true); 85 this._viewport.setStickToBottom(true);
89 this._viewport.contentElement().classList.add("console-group"); 86 this._viewport.contentElement().classList.add("console-group", "console-grou p-messages");
90 this._viewport.contentElement().classList.add("console-group-messages");
91 this._contentsElement.appendChild(this._viewport.element); 87 this._contentsElement.appendChild(this._viewport.element);
92 this._messagesElement = this._viewport.element; 88 this._messagesElement = this._viewport.element;
93 this._messagesElement.id = "console-messages"; 89 this._messagesElement.id = "console-messages";
94 this._messagesElement.classList.add("monospace"); 90 this._messagesElement.classList.add("monospace");
95 this._messagesElement.addEventListener("click", this._messagesClicked.bind(t his), true); 91 this._messagesElement.addEventListener("click", this._messagesClicked.bind(t his), true);
96 this._scrolledToBottom = true; 92 this._scrolledToBottom = true;
97 93
98 this._filterStatusMessageElement = document.createElementWithClass("div", "c onsole-message"); 94 this._filterStatusMessageElement = document.createElementWithClass("div", "c onsole-message");
99 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m essagesElement.firstChild); 95 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m essagesElement.firstChild);
100 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ("span", "console-info"); 96 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ("span", "console-info");
101 this._filterStatusMessageElement.createTextChild(" "); 97 this._filterStatusMessageElement.createTextChild(" ");
102 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info node-link"); 98 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info node-link");
103 resetFiltersLink.textContent = WebInspector.UIString("Show all messages."); 99 resetFiltersLink.textContent = WebInspector.UIString("Show all messages.");
104 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true); 100 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true);
105 101
106 this._topGroup = WebInspector.ConsoleGroup.createTopGroup(); 102 this._topGroup = WebInspector.ConsoleGroup.createTopGroup();
107 this._currentGroup = this._topGroup; 103 this._currentGroup = this._topGroup;
108 104
109 this._promptElement = this._messagesElement.createChild("div", "source-code" ); 105 this._promptElement = this._messagesElement.createChild("div", "source-code" );
110 this._promptElement.id = "console-prompt"; 106 this._promptElement.id = "console-prompt";
111 this._promptElement.spellcheck = false; 107 this._promptElement.spellcheck = false;
112 this._messagesElement.appendChild(this._promptElement);
113 108
114 this._showAllMessagesCheckbox = new WebInspector.StatusBarCheckbox(WebInspec tor.UIString("Show all messages")); 109 this._showAllMessagesCheckbox = new WebInspector.StatusBarCheckbox(WebInspec tor.UIString("Show all messages"));
115 this._showAllMessagesCheckbox.inputElement.checked = true; 110 this._showAllMessagesCheckbox.inputElement.checked = true;
116 this._showAllMessagesCheckbox.inputElement.addEventListener("change", this._ updateMessageList.bind(this), false); 111 this._showAllMessagesCheckbox.inputElement.addEventListener("change", this._ updateMessageList.bind(this), false);
117 112
118 if (!WebInspector.experimentsSettings.workersInMainWindow.isEnabled()) 113 if (!WebInspector.experimentsSettings.workersInMainWindow.isEnabled())
119 this._showAllMessagesCheckbox.element.classList.add("hidden"); 114 this._showAllMessagesCheckbox.element.classList.add("hidden");
120 115
121 statusBarElement.appendChild(this._showAllMessagesCheckbox.element); 116 statusBarElement.appendChild(this._showAllMessagesCheckbox.element);
122 117
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 regexObject.lastIndex = 0; 1105 regexObject.lastIndex = 0;
1111 return regexObject.test(this.text); 1106 return regexObject.test(this.text);
1112 }, 1107 },
1113 1108
1114 /** 1109 /**
1115 * @return {!Element} 1110 * @return {!Element}
1116 */ 1111 */
1117 contentElement: function() 1112 contentElement: function()
1118 { 1113 {
1119 if (!this._element) { 1114 if (!this._element) {
1120 this._element = document.createElement("div"); 1115 this._element = document.createElementWithClass("div", "console-user -command");
1121 this._element.message = this; 1116 this._element.message = this;
1122 this._element.className = "console-user-command";
1123 1117
1124 this._formatCommand(); 1118 this._formatCommand();
1125 this._element.appendChild(this._formattedCommand); 1119 this._element.appendChild(this._formattedCommand);
1126 } 1120 }
1127 return this._element; 1121 return this._element;
1128 }, 1122 },
1129 1123
1130 _formatCommand: function() 1124 _formatCommand: function()
1131 { 1125 {
1132 this._formattedCommand = document.createElement("span"); 1126 this._formattedCommand = document.createElementWithClass("span", "consol e-message-text source-code");
1133 this._formattedCommand.className = "console-message-text source-code";
1134 this._formattedCommand.textContent = this.text; 1127 this._formattedCommand.textContent = this.text;
1135 }, 1128 },
1136 1129
1137 __proto__: WebInspector.ConsoleViewMessage.prototype 1130 __proto__: WebInspector.ConsoleViewMessage.prototype
1138 } 1131 }
1139 1132
1140 /** 1133 /**
1141 * @constructor 1134 * @constructor
1142 * @extends {WebInspector.ConsoleViewMessage} 1135 * @extends {WebInspector.ConsoleViewMessage}
1143 * @param {!WebInspector.ConsoleMessage} message 1136 * @param {!WebInspector.ConsoleMessage} message
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { 1223 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = {
1231 /** 1224 /**
1232 * @return {boolean} 1225 * @return {boolean}
1233 */ 1226 */
1234 handleAction: function() 1227 handleAction: function()
1235 { 1228 {
1236 WebInspector.console.show(); 1229 WebInspector.console.show();
1237 return true; 1230 return true;
1238 } 1231 }
1239 } 1232 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/components/FlameChart.js ('k') | Source/devtools/front_end/elements/Spectrum.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698