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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @interface | 32 * @interface |
33 */ | 33 */ |
34 WebInspector.SuggestBoxDelegate = function() | 34 WebInspector.SuggestBoxDelegate = function() |
35 { | 35 { |
36 } | 36 }; |
37 | 37 |
38 WebInspector.SuggestBoxDelegate.prototype = { | 38 WebInspector.SuggestBoxDelegate.prototype = { |
39 /** | 39 /** |
40 * @param {string} suggestion | 40 * @param {string} suggestion |
41 * @param {boolean=} isIntermediateSuggestion | 41 * @param {boolean=} isIntermediateSuggestion |
42 */ | 42 */ |
43 applySuggestion: function(suggestion, isIntermediateSuggestion) { }, | 43 applySuggestion: function(suggestion, isIntermediateSuggestion) { }, |
44 | 44 |
45 /** | 45 /** |
46 * acceptSuggestion will be always called after call to applySuggestion with
isIntermediateSuggestion being equal to false. | 46 * acceptSuggestion will be always called after call to applySuggestion with
isIntermediateSuggestion being equal to false. |
47 */ | 47 */ |
48 acceptSuggestion: function() { }, | 48 acceptSuggestion: function() { }, |
49 } | 49 }; |
50 | 50 |
51 /** | 51 /** |
52 * @constructor | 52 * @constructor |
53 * @implements {WebInspector.StaticViewportControl.Provider} | 53 * @implements {WebInspector.StaticViewportControl.Provider} |
54 * @param {!WebInspector.SuggestBoxDelegate} suggestBoxDelegate | 54 * @param {!WebInspector.SuggestBoxDelegate} suggestBoxDelegate |
55 * @param {number=} maxItemsHeight | 55 * @param {number=} maxItemsHeight |
56 * @param {boolean=} captureEnter | 56 * @param {boolean=} captureEnter |
57 */ | 57 */ |
58 WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight, captureEn
ter) | 58 WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight, captureEn
ter) |
59 { | 59 { |
(...skipping 17 matching lines...) Expand all Loading... |
77 this._userInteracted = false; | 77 this._userInteracted = false; |
78 this._captureEnter = captureEnter; | 78 this._captureEnter = captureEnter; |
79 /** @type {!Array<!Element>} */ | 79 /** @type {!Array<!Element>} */ |
80 this._elementList = []; | 80 this._elementList = []; |
81 this._rowHeight = 17; | 81 this._rowHeight = 17; |
82 this._viewportWidth = "100vw"; | 82 this._viewportWidth = "100vw"; |
83 this._hasVerticalScroll = false; | 83 this._hasVerticalScroll = false; |
84 this._userEnteredText = ""; | 84 this._userEnteredText = ""; |
85 /** @type {!WebInspector.SuggestBox.Suggestions} */ | 85 /** @type {!WebInspector.SuggestBox.Suggestions} */ |
86 this._items = []; | 86 this._items = []; |
87 } | 87 }; |
88 | 88 |
89 /** | 89 /** |
90 * @typedef {!Array.<{title: string, className: (string|undefined)}>} | 90 * @typedef {!Array.<{title: string, className: (string|undefined)}>} |
91 */ | 91 */ |
92 WebInspector.SuggestBox.Suggestions; | 92 WebInspector.SuggestBox.Suggestions; |
93 | 93 |
94 WebInspector.SuggestBox.prototype = { | 94 WebInspector.SuggestBox.prototype = { |
95 /** | 95 /** |
96 * @return {boolean} | 96 * @return {boolean} |
97 */ | 97 */ |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 * @override | 534 * @override |
535 * @param {number} index | 535 * @param {number} index |
536 * @return {?Element} | 536 * @return {?Element} |
537 */ | 537 */ |
538 itemElement: function(index) | 538 itemElement: function(index) |
539 { | 539 { |
540 if (!this._elementList[index]) | 540 if (!this._elementList[index]) |
541 this._elementList[index] = this._createItemElement(this._userEntered
Text, this._items[index].title, this._items[index].className); | 541 this._elementList[index] = this._createItemElement(this._userEntered
Text, this._items[index].title, this._items[index].className); |
542 return this._elementList[index]; | 542 return this._elementList[index]; |
543 } | 543 } |
544 } | 544 }; |
545 | 545 |
546 /** | 546 /** |
547 * @constructor | 547 * @constructor |
548 * // FIXME: make SuggestBox work for multiple documents. | 548 * // FIXME: make SuggestBox work for multiple documents. |
549 * @suppressGlobalPropertiesCheck | 549 * @suppressGlobalPropertiesCheck |
550 */ | 550 */ |
551 WebInspector.SuggestBox.Overlay = function() | 551 WebInspector.SuggestBox.Overlay = function() |
552 { | 552 { |
553 this.element = createElementWithClass("div", "suggest-box-overlay"); | 553 this.element = createElementWithClass("div", "suggest-box-overlay"); |
554 var root = WebInspector.createShadowRootWithCoreStyles(this.element, "ui/sug
gestBox.css"); | 554 var root = WebInspector.createShadowRootWithCoreStyles(this.element, "ui/sug
gestBox.css"); |
555 this._leftSpacerElement = root.createChild("div", "suggest-box-left-spacer")
; | 555 this._leftSpacerElement = root.createChild("div", "suggest-box-left-spacer")
; |
556 this._horizontalElement = root.createChild("div", "suggest-box-horizontal"); | 556 this._horizontalElement = root.createChild("div", "suggest-box-horizontal"); |
557 this._topSpacerElement = this._horizontalElement.createChild("div", "suggest
-box-top-spacer"); | 557 this._topSpacerElement = this._horizontalElement.createChild("div", "suggest
-box-top-spacer"); |
558 this._bottomSpacerElement = this._horizontalElement.createChild("div", "sugg
est-box-bottom-spacer"); | 558 this._bottomSpacerElement = this._horizontalElement.createChild("div", "sugg
est-box-bottom-spacer"); |
559 this._resize(); | 559 this._resize(); |
560 document.body.appendChild(this.element); | 560 document.body.appendChild(this.element); |
561 } | 561 }; |
562 | 562 |
563 WebInspector.SuggestBox.Overlay.prototype = { | 563 WebInspector.SuggestBox.Overlay.prototype = { |
564 /** | 564 /** |
565 * @param {number} offset | 565 * @param {number} offset |
566 */ | 566 */ |
567 setLeftOffset: function(offset) | 567 setLeftOffset: function(offset) |
568 { | 568 { |
569 this._leftSpacerElement.style.flexBasis = offset + "px"; | 569 this._leftSpacerElement.style.flexBasis = offset + "px"; |
570 }, | 570 }, |
571 | 571 |
(...skipping 30 matching lines...) Expand all Loading... |
602 this.element.style.left = containerBox.x + "px"; | 602 this.element.style.left = containerBox.x + "px"; |
603 this.element.style.top = containerBox.y + "px"; | 603 this.element.style.top = containerBox.y + "px"; |
604 this.element.style.height = containerBox.height + "px"; | 604 this.element.style.height = containerBox.height + "px"; |
605 this.element.style.width = containerBox.width + "px"; | 605 this.element.style.width = containerBox.width + "px"; |
606 }, | 606 }, |
607 | 607 |
608 dispose: function() | 608 dispose: function() |
609 { | 609 { |
610 this.element.remove(); | 610 this.element.remove(); |
611 } | 611 } |
612 } | 612 }; |
OLD | NEW |