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

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

Issue 2557763003: DevTools: sort completions by prototype. (Closed)
Patch Set: rebaselined 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 * @param {!Event} event 264 * @param {!Event} event
265 */ 265 */
266 _onItemMouseDown(event) { 266 _onItemMouseDown(event) {
267 this._selectedElement = event.currentTarget; 267 this._selectedElement = event.currentTarget;
268 this.acceptSuggestion(); 268 this.acceptSuggestion();
269 event.consume(true); 269 event.consume(true);
270 } 270 }
271 271
272 /** 272 /**
273 * @param {string} query 273 * @param {string} query
274 * @param {string} text 274 * @param {string} title
275 * @param {string=} subtitle
275 * @param {string=} iconType 276 * @param {string=} iconType
276 * @param {boolean=} isSecondary 277 * @param {boolean=} isSecondary
277 * @return {!Element} 278 * @return {!Element}
278 */ 279 */
279 _createItemElement(query, text, iconType, isSecondary) { 280 _createItemElement(query, title, subtitle, iconType, isSecondary) {
280 var element = createElementWithClass('div', 'suggest-box-content-item source -code'); 281 var element = createElementWithClass('div', 'suggest-box-content-item source -code');
281 if (iconType) { 282 if (iconType) {
282 var icon = UI.Icon.create(iconType, 'suggestion-icon'); 283 var icon = UI.Icon.create(iconType, 'suggestion-icon');
283 element.appendChild(icon); 284 element.appendChild(icon);
284 } 285 }
285 if (isSecondary) 286 if (isSecondary)
286 element.classList.add('secondary'); 287 element.classList.add('secondary');
287 element.tabIndex = -1; 288 element.tabIndex = -1;
288 var displayText = text.trimEnd(50 + query.length); 289 var displayText = title.trimEnd(50 + query.length);
289 290
290 var suggestionText = element.createChild('span', 'suggestion-text'); 291 var titleElement = element.createChild('span', 'suggestion-title');
291 var index = displayText.toLowerCase().indexOf(query.toLowerCase()); 292 var index = displayText.toLowerCase().indexOf(query.toLowerCase());
292 if (index > 0) 293 if (index > 0)
293 suggestionText.createChild('span').textContent = displayText.substring(0, index); 294 titleElement.createChild('span').textContent = displayText.substring(0, in dex);
294 if (index > -1) 295 if (index > -1)
295 suggestionText.createChild('span', 'query').textContent = displayText.subs tring(index, index + query.length); 296 titleElement.createChild('span', 'query').textContent = displayText.substr ing(index, index + query.length);
296 suggestionText.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0); 297 titleElement.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0);
297 suggestionText.createChild('span', 'spacer'); 298 titleElement.createChild('span', 'spacer');
298 element.__fullValue = text; 299 if (subtitle) {
300 var subtitleElement = element.createChild('span', 'suggestion-subtitle');
301 subtitleElement.textContent = subtitle.trimEnd(15);
302 }
303 element.__fullValue = title;
299 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals e); 304 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals e);
300 return element; 305 return element;
301 } 306 }
302 307
303 /** 308 /**
304 * @param {!UI.SuggestBox.Suggestions} items 309 * @param {!UI.SuggestBox.Suggestions} items
305 * @param {string} userEnteredText 310 * @param {string} userEnteredText
306 * @param {function(number): !Promise<{detail:string, description:string}>=} a syncDetails 311 * @param {function(number): !Promise<{detail:string, description:string}>=} a syncDetails
307 */ 312 */
308 _updateItems(items, userEnteredText, asyncDetails) { 313 _updateItems(items, userEnteredText, asyncDetails) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 534 }
530 535
531 /** 536 /**
532 * @override 537 * @override
533 * @param {number} index 538 * @param {number} index
534 * @return {?Element} 539 * @return {?Element}
535 */ 540 */
536 itemElement(index) { 541 itemElement(index) {
537 if (!this._elementList[index]) { 542 if (!this._elementList[index]) {
538 this._elementList[index] = this._createItemElement( 543 this._elementList[index] = this._createItemElement(
539 this._userEnteredText, this._items[index].title, this._items[index].ic onType, this._items[index].isSecondary); 544 this._userEnteredText, this._items[index].title, this._items[index].su btitle, this._items[index].iconType,
545 this._items[index].isSecondary);
540 } 546 }
541 return this._elementList[index]; 547 return this._elementList[index];
542 } 548 }
543 }; 549 };
544 550
545 /** 551 /**
546 * @typedef {!Array.<{title: string, iconType: (string|undefined), priority: (nu mber|undefined), isSecondary: (boolean|undefined)}>} 552 * @typedef {!Array.<{title: string, subtitle: (string|undefined), iconType: (st ring|undefined), priority: (number|undefined), isSecondary: (boolean|undefined)} >}
547 */ 553 */
548 UI.SuggestBox.Suggestions; 554 UI.SuggestBox.Suggestions;
549 555
550 /** 556 /**
551 * @unrestricted 557 * @unrestricted
552 */ 558 */
553 UI.SuggestBox.Overlay = class { 559 UI.SuggestBox.Overlay = class {
554 /** 560 /**
555 * // FIXME: make SuggestBox work for multiple documents. 561 * // FIXME: make SuggestBox work for multiple documents.
556 * @suppressGlobalPropertiesCheck 562 * @suppressGlobalPropertiesCheck
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 this.element.style.left = containerBox.x + 'px'; 609 this.element.style.left = containerBox.x + 'px';
604 this.element.style.top = containerBox.y + 'px'; 610 this.element.style.top = containerBox.y + 'px';
605 this.element.style.height = containerBox.height + 'px'; 611 this.element.style.height = containerBox.height + 'px';
606 this.element.style.width = containerBox.width + 'px'; 612 this.element.style.width = containerBox.width + 'px';
607 } 613 }
608 614
609 dispose() { 615 dispose() {
610 this.element.remove(); 616 this.element.remove();
611 } 617 }
612 }; 618 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698