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

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

Issue 2742573007: DevTools: initial console suggestion should be greyed out (Closed)
Patch Set: use another css Created 3 years, 9 months 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 this._element.addEventListener('mousedown', event => event.preventDefault(), true); 71 this._element.addEventListener('mousedown', event => event.preventDefault(), true);
72 72
73 this._glassPane = new UI.GlassPane(); 73 this._glassPane = new UI.GlassPane();
74 this._glassPane.setAnchorBehavior(UI.GlassPane.AnchorBehavior.PreferBottom); 74 this._glassPane.setAnchorBehavior(UI.GlassPane.AnchorBehavior.PreferBottom);
75 this._glassPane.setSetOutsideClickCallback(this.hide.bind(this)); 75 this._glassPane.setSetOutsideClickCallback(this.hide.bind(this));
76 var shadowRoot = UI.createShadowRootWithCoreStyles(this._glassPane.contentEl ement, 'ui/suggestBox.css'); 76 var shadowRoot = UI.createShadowRootWithCoreStyles(this._glassPane.contentEl ement, 'ui/suggestBox.css');
77 shadowRoot.appendChild(this._element); 77 shadowRoot.appendChild(this._element);
78 } 78 }
79 79
80 /** 80 /**
81 * @param {boolean} value
82 */
83 setDefaultSelectionIsDimmed(value) {
84 this._element.classList.toggle('default-selection-is-dimmed', value);
85 }
86
87 /**
88 * @param {boolean} value
89 */
90 _setUserInteracted(value) {
91 this._userInteracted = value;
92 this._element.classList.toggle('user-has-interacted', value);
93 }
94
95 /**
81 * @return {boolean} 96 * @return {boolean}
82 */ 97 */
83 visible() { 98 visible() {
84 return this._glassPane.isShowing(); 99 return this._glassPane.isShowing();
85 } 100 }
86 101
87 /** 102 /**
88 * @param {!AnchorBox} anchorBox 103 * @param {!AnchorBox} anchorBox
89 */ 104 */
90 setPosition(anchorBox) { 105 setPosition(anchorBox) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return; 145 return;
131 // TODO(dgozman): take document as a parameter. 146 // TODO(dgozman): take document as a parameter.
132 this._glassPane.show(document); 147 this._glassPane.show(document);
133 this._rowHeight = 148 this._rowHeight =
134 UI.measurePreferredSize(this.createElementForItem({text: '1', subtitle: '12'}), this._element).height; 149 UI.measurePreferredSize(this.createElementForItem({text: '1', subtitle: '12'}), this._element).height;
135 } 150 }
136 151
137 hide() { 152 hide() {
138 if (!this.visible()) 153 if (!this.visible())
139 return; 154 return;
140 this._userInteracted = false; 155 this._setUserInteracted(false);
141 this._glassPane.hide(); 156 this._glassPane.hide();
142 } 157 }
143 158
144 /** 159 /**
145 * @param {boolean=} isIntermediateSuggestion 160 * @param {boolean=} isIntermediateSuggestion
146 * @return {boolean} 161 * @return {boolean}
147 */ 162 */
148 _applySuggestion(isIntermediateSuggestion) { 163 _applySuggestion(isIntermediateSuggestion) {
149 if (this._onlyCompletion) { 164 if (this._onlyCompletion) {
150 this._suggestBoxDelegate.applySuggestion(this._onlyCompletion, isIntermedi ateSuggestion); 165 this._suggestBoxDelegate.applySuggestion(this._onlyCompletion, isIntermedi ateSuggestion);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 titleElement.createChild('span', 'query').textContent = displayText.substr ing(index, index + query.length); 217 titleElement.createChild('span', 'query').textContent = displayText.substr ing(index, index + query.length);
203 titleElement.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0); 218 titleElement.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0);
204 titleElement.createChild('span', 'spacer'); 219 titleElement.createChild('span', 'spacer');
205 if (item.subtitle) { 220 if (item.subtitle) {
206 var subtitleElement = element.createChild('span', 'suggestion-subtitle'); 221 var subtitleElement = element.createChild('span', 'suggestion-subtitle');
207 subtitleElement.textContent = item.subtitle.trimEnd(maxTextLength - displa yText.length); 222 subtitleElement.textContent = item.subtitle.trimEnd(maxTextLength - displa yText.length);
208 } 223 }
209 224
210 element.addEventListener('click', event => { 225 element.addEventListener('click', event => {
211 this._list.selectItem(item); 226 this._list.selectItem(item);
212 this._userInteracted = true; 227 this._setUserInteracted(true);
213 event.consume(true); 228 event.consume(true);
214 this.acceptSuggestion(); 229 this.acceptSuggestion();
215 }); 230 });
216 return element; 231 return element;
217 } 232 }
218 233
219 /** 234 /**
220 * @override 235 * @override
221 * @param {!UI.SuggestBox.Suggestion} item 236 * @param {!UI.SuggestBox.Suggestion} item
222 * @return {number} 237 * @return {number}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 case 'PageUp': 343 case 'PageUp':
329 selected = this._list.selectItemPreviousPage(false); 344 selected = this._list.selectItemPreviousPage(false);
330 break; 345 break;
331 case 'PageDown': 346 case 'PageDown':
332 selected = this._list.selectItemNextPage(false); 347 selected = this._list.selectItemNextPage(false);
333 break; 348 break;
334 default: 349 default:
335 return false; 350 return false;
336 } 351 }
337 if (selected) { 352 if (selected) {
338 this._userInteracted = true; 353 this._setUserInteracted(true);
339 return true; 354 return true;
340 } 355 }
341 return false; 356 return false;
342 } 357 }
343 358
344 /** 359 /**
345 * @return {boolean} 360 * @return {boolean}
346 */ 361 */
347 enterKeyPressed() { 362 enterKeyPressed() {
348 if (!this._userInteracted && this._captureEnter) 363 if (!this._userInteracted && this._captureEnter)
(...skipping 10 matching lines...) Expand all
359 374
360 /** 375 /**
361 * @typedef {!{text: string, subtitle: (string|undefined), iconType: (string|und efined), priority: (number|undefined), isSecondary: (boolean|undefined), title: (string|undefined)}} 376 * @typedef {!{text: string, subtitle: (string|undefined), iconType: (string|und efined), priority: (number|undefined), isSecondary: (boolean|undefined), title: (string|undefined)}}
362 */ 377 */
363 UI.SuggestBox.Suggestion; 378 UI.SuggestBox.Suggestion;
364 379
365 /** 380 /**
366 * @typedef {!Array<!UI.SuggestBox.Suggestion>} 381 * @typedef {!Array<!UI.SuggestBox.Suggestion>}
367 */ 382 */
368 UI.SuggestBox.Suggestions; 383 UI.SuggestBox.Suggestions;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698