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

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

Issue 2431223003: [DevTools]: Require explicit connection (Closed)
Patch Set: Reworked - again 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 unified diff | Download patch
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
dgozman 2016/10/28 18:31:36 _actionElement
eostroukhov 2016/11/01 20:28:15 Done.
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
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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698