| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 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 * 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 * @param {string} subtitle | 77 * @param {string} subtitle |
| 78 * @param {boolean=} isLabel | 78 * @param {boolean=} isLabel |
| 79 */ | 79 */ |
| 80 constructor(title, subtitle, isLabel) { | 80 constructor(title, subtitle, isLabel) { |
| 81 this.element = createElementWithClass('div', 'list-item'); | 81 this.element = createElementWithClass('div', 'list-item'); |
| 82 if (isLabel) | 82 if (isLabel) |
| 83 this.element.classList.add('label'); | 83 this.element.classList.add('label'); |
| 84 | 84 |
| 85 this.titleElement = this.element.createChild('div', 'title'); | 85 this.titleElement = this.element.createChild('div', 'title'); |
| 86 this.subtitleElement = this.element.createChild('div', 'subtitle'); | 86 this.subtitleElement = this.element.createChild('div', 'subtitle'); |
| 87 | 87 /** @type {?Element} */ |
| 88 this._actionElement = null; |
| 88 this._hidden = false; | 89 this._hidden = false; |
| 89 this._isLabel = !!isLabel; | 90 this._isLabel = !!isLabel; |
| 90 this.setTitle(title); | 91 this.setTitle(title); |
| 91 this.setSubtitle(subtitle); | 92 this.setSubtitle(subtitle); |
| 92 this.setSelected(false); | 93 this.setSelected(false); |
| 93 } | 94 } |
| 94 | 95 |
| 95 /** | 96 /** |
| 96 * @return {?WebInspector.UIList.Item} | 97 * @return {?WebInspector.UIList.Item} |
| 97 */ | 98 */ |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 * @return {boolean} | 193 * @return {boolean} |
| 193 */ | 194 */ |
| 194 isLabel() { | 195 isLabel() { |
| 195 return this._isLabel; | 196 return this._isLabel; |
| 196 } | 197 } |
| 197 | 198 |
| 198 /** | 199 /** |
| 199 * @param {boolean} x | 200 * @param {boolean} x |
| 200 */ | 201 */ |
| 201 setDimmed(x) { | 202 setDimmed(x) { |
| 202 this.element.classList.toggle('dimmed', x); | 203 this.element.classList.toggle('dimmed-item', x); |
| 203 } | 204 } |
| 204 | 205 |
| 205 discard() { | 206 discard() { |
| 206 } | 207 } |
| 207 | 208 |
| 208 /** | 209 /** |
| 209 * @param {boolean} hoverable | 210 * @param {boolean} hoverable |
| 210 */ | 211 */ |
| 211 setHoverable(hoverable) { | 212 setHoverable(hoverable) { |
| 212 this.element.classList.toggle('ignore-hover', !hoverable); | 213 this.element.classList.toggle('ignore-hover', !hoverable); |
| 213 } | 214 } |
| 215 |
| 216 /** |
| 217 * @param {?string} title |
| 218 * @param {?function(!Event):!Promise} handler |
| 219 */ |
| 220 setAction(title, handler) { |
| 221 if (this._actionElement) |
| 222 this._actionElement.remove(); |
| 223 if (!title || !handler) |
| 224 return; |
| 225 this._actionElement = this.element.createChild('div', 'action'); |
| 226 var link = this._actionElement.createChild('a', 'action-link'); |
| 227 link.textContent = title; |
| 228 link.addEventListener('click', (event) => { |
| 229 link.disabled = true; |
| 230 handler(event).then(() => link.disabled = false); |
| 231 event.stopPropagation(); |
| 232 }); |
| 233 } |
| 214 }; | 234 }; |
| OLD | NEW |