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 34f5957d6bd7bfeb571856609f53e3681ee860cd..c75e21cffbf1c12de88348ebdf9b4bb56737556f 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
| @@ -84,7 +84,8 @@ WebInspector.UIList.Item = class { |
| this.titleElement = this.element.createChild('div', 'title'); |
| this.subtitleElement = this.element.createChild('div', 'subtitle'); |
| - |
| + /** @type {?Element} */ |
| + this._actionElement = null; |
| this._hidden = false; |
| this._isLabel = !!isLabel; |
| this.setTitle(title); |
| @@ -199,7 +200,7 @@ WebInspector.UIList.Item = class { |
| * @param {boolean} x |
| */ |
| setDimmed(x) { |
| - this.element.classList.toggle('dimmed', x); |
| + this.element.classList.toggle('dimmed-item', x); |
| } |
| discard() { |
| @@ -211,4 +212,23 @@ WebInspector.UIList.Item = class { |
| setHoverable(hoverable) { |
| this.element.classList.toggle('ignore-hover', !hoverable); |
| } |
| + |
| + /** |
| + * @param {?string} title |
| + * @param {?function(!Event)} handler |
| + */ |
| + setAction(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); |
|
dgozman
2016/11/02 23:20:40
Why Promise.resolve?
eostroukhov
2016/11/03 17:25:52
I don't want to force people who use the UIList to
dgozman
2016/11/03 21:21:30
In this case you must mark handler as returning pr
eostroukhov
2016/11/03 22:44:50
Done.
|
| + event.stopPropagation(); |
| + }); |
| + } |
| }; |