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

Side by Side Diff: chrome/test/data/instant_extended.html

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted back to asvitkine's fix. REALLY answered PK's comments. :) Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 4
5 var apiHandle; 5 var apiHandle;
6 var onnativesuggestioncalls = 0; 6 var onnativesuggestioncalls = 0;
7 var onsubmitcalls = 0; 7 var onsubmitcalls = 0;
8 var savedUserText = null; 8 var savedUserText = null;
9 var suggestionIndex = -1; 9 var suggestionIndex = -1;
10 var suggestions = ["result 1", "result 2", "result 3"]; 10 var suggestions = ["result 1", "result 2", "result 3"];
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 suggestionIndex++; 43 suggestionIndex++;
44 apiHandle.setValue(suggestions[suggestionIndex]); 44 apiHandle.setValue(suggestions[suggestionIndex]);
45 } 45 }
46 } 46 }
47 47
48 function previousSuggestion() { 48 function previousSuggestion() {
49 if (suggestionIndex != -1) { 49 if (suggestionIndex != -1) {
50 suggestionIndex--; 50 suggestionIndex--;
51 if (suggestionIndex == -1) { 51 if (suggestionIndex == -1) {
52 apiHandle.setValue(savedUserText); 52 apiHandle.setValue(savedUserText);
53 suggestionIndex = -1;
53 } else { 54 } else {
54 apiHandle.setValue(suggestions[suggestionIndex]); 55 apiHandle.setValue(suggestions[suggestionIndex]);
55 } 56 }
56 } 57 }
57 } 58 }
58 59
59 function handleKeyPress(event) { 60 function handleKeyPress(event) {
60 var VKEY_UP = 0x26; 61 var VKEY_UP = 0x26;
61 var VKEY_DOWN = 0x28; 62 var VKEY_DOWN = 0x28;
63 var VKEY_ESCAPE = 0x1B;
62 64
63 if (event.keyCode == VKEY_DOWN) { 65 if (event.keyCode == VKEY_DOWN) {
64 nextSuggestion(); 66 nextSuggestion();
65 } else if (event.keyCode == VKEY_UP) { 67 } else if (event.keyCode == VKEY_UP) {
66 previousSuggestion(); 68 previousSuggestion();
69 } else if (event.keyCode == VKEY_ESCAPE) {
70 suggestionIndex = -1;
67 } 71 }
68 } 72 }
69 73
70 function setUp() { 74 function setUp() {
71 apiHandle = getApiHandle(); 75 apiHandle = getApiHandle();
72 apiHandle.onnativesuggestions = handleNativeSuggestions; 76 apiHandle.onnativesuggestions = handleNativeSuggestions;
73 apiHandle.onsubmit = handleSubmit; 77 apiHandle.onsubmit = handleSubmit;
74 apiHandle.onchange = handleOnChange; 78 apiHandle.onchange = handleOnChange;
75 apiHandle.onkeypress = handleKeyPress; 79 apiHandle.onkeypress = handleKeyPress;
76 if (apiHandle.value) { 80 if (apiHandle.value) {
77 handleNativeSuggestions(); 81 handleNativeSuggestions();
78 handleOnChange(); 82 handleOnChange();
79 } 83 }
80 } 84 }
81 85
82 setUp(); 86 setUp();
83 87
84 </script> 88 </script>
85 </head> 89 </head>
86 <body> 90 <body>
87 <h1>Instant</h1> 91 <h1>Instant</h1>
88 </body> 92 </body>
89 </html> 93 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698