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

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js

Issue 2534383002: DevTools: [SuggestBox] migrate suggestbox icons onto UI.Icon (Closed)
Patch Set: address comments + better centering Created 4 years 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/ui/SuggestBox.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
index 18164bd77e335f0a2a3a25cd3e5edf8cf7c3727a..cc0c23eef54896677a93eb2867dc875a81af18fe 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
@@ -271,11 +271,18 @@ UI.SuggestBox = class {
/**
* @param {string} query
* @param {string} text
- * @param {string=} className
+ * @param {string=} iconType
+ * @param {boolean=} isSecondary
* @return {!Element}
*/
- _createItemElement(query, text, className) {
- var element = createElementWithClass('div', 'suggest-box-content-item source-code ' + (className || ''));
+ _createItemElement(query, text, iconType, isSecondary) {
+ var element = createElementWithClass('div', 'suggest-box-content-item source-code');
+ if (iconType) {
+ var icon = UI.Icon.create(iconType, 'suggestion-icon');
+ element.appendChild(icon);
+ }
+ if (isSecondary)
+ element.classList.add('secondary');
element.tabIndex = -1;
var displayText = text.trimEnd(50 + query.length);
var index = displayText.toLowerCase().indexOf(query.toLowerCase());
@@ -334,8 +341,10 @@ UI.SuggestBox = class {
* @param {number} index
*/
_selectItem(index) {
- if (this._selectedElement)
+ if (this._selectedElement) {
this._selectedElement.classList.remove('selected');
+ this._selectedElement.classList.remove('force-white-icons');
+ }
this._selectedIndex = index;
if (index < 0)
@@ -343,6 +352,7 @@ UI.SuggestBox = class {
this._selectedElement = this.itemElement(index);
this._selectedElement.classList.add('selected');
+ this._selectedElement.classList.add('force-white-icons');
this._detailsPopup.classList.add('hidden');
var elem = this._selectedElement;
this._asyncDetails(index).then(showDetails.bind(this), function() {});
@@ -522,15 +532,15 @@ UI.SuggestBox = class {
*/
itemElement(index) {
if (!this._elementList[index]) {
- this._elementList[index] =
- this._createItemElement(this._userEnteredText, this._items[index].title, this._items[index].className);
+ this._elementList[index] = this._createItemElement(
+ this._userEnteredText, this._items[index].title, this._items[index].iconType, this._items[index].isSecondary);
}
return this._elementList[index];
}
};
/**
- * @typedef {!Array.<{title: string, className: (string|undefined), priority: (number|undefined)}>}
+ * @typedef {!Array.<{title: string, iconType: (string|undefined), priority: (number|undefined), isSecondary: (boolean|undefined)}>}
*/
UI.SuggestBox.Suggestions;

Powered by Google App Engine
This is Rietveld 408576698