| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE._ |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @constructor | 28 * @constructor |
| 29 * @extends {WebInspector.VBox} | 29 * @extends {WebInspector.VBox} |
| 30 */ | 30 */ |
| 31 WebInspector.UIList = function() | 31 WebInspector.UIList = function() |
| 32 { | 32 { |
| 33 WebInspector.VBox.call(this, true); | 33 WebInspector.VBox.call(this, true); |
| 34 this.registerRequiredCSS("sources/uiList.css"); | 34 this.registerRequiredCSS("sources/uiList.css"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 * @param {boolean=} isLabel | 82 * @param {boolean=} isLabel |
| 83 */ | 83 */ |
| 84 WebInspector.UIList.Item = function(title, subtitle, isLabel) | 84 WebInspector.UIList.Item = function(title, subtitle, isLabel) |
| 85 { | 85 { |
| 86 this.element = createElementWithClass("div", "list-item"); | 86 this.element = createElementWithClass("div", "list-item"); |
| 87 if (isLabel) | 87 if (isLabel) |
| 88 this.element.classList.add("label"); | 88 this.element.classList.add("label"); |
| 89 | 89 |
| 90 this.titleElement = this.element.createChild("div", "title"); | 90 this.titleElement = this.element.createChild("div", "title"); |
| 91 this.subtitleElement = this.element.createChild("div", "subtitle"); | 91 this.subtitleElement = this.element.createChild("div", "subtitle"); |
| 92 /** @type {?Element} */ |
| 93 this._actionElement = null; |
| 92 | 94 |
| 93 this._hidden = false; | 95 this._hidden = false; |
| 94 this._isLabel = !!isLabel; | 96 this._isLabel = !!isLabel; |
| 95 this.setTitle(title); | 97 this.setTitle(title); |
| 96 this.setSubtitle(subtitle); | 98 this.setSubtitle(subtitle); |
| 97 this.setSelected(false); | 99 this.setSelected(false); |
| 98 }; | 100 }; |
| 99 | 101 |
| 100 WebInspector.UIList.Item.prototype = { | 102 WebInspector.UIList.Item.prototype = { |
| 101 /** | 103 /** |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 isLabel: function() | 214 isLabel: function() |
| 213 { | 215 { |
| 214 return this._isLabel; | 216 return this._isLabel; |
| 215 }, | 217 }, |
| 216 | 218 |
| 217 /** | 219 /** |
| 218 * @param {boolean} x | 220 * @param {boolean} x |
| 219 */ | 221 */ |
| 220 setDimmed: function(x) | 222 setDimmed: function(x) |
| 221 { | 223 { |
| 222 this.element.classList.toggle("dimmed", x); | 224 this.element.classList.toggle("dimmed-item", x); |
| 223 }, | 225 }, |
| 224 | 226 |
| 225 discard: function() | 227 discard: function() |
| 226 { | 228 { |
| 227 }, | 229 }, |
| 228 | 230 |
| 229 /** | 231 /** |
| 230 * @param {boolean} hoverable | 232 * @param {boolean} hoverable |
| 231 */ | 233 */ |
| 232 setHoverable: function(hoverable) | 234 setHoverable: function(hoverable) |
| 233 { | 235 { |
| 234 this.element.classList.toggle("ignore-hover", !hoverable); | 236 this.element.classList.toggle("ignore-hover", !hoverable); |
| 235 }, | 237 }, |
| 238 |
| 239 /** |
| 240 * @param {?string} title |
| 241 * @param {?function(!Event)} handler |
| 242 */ |
| 243 setAction: function(title, handler) |
| 244 { |
| 245 if (this._actionElement) |
| 246 this._actionElement.remove(); |
| 247 if (!title || !handler) |
| 248 return; |
| 249 this._actionElement = this.element.createChild("div", "action"); |
| 250 var link = this._actionElement.createChild("a", "action-link"); |
| 251 link.textContent = title; |
| 252 link.addEventListener("click", (event) => { |
| 253 link.disabled = true; |
| 254 Promise.resolve(handler(event)).then(() => link.disabled = false); |
| 255 event.stopPropagation(); |
| 256 }); |
| 257 }, |
| 236 }; | 258 }; |
| OLD | NEW |