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

Side by Side Diff: chrome/browser/resources/local_ntp/local_ntp.js

Issue 14562006: Handle Esc key press event in Local NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 years, 7 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 <include src="../../../../ui/webui/resources/js/assert.js"> 6 <include src="../../../../ui/webui/resources/js/assert.js">
7 7
8 /** 8 /**
9 * True if this a Google page and not some other search provider. Used to 9 * True if this a Google page and not some other search provider. Used to
10 * determine whether to show the logo and fakebox. 10 * determine whether to show the logo and fakebox.
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 var KEY_UP_ARROW = 38; 641 var KEY_UP_ARROW = 38;
642 642
643 /** 643 /**
644 * "Down" arrow keycode. 644 * "Down" arrow keycode.
645 * @type {number} 645 * @type {number}
646 * @const 646 * @const
647 */ 647 */
648 var KEY_DOWN_ARROW = 40; 648 var KEY_DOWN_ARROW = 40;
649 649
650 /** 650 /**
651 * "Esc" keycode.
652 * @type {number}
653 * @const
654 */
655 var KEY_ESC = 27;
656
657 /**
651 * Pixels of padding inside a suggestion div for displaying its icon. 658 * Pixels of padding inside a suggestion div for displaying its icon.
652 * @type {number} 659 * @type {number}
653 * @const 660 * @const
654 */ 661 */
655 var SUGGESTION_ICON_PADDING = 26; 662 var SUGGESTION_ICON_PADDING = 26;
656 663
657 /** 664 /**
658 * Pixels by which iframes should be moved down relative to their wrapping 665 * Pixels by which iframes should be moved down relative to their wrapping
659 * suggestion div. 666 * suggestion div.
660 */ 667 */
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 // This is bound only for initialization. Afterwards this style should only 1311 // This is bound only for initialization. Afterwards this style should only
1305 // change onmarginchange. 1312 // change onmarginchange.
1306 window.removeEventListener('resize', setSuggestionStyles); 1313 window.removeEventListener('resize', setSuggestionStyles);
1307 } 1314 }
1308 1315
1309 /** 1316 /**
1310 * Makes keys navigate through suggestions. 1317 * Makes keys navigate through suggestions.
1311 * @param {Object} e The key being pressed. 1318 * @param {Object} e The key being pressed.
1312 */ 1319 */
1313 function handleKeyPress(e) { 1320 function handleKeyPress(e) {
1314 if (!activeBox)
1315 return;
1316
1317 switch (e.keyCode) { 1321 switch (e.keyCode) {
1318 case KEY_UP_ARROW: 1322 case KEY_UP_ARROW:
1319 activeBox.selectPrevious(); 1323 if (activeBox)
1324 activeBox.selectPrevious();
1320 break; 1325 break;
1321 case KEY_DOWN_ARROW: 1326 case KEY_DOWN_ARROW:
1322 activeBox.selectNext(); 1327 if (activeBox)
1328 activeBox.selectNext();
1329 break;
1330 case KEY_ESC:
1331 hideActiveSuggestions();
samarth 2013/05/04 01:04:17 There are two cases here too :) 1) You type someth
kmadhusu 2013/05/04 03:34:38 Done.
1332 document.body.classList.remove(CLASSES.HIDE_NTP);
1333 onThemeChange();
samarth 2013/05/04 01:04:17 Not sure if this is the right way to go back to th
kmadhusu 2013/05/04 03:34:38 This call reloads the background theme if one exis
1323 break; 1334 break;
1324 } 1335 }
1325 } 1336 }
1326 1337
1327 /** 1338 /**
1328 * Handles postMessage calls from suggestion iframes. 1339 * Handles postMessage calls from suggestion iframes.
1329 * @param {Object} message A notification that all iframes are done loading or 1340 * @param {Object} message A notification that all iframes are done loading or
1330 * that an iframe was clicked. 1341 * that an iframe was clicked.
1331 */ 1342 */
1332 function handleMessage(message) { 1343 function handleMessage(message) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 } 1537 }
1527 } 1538 }
1528 1539
1529 document.addEventListener('DOMContentLoaded', init); 1540 document.addEventListener('DOMContentLoaded', init);
1530 window.addEventListener('message', handleMessage, false); 1541 window.addEventListener('message', handleMessage, false);
1531 window.addEventListener('blur', function() { 1542 window.addEventListener('blur', function() {
1532 if (activeBox) 1543 if (activeBox)
1533 activeBox.clearHover(); 1544 activeBox.clearHover();
1534 }, false); 1545 }, false);
1535 })(); 1546 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/search/instant_controller.h » ('j') | chrome/browser/ui/search/instant_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698