OLD | NEW |
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 _createItemElement(query, text, iconType, isSecondary) { | 278 _createItemElement(query, text, iconType, isSecondary) { |
279 var element = createElementWithClass('div', 'suggest-box-content-item source
-code'); | 279 var element = createElementWithClass('div', 'suggest-box-content-item source
-code'); |
280 if (iconType) { | 280 if (iconType) { |
281 var icon = UI.Icon.create(iconType, 'suggestion-icon'); | 281 var icon = UI.Icon.create(iconType, 'suggestion-icon'); |
282 element.appendChild(icon); | 282 element.appendChild(icon); |
283 } | 283 } |
284 if (isSecondary) | 284 if (isSecondary) |
285 element.classList.add('secondary'); | 285 element.classList.add('secondary'); |
286 element.tabIndex = -1; | 286 element.tabIndex = -1; |
287 var displayText = text.trimEnd(50 + query.length); | 287 var displayText = text.trimEnd(50 + query.length); |
| 288 |
| 289 var suggestionText = element.createChild('span', 'suggestion-text'); |
288 var index = displayText.toLowerCase().indexOf(query.toLowerCase()); | 290 var index = displayText.toLowerCase().indexOf(query.toLowerCase()); |
289 if (index > 0) | 291 if (index > 0) |
290 element.createChild('span').textContent = displayText.substring(0, index); | 292 suggestionText.createChild('span').textContent = displayText.substring(0,
index); |
291 if (index > -1) | 293 if (index > -1) |
292 element.createChild('span', 'query').textContent = displayText.substring(i
ndex, index + query.length); | 294 suggestionText.createChild('span', 'query').textContent = displayText.subs
tring(index, index + query.length); |
293 element.createChild('span').textContent = displayText.substring(index > -1 ?
index + query.length : 0); | 295 suggestionText.createChild('span').textContent = displayText.substring(index
> -1 ? index + query.length : 0); |
| 296 suggestionText.createChild('span', 'spacer'); |
294 element.__fullValue = text; | 297 element.__fullValue = text; |
295 element.createChild('span', 'spacer'); | |
296 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals
e); | 298 element.addEventListener('mousedown', this._onItemMouseDown.bind(this), fals
e); |
297 return element; | 299 return element; |
298 } | 300 } |
299 | 301 |
300 /** | 302 /** |
301 * @param {!UI.SuggestBox.Suggestions} items | 303 * @param {!UI.SuggestBox.Suggestions} items |
302 * @param {string} userEnteredText | 304 * @param {string} userEnteredText |
303 * @param {function(number): !Promise<{detail:string, description:string}>=} a
syncDetails | 305 * @param {function(number): !Promise<{detail:string, description:string}>=} a
syncDetails |
304 */ | 306 */ |
305 _updateItems(items, userEnteredText, asyncDetails) { | 307 _updateItems(items, userEnteredText, asyncDetails) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 this.element.style.left = containerBox.x + 'px'; | 602 this.element.style.left = containerBox.x + 'px'; |
601 this.element.style.top = containerBox.y + 'px'; | 603 this.element.style.top = containerBox.y + 'px'; |
602 this.element.style.height = containerBox.height + 'px'; | 604 this.element.style.height = containerBox.height + 'px'; |
603 this.element.style.width = containerBox.width + 'px'; | 605 this.element.style.width = containerBox.width + 'px'; |
604 } | 606 } |
605 | 607 |
606 dispose() { | 608 dispose() { |
607 this.element.remove(); | 609 this.element.remove(); |
608 } | 610 } |
609 }; | 611 }; |
OLD | NEW |