Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| index 5c6c6a36a169716665d9c1aa4ad97d67ee6bb24f..e785dca734d113feb0699fb3fef19309ebc09b79 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| @@ -89,6 +89,8 @@ WebInspector.UIList.Item = function(title, subtitle, isLabel) |
| this.titleElement = this.element.createChild("div", "title"); |
| this.subtitleElement = this.element.createChild("div", "subtitle"); |
| + /** @type {?Element} */ |
| + this.actionElement = null; |
|
dgozman
2016/10/28 18:31:36
_actionElement
eostroukhov
2016/11/01 20:28:15
Done.
|
| this._hidden = false; |
| this._isLabel = !!isLabel; |
| @@ -219,7 +221,7 @@ WebInspector.UIList.Item.prototype = { |
| */ |
| setDimmed: function(x) |
| { |
| - this.element.classList.toggle("dimmed", x); |
| + this.element.classList.toggle("dimmed-item", x); |
| }, |
| discard: function() |
| @@ -233,4 +235,24 @@ WebInspector.UIList.Item.prototype = { |
| { |
| this.element.classList.toggle("ignore-hover", !hoverable); |
| }, |
| + |
| + /** |
| + * @param {?string} title |
| + * @param {?function(!Event)} handler |
| + */ |
| + setAction: function(title, handler) |
| + { |
| + if (this.actionElement) |
| + this.actionElement.remove(); |
| + if (!title || !handler) |
| + return; |
| + this.actionElement = this.element.createChild("div", "action"); |
| + var link = this.actionElement.createChild("a", "action-link"); |
| + link.textContent = title; |
| + link.addEventListener("click", (event) => { |
| + link.disabled = true; |
| + Promise.resolve(handler(event)).then(() => link.disabled = false); |
| + event.stopPropagation(); |
| + }); |
| + }, |
| }; |