OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 } | 136 } |
137 | 137 |
138 /** | 138 /** |
139 * @constructor | 139 * @constructor |
140 * @extends {WebInspector.NavigatorView} | 140 * @extends {WebInspector.NavigatorView} |
141 */ | 141 */ |
142 WebInspector.SourcesNavigatorView = function() | 142 WebInspector.SourcesNavigatorView = function() |
143 { | 143 { |
144 WebInspector.NavigatorView.call(this); | 144 WebInspector.NavigatorView.call(this); |
145 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); | 145 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); |
146 this.element.addEventListener("blur", this._handleBlur.bind(this), true); | |
147 this.element.addEventListener("click", this._handleClick.bind(this), true); | |
148 | |
149 this._scriptsTree.addEventListener(TreeOutline.Events.FilterChanged, this._h andleFilterChange.bind(this)); | |
146 } | 150 } |
147 | 151 |
148 WebInspector.SourcesNavigatorView.prototype = { | 152 WebInspector.SourcesNavigatorView.prototype = { |
149 /** | 153 /** |
150 * @override | 154 * @override |
151 * @param {!WebInspector.UISourceCode} uiSourceCode | 155 * @param {!WebInspector.UISourceCode} uiSourceCode |
152 * @return {boolean} | 156 * @return {boolean} |
153 */ | 157 */ |
154 accept: function(uiSourceCode) | 158 accept: function(uiSourceCode) |
155 { | 159 { |
156 if (!WebInspector.NavigatorView.prototype.accept(uiSourceCode)) | 160 if (!WebInspector.NavigatorView.prototype.accept(uiSourceCode)) |
157 return false; | 161 return false; |
158 return uiSourceCode.project().type() !== WebInspector.projectTypes.Conte ntScripts && uiSourceCode.project().type() !== WebInspector.projectTypes.Snippet s; | 162 return uiSourceCode.project().type() !== WebInspector.projectTypes.Conte ntScripts && uiSourceCode.project().type() !== WebInspector.projectTypes.Snippet s; |
159 }, | 163 }, |
160 | 164 |
161 /** | 165 /** |
166 * @param {!Event} event | |
167 */ | |
168 _handleClick: function (event){ | |
169 // remove filter | |
lushnikov
2016/03/14 20:56:38
we usually don't put comments in the code unless i
| |
170 this._scriptsTree.setCurrentSelectionFilterString(''); | |
171 }, | |
172 | |
173 /** | |
174 * @param {!Event} event | |
175 */ | |
176 _handleBlur: function (event) { | |
177 // remove filter | |
178 this._scriptsTree.setCurrentSelectionFilterString(''); | |
179 }, | |
180 | |
181 /** | |
182 * Does the highlighting for for when the filter changes | |
lushnikov
2016/03/14 20:56:37
ditto
| |
183 * @param {!WebInspector.Event} event | |
184 */ | |
185 _handleFilterChange: function (event){ | |
lushnikov
2016/03/14 20:56:37
style: no space after "function"
style: the { shou
| |
186 var node = this._rootNode.treeNode(); | |
187 | |
188 if (node){ | |
lushnikov
2016/03/14 20:56:38
style: space before {
| |
189 var treeOutline = event.data.treeOutline; | |
190 if (!treeOutline.selectedTreeElement.selectable) { | |
191 treeOutline.selectNext() || treeOutline.selectPrevious(); | |
lushnikov
2016/03/14 20:56:37
Style: we don't use {} for a one-line statements.
| |
192 } | |
193 | |
194 do { | |
195 if (node.titleText !== null) { | |
196 let titleText = node.titleText; | |
lushnikov
2016/03/14 20:56:37
we haven't been using LET and don't have a policy
| |
197 if (typeof titleText !== 'string'){ | |
198 titleText = titleText.textContent; | |
199 } | |
200 if (event.data.changeTo === null) { | |
lushnikov
2016/03/14 20:56:38
let's extract event.data and typecast it to the co
| |
201 node.title = titleText; | |
202 } else { | |
203 let newExp = new RegExp(event.data.changeTo.source, 'gi' ); | |
204 if (node.title) { | |
205 let parentSpan = createElementWithClass("span", "tre e-element-title"); | |
206 let match; | |
207 let offsetStart = 0; | |
208 while((match = newExp.exec(titleText)) !== null){ | |
209 let leftSpan = createElementWithClass("span"), | |
210 midSpan = createElementWithClass("span", "na vigator-tree-item-highlight"); | |
211 | |
212 leftSpan.textContent = titleText.substring(offse tStart, match.index); | |
213 parentSpan.appendChild(leftSpan); | |
214 midSpan.textContent = titleText.substr(match.ind ex, match[0].length); | |
215 parentSpan.appendChild(midSpan); | |
216 | |
217 offsetStart = match.index + match[0].length; | |
218 } | |
219 if (offsetStart !== titleText.length) { | |
220 let rightSpan = createElementWithClass("span"); | |
221 rightSpan.textContent = titleText.substr(offsetS tart); | |
222 parentSpan.appendChild(rightSpan); | |
223 } | |
224 node.title = parentSpan; | |
225 } | |
226 } | |
227 } | |
228 node = node.traverseNextTreeElement(true, null, true); | |
229 }while(node); | |
230 } | |
231 }, | |
232 | |
233 /** | |
162 * @param {!WebInspector.Event} event | 234 * @param {!WebInspector.Event} event |
163 */ | 235 */ |
164 _inspectedURLChanged: function(event) | 236 _inspectedURLChanged: function(event) |
165 { | 237 { |
166 var nodes = this._uiSourceCodeNodes.valuesArray(); | 238 var nodes = this._uiSourceCodeNodes.valuesArray(); |
167 for (var i = 0; i < nodes.length; ++i) { | 239 for (var i = 0; i < nodes.length; ++i) { |
168 var uiSourceCode = nodes[i].uiSourceCode(); | 240 var uiSourceCode = nodes[i].uiSourceCode(); |
169 var inspectedPageURL = WebInspector.targetManager.inspectedPageURL(); | 241 var inspectedPageURL = WebInspector.targetManager.inspectedPageURL(); |
170 if (inspectedPageURL && WebInspector.networkMapping.networkURL(uiSour ceCode) === inspectedPageURL) | 242 if (inspectedPageURL && WebInspector.networkMapping.networkURL(uiSour ceCode) === inspectedPageURL) |
171 this.revealUISourceCode(uiSourceCode, true); | 243 this.revealUISourceCode(uiSourceCode, true); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 /** | 361 /** |
290 * @override | 362 * @override |
291 */ | 363 */ |
292 sourceDeleted: function(uiSourceCode) | 364 sourceDeleted: function(uiSourceCode) |
293 { | 365 { |
294 this._handleRemoveSnippet(uiSourceCode); | 366 this._handleRemoveSnippet(uiSourceCode); |
295 }, | 367 }, |
296 | 368 |
297 __proto__: WebInspector.NavigatorView.prototype | 369 __proto__: WebInspector.NavigatorView.prototype |
298 } | 370 } |
OLD | NEW |