Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/UIList.js

Issue 2431223003: [DevTools]: Require explicit connection (Closed)
Patch Set: Code review comments were addressed Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..af18e327f028d3f396fac27ecc7503fb922a516f 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js
@@ -21,7 +21,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE._
*/
/**
@@ -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;
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();
+ });
+ },
};

Powered by Google App Engine
This is Rietveld 408576698