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 28 matching lines...) Expand all Loading... |
39 */ | 39 */ |
40 applySuggestion(suggestion, isIntermediateSuggestion) {}, | 40 applySuggestion(suggestion, isIntermediateSuggestion) {}, |
41 | 41 |
42 /** | 42 /** |
43 * acceptSuggestion will be always called after call to applySuggestion with i
sIntermediateSuggestion being equal to false. | 43 * acceptSuggestion will be always called after call to applySuggestion with i
sIntermediateSuggestion being equal to false. |
44 */ | 44 */ |
45 acceptSuggestion() {}, | 45 acceptSuggestion() {}, |
46 }; | 46 }; |
47 | 47 |
48 /** | 48 /** |
49 * @implements {UI.StaticViewportControl.Provider} | 49 * @implements {UI.ViewportControl.Provider} |
50 * @unrestricted | 50 * @unrestricted |
51 */ | 51 */ |
52 UI.SuggestBox = class { | 52 UI.SuggestBox = class { |
53 /** | 53 /** |
54 * @param {!UI.SuggestBoxDelegate} suggestBoxDelegate | 54 * @param {!UI.SuggestBoxDelegate} suggestBoxDelegate |
55 * @param {number=} maxItemsHeight | 55 * @param {number=} maxItemsHeight |
56 * @param {boolean=} captureEnter | 56 * @param {boolean=} captureEnter |
57 */ | 57 */ |
58 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) { | 58 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) { |
59 this._suggestBoxDelegate = suggestBoxDelegate; | 59 this._suggestBoxDelegate = suggestBoxDelegate; |
60 this._length = 0; | 60 this._length = 0; |
61 this._selectedIndex = -1; | 61 this._selectedIndex = -1; |
62 this._selectedElement = null; | 62 this._selectedElement = null; |
63 this._maxItemsHeight = maxItemsHeight; | 63 this._maxItemsHeight = maxItemsHeight; |
64 this._maybeHideBound = this._maybeHide.bind(this); | 64 this._maybeHideBound = this._maybeHide.bind(this); |
65 this._container = createElementWithClass('div', 'suggest-box-container'); | 65 this._container = createElementWithClass('div', 'suggest-box-container'); |
66 this._viewport = new UI.StaticViewportControl(this); | 66 this._viewport = new UI.ViewportControl(this); |
67 this._element = this._viewport.element; | 67 this._element = this._viewport.element; |
68 this._element.classList.add('suggest-box'); | 68 this._element.classList.add('suggest-box'); |
69 this._container.appendChild(this._element); | 69 this._container.appendChild(this._element); |
70 this._element.addEventListener('mousedown', this._onBoxMouseDown.bind(this),
true); | 70 this._element.addEventListener('mousedown', this._onBoxMouseDown.bind(this),
true); |
71 this._detailsPopup = this._container.createChild('div', 'suggest-box details
-popup monospace'); | 71 this._detailsPopup = this._container.createChild('div', 'suggest-box details
-popup monospace'); |
72 this._detailsPopup.classList.add('hidden'); | 72 this._detailsPopup.classList.add('hidden'); |
73 this._asyncDetailsCallback = null; | 73 this._asyncDetailsCallback = null; |
74 /** @type {!Map<number, !Promise<{detail: string, description: string}>>} */ | 74 /** @type {!Map<number, !Promise<{detail: string, description: string}>>} */ |
75 this._asyncDetailsPromises = new Map(); | 75 this._asyncDetailsPromises = new Map(); |
76 this._userInteracted = false; | 76 this._userInteracted = false; |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 this.element.style.left = containerBox.x + 'px'; | 609 this.element.style.left = containerBox.x + 'px'; |
610 this.element.style.top = containerBox.y + 'px'; | 610 this.element.style.top = containerBox.y + 'px'; |
611 this.element.style.height = containerBox.height + 'px'; | 611 this.element.style.height = containerBox.height + 'px'; |
612 this.element.style.width = containerBox.width + 'px'; | 612 this.element.style.width = containerBox.width + 'px'; |
613 } | 613 } |
614 | 614 |
615 dispose() { | 615 dispose() { |
616 this.element.remove(); | 616 this.element.remove(); |
617 } | 617 } |
618 }; | 618 }; |
OLD | NEW |