| 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 /** | 100 /** |
| 101 * @param {!WebInspector.AuditCategory} category | 101 * @param {!WebInspector.AuditCategory} category |
| 102 */ | 102 */ |
| 103 addCategory: function(category) | 103 addCategory: function(category) |
| 104 { | 104 { |
| 105 if (!this._sortedCategories.length) | 105 if (!this._sortedCategories.length) |
| 106 this._createLauncherUI(); | 106 this._createLauncherUI(); |
| 107 | 107 |
| 108 var selectedCategories = this._selectedCategoriesSetting.get(); | 108 var selectedCategories = this._selectedCategoriesSetting.get(); |
| 109 var categoryElement = this._createCategoryElement(category.displayName,
category.id); | 109 var categoryElement = this._createCategoryElement(category.displayName,
category.id); |
| 110 category._checkboxElement = categoryElement.firstChild; | 110 category._checkboxElement = categoryElement.checkboxElement; |
| 111 if (this._selectAllCheckboxElement.checked || selectedCategories[categor
y.displayName]) { | 111 if (this._selectAllCheckboxElement.checked || selectedCategories[categor
y.displayName]) { |
| 112 category._checkboxElement.checked = true; | 112 category._checkboxElement.checked = true; |
| 113 ++this._currentCategoriesCount; | 113 ++this._currentCategoriesCount; |
| 114 } | 114 } |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * @param {!WebInspector.AuditCategory} a | 117 * @param {!WebInspector.AuditCategory} a |
| 118 * @param {!WebInspector.AuditCategory} b | 118 * @param {!WebInspector.AuditCategory} b |
| 119 * @return {number} | 119 * @return {number} |
| 120 */ | 120 */ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 _categoryClicked: function(event) | 215 _categoryClicked: function(event) |
| 216 { | 216 { |
| 217 this._currentCategoriesCount += event.target.checked ? 1 : -1; | 217 this._currentCategoriesCount += event.target.checked ? 1 : -1; |
| 218 this._selectAllCheckboxElement.checked = this._currentCategoriesCount ==
= this._sortedCategories.length; | 218 this._selectAllCheckboxElement.checked = this._currentCategoriesCount ==
= this._sortedCategories.length; |
| 219 this._selectedCategoriesUpdated(true); | 219 this._selectedCategoriesUpdated(true); |
| 220 }, | 220 }, |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * @param {string} title | 223 * @param {string} title |
| 224 * @param {string} id | 224 * @param {string=} id |
| 225 */ | 225 */ |
| 226 _createCategoryElement: function(title, id) | 226 _createCategoryElement: function(title, id) |
| 227 { | 227 { |
| 228 var labelElement = createElement("label"); | 228 var labelElement = createCheckboxLabel(title); |
| 229 labelElement.id = this._categoryIdPrefix + id; | 229 if (id) { |
| 230 | 230 labelElement.id = this._categoryIdPrefix + id; |
| 231 var element = createElement("input"); | 231 labelElement.checkboxElement.addEventListener("click", this._boundCa
tegoryClickListener, false); |
| 232 element.type = "checkbox"; | 232 } |
| 233 if (id !== "") | |
| 234 element.addEventListener("click", this._boundCategoryClickListener,
false); | |
| 235 labelElement.appendChild(element); | |
| 236 labelElement.createTextChild(title); | |
| 237 labelElement.__displayName = title; | 233 labelElement.__displayName = title; |
| 238 | 234 |
| 239 return labelElement; | 235 return labelElement; |
| 240 }, | 236 }, |
| 241 | 237 |
| 242 _createLauncherUI: function() | 238 _createLauncherUI: function() |
| 243 { | 239 { |
| 244 this._headerElement = createElement("h1"); | 240 this._headerElement = createElement("h1"); |
| 245 this._headerElement.textContent = WebInspector.UIString("Select audits t
o run"); | 241 this._headerElement.textContent = WebInspector.UIString("Select audits t
o run"); |
| 246 | 242 |
| 247 for (var child = 0; child < this._contentElement.children.length; ++chil
d) | 243 for (var child = 0; child < this._contentElement.children.length; ++chil
d) |
| 248 this._contentElement.removeChild(this._contentElement.children[child
]); | 244 this._contentElement.removeChild(this._contentElement.children[child
]); |
| 249 | 245 |
| 250 this._contentElement.appendChild(this._headerElement); | 246 this._contentElement.appendChild(this._headerElement); |
| 251 | 247 |
| 252 /** | 248 /** |
| 253 * @param {!Event} event | 249 * @param {!Event} event |
| 254 * @this {WebInspector.AuditLauncherView} | 250 * @this {WebInspector.AuditLauncherView} |
| 255 */ | 251 */ |
| 256 function handleSelectAllClick(event) | 252 function handleSelectAllClick(event) |
| 257 { | 253 { |
| 258 this._selectAllClicked(event.target.checked, true); | 254 this._selectAllClicked(event.target.checked, true); |
| 259 } | 255 } |
| 260 var categoryElement = this._createCategoryElement(WebInspector.UIString(
"Select All"), ""); | 256 var categoryElement = this._createCategoryElement(WebInspector.UIString(
"Select All"), ""); |
| 261 categoryElement.id = "audit-launcher-selectall"; | 257 categoryElement.id = "audit-launcher-selectall"; |
| 262 this._selectAllCheckboxElement = categoryElement.firstChild; | 258 this._selectAllCheckboxElement = categoryElement.checkboxElement; |
| 263 this._selectAllCheckboxElement.checked = this._selectedCategoriesSetting
.get()[WebInspector.AuditLauncherView.AllCategoriesKey]; | 259 this._selectAllCheckboxElement.checked = this._selectedCategoriesSetting
.get()[WebInspector.AuditLauncherView.AllCategoriesKey]; |
| 264 this._selectAllCheckboxElement.addEventListener("click", handleSelectAll
Click.bind(this), false); | 260 this._selectAllCheckboxElement.addEventListener("click", handleSelectAll
Click.bind(this), false); |
| 265 this._contentElement.appendChild(categoryElement); | 261 this._contentElement.appendChild(categoryElement); |
| 266 | 262 |
| 267 this._categoriesElement = this._contentElement.createChild("fieldset", "
audit-categories-container"); | 263 this._categoriesElement = this._contentElement.createChild("fieldset", "
audit-categories-container"); |
| 268 this._currentCategoriesCount = 0; | 264 this._currentCategoriesCount = 0; |
| 269 | 265 |
| 270 this._contentElement.createChild("div", "flexible-space"); | 266 this._contentElement.createChild("div", "flexible-space"); |
| 271 | 267 |
| 272 this._buttonContainerElement = this._contentElement.createChild("div", "
button-container"); | 268 this._buttonContainerElement = this._contentElement.createChild("div", "
button-container"); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 }, | 308 }, |
| 313 | 309 |
| 314 _updateButton: function() | 310 _updateButton: function() |
| 315 { | 311 { |
| 316 this._launchButton.textContent = this._auditRunning ? WebInspector.UIStr
ing("Stop") : WebInspector.UIString("Run"); | 312 this._launchButton.textContent = this._auditRunning ? WebInspector.UIStr
ing("Stop") : WebInspector.UIString("Run"); |
| 317 this._launchButton.disabled = !this._currentCategoriesCount; | 313 this._launchButton.disabled = !this._currentCategoriesCount; |
| 318 }, | 314 }, |
| 319 | 315 |
| 320 __proto__: WebInspector.VBox.prototype | 316 __proto__: WebInspector.VBox.prototype |
| 321 } | 317 } |
| OLD | NEW |