Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var SourceRow = (function() { | 5 var SourceRow = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A SourceRow represents the row corresponding to a single SourceEntry | 9 * A SourceRow represents the row corresponding to a single SourceEntry |
| 10 * displayed by the EventsView. | 10 * displayed by the EventsView. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 this.description_ = sourceEntry.getDescription(); | 29 this.description_ = sourceEntry.getDescription(); |
| 30 | 30 |
| 31 this.createRow_(); | 31 this.createRow_(); |
| 32 this.onSourceUpdated(); | 32 this.onSourceUpdated(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SourceRow.prototype = { | 35 SourceRow.prototype = { |
| 36 createRow_: function() { | 36 createRow_: function() { |
| 37 // Create a row. | 37 // Create a row. |
| 38 var tr = addNode(this.parentView_.tableBody_, 'tr'); | 38 var tr = addNode(this.parentView_.tableBody_, 'tr'); |
| 39 tr._id = this.sourceEntry_.getSourceId(); | 39 tr._id = this.getSourceId(); |
| 40 tr.style.display = 'none'; | 40 tr.style.display = 'none'; |
| 41 this.row_ = tr; | 41 this.row_ = tr; |
| 42 | 42 |
| 43 var selectionCol = addNode(tr, 'td'); | 43 var selectionCol = addNode(tr, 'td'); |
| 44 var checkbox = addNode(selectionCol, 'input'); | 44 var checkbox = addNode(selectionCol, 'input'); |
| 45 checkbox.type = 'checkbox'; | 45 checkbox.type = 'checkbox'; |
| 46 | 46 |
| 47 var idCell = addNode(tr, 'td'); | 47 var idCell = addNode(tr, 'td'); |
| 48 idCell.style.textAlign = 'right'; | 48 idCell.style.textAlign = 'right'; |
| 49 | 49 |
| 50 var typeCell = addNode(tr, 'td'); | 50 var typeCell = addNode(tr, 'td'); |
| 51 var descriptionCell = addNode(tr, 'td'); | 51 var descriptionCell = addNode(tr, 'td'); |
| 52 this.descriptionCell_ = descriptionCell; | 52 this.descriptionCell_ = descriptionCell; |
| 53 | 53 |
| 54 // Connect listeners. | 54 // Connect listeners. |
| 55 checkbox.onchange = this.onCheckboxToggled_.bind(this); | 55 checkbox.onchange = this.onCheckboxToggled_.bind(this); |
| 56 | 56 |
| 57 var onclick = this.onClicked_.bind(this); | 57 var onclick = this.onClicked_.bind(this); |
| 58 idCell.onclick = onclick; | 58 idCell.onclick = onclick; |
| 59 typeCell.onclick = onclick; | 59 typeCell.onclick = onclick; |
| 60 descriptionCell.onclick = onclick; | 60 descriptionCell.onclick = onclick; |
| 61 | 61 |
| 62 tr.onmouseover = this.onMouseover_.bind(this); | 62 tr.onmouseover = this.onMouseover_.bind(this); |
| 63 tr.onmouseout = this.onMouseout_.bind(this); | 63 tr.onmouseout = this.onMouseout_.bind(this); |
| 64 | 64 |
| 65 // Set the cell values to match this source's data. | 65 // Set the cell values to match this source's data. |
| 66 if (this.sourceEntry_.getSourceId() >= 0) { | 66 if (this.getSourceId() >= 0) { |
| 67 addTextNode(idCell, this.sourceEntry_.getSourceId()); | 67 addTextNode(idCell, this.getSourceId()); |
| 68 } else { | 68 } else { |
| 69 addTextNode(idCell, '-'); | 69 addTextNode(idCell, '-'); |
| 70 } | 70 } |
| 71 var sourceTypeString = this.sourceEntry_.getSourceTypeString(); | 71 var sourceTypeString = this.sourceEntry_.getSourceTypeString(); |
| 72 addTextNode(typeCell, sourceTypeString); | 72 addTextNode(typeCell, sourceTypeString); |
| 73 this.updateDescription_(); | 73 this.updateDescription_(); |
| 74 | 74 |
| 75 // Add a CSS classname specific to this source type (so CSS can specify | 75 // Add a CSS classname specific to this source type (so CSS can specify |
| 76 // different stylings for different types). | 76 // different stylings for different types). |
| 77 changeClassName(this.row_, 'source_' + sourceTypeString, true); | 77 changeClassName(this.row_, 'source_' + sourceTypeString, true); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 172 |
| 173 // Check source type, if needed. | 173 // Check source type, if needed. |
| 174 if (filter.type) { | 174 if (filter.type) { |
| 175 var sourceType = this.sourceEntry_.getSourceTypeString().toLowerCase(); | 175 var sourceType = this.sourceEntry_.getSourceTypeString().toLowerCase(); |
| 176 if (filter.type.indexOf(sourceType) == -1) | 176 if (filter.type.indexOf(sourceType) == -1) |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Check source ID, if needed. | 180 // Check source ID, if needed. |
| 181 if (filter.id) { | 181 if (filter.id) { |
| 182 if (filter.id.indexOf(this.sourceEntry_.getSourceId() + '') == -1) | 182 if (filter.id.indexOf(this.getSourceId() + '') == -1) |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 if (filter.text == '') | 186 if (filter.text == '') |
| 187 return true; | 187 return true; |
| 188 | 188 |
| 189 var filterText = filter.text; | 189 // The description is not always contained in one of the log entries. |
| 190 var entryText = this.sourceEntry_.printAsText().toLowerCase(); | 190 if (this.description_.toLowerCase().indexOf(filter.text) != -1) |
| 191 return true; | |
| 191 | 192 |
| 192 return entryText.indexOf(filterText) != -1; | 193 var entryText = JSON.stringify(this.sourceEntry_.getLogEntries()); |
|
mmenke
2011/12/08 21:50:28
This doesn't work quite as well as the old code, s
| |
| 194 return entryText.toLowerCase().indexOf(filter.text) != -1; | |
| 193 }, | 195 }, |
| 194 | 196 |
| 195 isSelected: function() { | 197 isSelected: function() { |
| 196 return this.isSelected_; | 198 return this.isSelected_; |
| 197 }, | 199 }, |
| 198 | 200 |
| 199 setSelected: function(isSelected) { | 201 setSelected: function(isSelected) { |
| 200 if (isSelected == this.isSelected()) | 202 if (isSelected == this.isSelected()) |
| 201 return; | 203 return; |
| 202 | 204 |
| 203 this.isSelected_ = isSelected; | 205 this.isSelected_ = isSelected; |
| 204 | 206 |
| 205 this.setSelectedStyles(isSelected); | 207 this.setSelectedStyles(isSelected); |
| 206 this.parentView_.modifySelectionArray(this, isSelected); | 208 this.parentView_.modifySelectionArray(this.getSourceId(), isSelected); |
| 207 this.parentView_.onSelectionChanged(); | 209 this.parentView_.onSelectionChanged(); |
| 208 }, | 210 }, |
| 209 | 211 |
| 210 setSelectedStyles: function(isSelected) { | 212 setSelectedStyles: function(isSelected) { |
| 211 this.isSelected_ = isSelected; | 213 this.isSelected_ = isSelected; |
| 212 this.getSelectionCheckbox().checked = isSelected; | 214 this.getSelectionCheckbox().checked = isSelected; |
| 213 this.updateClass_(); | 215 this.updateClass_(); |
| 214 }, | 216 }, |
| 215 | 217 |
| 216 setMouseoverStyle: function(isMouseOver) { | 218 setMouseoverStyle: function(isMouseOver) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 238 }, | 240 }, |
| 239 | 241 |
| 240 onCheckboxToggled_: function() { | 242 onCheckboxToggled_: function() { |
| 241 this.setSelected(this.getSelectionCheckbox().checked); | 243 this.setSelected(this.getSelectionCheckbox().checked); |
| 242 }, | 244 }, |
| 243 | 245 |
| 244 getSelectionCheckbox: function() { | 246 getSelectionCheckbox: function() { |
| 245 return this.row_.childNodes[0].firstChild; | 247 return this.row_.childNodes[0].firstChild; |
| 246 }, | 248 }, |
| 247 | 249 |
| 250 getSourceId: function() { | |
| 251 return this.sourceEntry_.getSourceId(); | |
| 252 }, | |
| 253 | |
| 248 /** | 254 /** |
| 249 * Returns source ID of the entry whose row is currently above this one's. | 255 * Returns source ID of the entry whose row is currently above this one's. |
| 250 * Returns null if no such node exists. | 256 * Returns null if no such node exists. |
| 251 */ | 257 */ |
| 252 getPreviousNodeSourceId: function() { | 258 getPreviousNodeSourceId: function() { |
| 253 var prevNode = this.row_.previousSibling; | 259 var prevNode = this.row_.previousSibling; |
| 254 if (prevNode == null) | 260 if (prevNode == null) |
| 255 return null; | 261 return null; |
| 256 return prevNode._id; | 262 return prevNode._id; |
| 257 }, | 263 }, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 283 | 289 |
| 284 remove: function() { | 290 remove: function() { |
| 285 this.setSelected(false); | 291 this.setSelected(false); |
| 286 this.setIsMatchedByFilter(false); | 292 this.setIsMatchedByFilter(false); |
| 287 this.row_.parentNode.removeChild(this.row_); | 293 this.row_.parentNode.removeChild(this.row_); |
| 288 } | 294 } |
| 289 }; | 295 }; |
| 290 | 296 |
| 291 return SourceRow; | 297 return SourceRow; |
| 292 })(); | 298 })(); |
| OLD | NEW |