OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 this._viewportControl = new WebInspector.ViewportControl(this); | 56 this._viewportControl = new WebInspector.ViewportControl(this); |
57 this._itemElementsContainer = this._viewportControl.element; | 57 this._itemElementsContainer = this._viewportControl.element; |
58 this._itemElementsContainer.classList.add("container"); | 58 this._itemElementsContainer.classList.add("container"); |
59 this._itemElementsContainer.classList.add("monospace"); | 59 this._itemElementsContainer.classList.add("monospace"); |
60 this._itemElementsContainer.addEventListener("click", this._onClick.bind(thi
s), false); | 60 this._itemElementsContainer.addEventListener("click", this._onClick.bind(thi
s), false); |
61 this.element.appendChild(this._itemElementsContainer); | 61 this.element.appendChild(this._itemElementsContainer); |
62 | 62 |
63 this._delegate = delegate; | 63 this._delegate = delegate; |
64 this._delegate.setRefreshCallback(this._itemsLoaded.bind(this)); | 64 this._delegate.setRefreshCallback(this._itemsLoaded.bind(this)); |
65 this._itemsLoaded(); | 65 this._itemsLoaded(); |
66 | |
67 this._shouldShowMatchingItems = true; | |
68 } | 66 } |
69 | 67 |
70 WebInspector.FilteredItemSelectionDialog.prototype = { | 68 WebInspector.FilteredItemSelectionDialog.prototype = { |
71 /** | 69 /** |
72 * @param {!Element} element | 70 * @param {!Element} element |
73 * @param {!Element} relativeToElement | 71 * @param {!Element} relativeToElement |
74 */ | 72 */ |
75 position: function(element, relativeToElement) | 73 position: function(element, relativeToElement) |
76 { | 74 { |
77 const minWidth = 500; | 75 const minWidth = 500; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 break; | 243 break; |
246 } | 244 } |
247 } | 245 } |
248 this._viewportControl.refresh(); | 246 this._viewportControl.refresh(); |
249 if (!query) | 247 if (!query) |
250 this._selectedIndexInFiltered = 0; | 248 this._selectedIndexInFiltered = 0; |
251 this._updateSelection(this._selectedIndexInFiltered, false); | 249 this._updateSelection(this._selectedIndexInFiltered, false); |
252 } | 250 } |
253 }, | 251 }, |
254 | 252 |
| 253 /** |
| 254 * @return {boolean} |
| 255 */ |
| 256 _shouldShowMatchingItems: function() |
| 257 { |
| 258 return this._delegate.shouldShowMatchingItems(this._promptElement.value)
; |
| 259 }, |
| 260 |
255 _onInput: function(event) | 261 _onInput: function(event) |
256 { | 262 { |
257 this._shouldShowMatchingItems = this._delegate.shouldShowMatchingItems(t
his._promptElement.value); | |
258 this._updateShowMatchingItems(); | 263 this._updateShowMatchingItems(); |
259 this._scheduleFilter(); | 264 this._scheduleFilter(); |
260 }, | 265 }, |
261 | 266 |
262 _updateShowMatchingItems: function() | 267 _updateShowMatchingItems: function() |
263 { | 268 { |
264 this._itemElementsContainer.classList.toggle("hidden", !this._shouldShow
MatchingItems); | 269 var shouldShowMatchingItems = this._shouldShowMatchingItems(); |
265 this.element.style.height = this._shouldShowMatchingItems ? this._dialog
Height + "px" : "auto"; | 270 this._itemElementsContainer.classList.toggle("hidden", !shouldShowMatchi
ngItems); |
| 271 this.element.style.height = shouldShowMatchingItems ? this._dialogHeight
+ "px" : "auto"; |
266 }, | 272 }, |
267 | 273 |
268 _onKeyDown: function(event) | 274 _onKeyDown: function(event) |
269 { | 275 { |
270 var newSelectedIndex = this._selectedIndexInFiltered; | 276 var newSelectedIndex = this._selectedIndexInFiltered; |
271 | 277 |
272 switch (event.keyCode) { | 278 switch (event.keyCode) { |
273 case WebInspector.KeyboardShortcut.Keys.Down.code: | 279 case WebInspector.KeyboardShortcut.Keys.Down.code: |
274 if (++newSelectedIndex >= this._filteredItems.length) | 280 if (++newSelectedIndex >= this._filteredItems.length) |
275 newSelectedIndex = this._filteredItems.length - 1; | 281 newSelectedIndex = this._filteredItems.length - 1; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 { | 810 { |
805 return !project.isServiceProject(); | 811 return !project.isServiceProject(); |
806 }, | 812 }, |
807 | 813 |
808 __proto__: WebInspector.SelectUISourceCodeDialog.prototype | 814 __proto__: WebInspector.SelectUISourceCodeDialog.prototype |
809 } | 815 } |
810 | 816 |
811 /** | 817 /** |
812 * @param {!WebInspector.SourcesPanel} panel | 818 * @param {!WebInspector.SourcesPanel} panel |
813 * @param {!Element} relativeToElement | 819 * @param {!Element} relativeToElement |
814 * @param {string=} name | 820 * @param {string=} query |
815 * @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores | 821 * @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores |
816 */ | 822 */ |
817 WebInspector.OpenResourceDialog.show = function(panel, relativeToElement, name,
defaultScores) | 823 WebInspector.OpenResourceDialog.show = function(panel, relativeToElement, query,
defaultScores) |
818 { | 824 { |
819 if (WebInspector.Dialog.currentInstance()) | 825 if (WebInspector.Dialog.currentInstance()) |
820 return; | 826 return; |
821 | 827 |
822 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.OpenResourceDialog(panel, defaultScores)); | 828 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.OpenResourceDialog(panel, defaultScores)); |
823 filteredItemSelectionDialog.renderAsTwoRows(); | 829 filteredItemSelectionDialog.renderAsTwoRows(); |
824 if (name) | 830 if (query) |
825 filteredItemSelectionDialog.setQuery(name); | 831 filteredItemSelectionDialog.setQuery(query); |
826 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); | 832 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); |
827 } | 833 } |
828 | 834 |
829 /** | 835 /** |
830 * @constructor | 836 * @constructor |
831 * @extends {WebInspector.SelectUISourceCodeDialog} | 837 * @extends {WebInspector.SelectUISourceCodeDialog} |
832 * @param {string} type | 838 * @param {string} type |
833 * @param {function(!WebInspector.UISourceCode)} callback | 839 * @param {function(!WebInspector.UISourceCode)} callback |
834 */ | 840 */ |
835 WebInspector.SelectUISourceCodeForProjectTypeDialog = function(type, callback) | 841 WebInspector.SelectUISourceCodeForProjectTypeDialog = function(type, callback) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); | 881 var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDial
og(new WebInspector.SelectUISourceCodeForProjectTypeDialog(type, callback)); |
876 filteredItemSelectionDialog.setQuery(name); | 882 filteredItemSelectionDialog.setQuery(name); |
877 filteredItemSelectionDialog.renderAsTwoRows(); | 883 filteredItemSelectionDialog.renderAsTwoRows(); |
878 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); | 884 WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog); |
879 } | 885 } |
880 | 886 |
881 /** | 887 /** |
882 * @typedef {{index: number, total: number, chunk: !Array.<!{selectorText: strin
g, lineNumber: number, columnNumber: number}>}} | 888 * @typedef {{index: number, total: number, chunk: !Array.<!{selectorText: strin
g, lineNumber: number, columnNumber: number}>}} |
883 */ | 889 */ |
884 WebInspector.JavaScriptOutlineDialog.MessageEventData; | 890 WebInspector.JavaScriptOutlineDialog.MessageEventData; |
OLD | NEW |