OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <include src="../uber/uber_utils.js"> | 5 <include src="../uber/uber_utils.js"> |
6 <include src="history_focus_manager.js"> | 6 <include src="history_focus_manager.js"> |
7 | 7 |
8 /////////////////////////////////////////////////////////////////////////////// | 8 /////////////////////////////////////////////////////////////////////////////// |
9 // Globals: | 9 // Globals: |
10 /** @const */ var RESULTS_PER_PAGE = 150; | 10 /** @const */ var RESULTS_PER_PAGE = 150; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 controls.push(this.dropDown); | 476 controls.push(this.dropDown); |
477 | 477 |
478 return controls; | 478 return controls; |
479 }; | 479 }; |
480 | 480 |
481 /** | 481 /** |
482 * @param {Event} e A keydown event to handle. | 482 * @param {Event} e A keydown event to handle. |
483 * @private | 483 * @private |
484 */ | 484 */ |
485 Visit.prototype.handleKeydown_ = function(e) { | 485 Visit.prototype.handleKeydown_ = function(e) { |
486 var keyCode = e.keyCode; | 486 if (e.keyCode == 8 || e.keyCode == 46) { // Delete or Backspace. |
487 if (keyCode == 8 || keyCode == 46) { // Delete or Backspace. | |
488 if (!this.model_.isDeletingVisits()) | 487 if (!this.model_.isDeletingVisits()) |
489 this.removeEntryFromHistory_(e); | 488 this.removeEntryFromHistory_(e); |
490 return; | 489 return; |
491 } | 490 } |
492 | 491 |
493 var target = e.target; | 492 var target = e.target; |
494 if (target != document.activeElement || !(keyCode == 37 || keyCode == 39)) { | 493 var key = e.keyIdentifier; |
495 // Handling key code for inactive element or key wasn't left or right. | 494 if (target != document.activeElement || !(key == 'Left' || key == 'Right')) |
496 return; | 495 return; |
497 } | |
498 | 496 |
499 var controls = this.getFocusableControls_(); | 497 var controls = this.getFocusableControls_(); |
500 for (var i = 0; i < controls.length; ++i) { | 498 for (var i = 0; i < controls.length; ++i) { |
501 if (controls[i].contains(target)) { | 499 if (controls[i].contains(target)) { |
502 /** @const */ var isLeft = e.keyCode == 37; | 500 var toFocus = key == 'Left' ? controls[i - 1] : controls[i + 1]; |
503 var toFocus = isLeft ? controls[i - 1] : controls[i + 1]; | |
504 if (toFocus) { | 501 if (toFocus) { |
505 this.focusControl(toFocus); | 502 this.focusControl(toFocus); |
506 e.preventDefault(); | 503 e.preventDefault(); |
507 } | 504 } |
508 break; | 505 break; |
509 } | 506 } |
510 } | 507 } |
511 }; | 508 }; |
512 | 509 |
513 /** | 510 /** |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 | 1674 |
1678 activeVisit.setIsLead(false); | 1675 activeVisit.setIsLead(false); |
1679 }; | 1676 }; |
1680 | 1677 |
1681 /** | 1678 /** |
1682 * @param {Event} e A keydown event to handle. | 1679 * @param {Event} e A keydown event to handle. |
1683 * @private | 1680 * @private |
1684 */ | 1681 */ |
1685 HistoryView.prototype.handleKeydown_ = function(e) { | 1682 HistoryView.prototype.handleKeydown_ = function(e) { |
1686 // Only handle up or down arrows on the focused element. | 1683 // Only handle up or down arrows on the focused element. |
1687 var keyCode = e.keyCode, target = e.target; | 1684 var key = e.keyIdentifier, target = e.target; |
1688 if (target != document.activeElement || !(keyCode == 38 || keyCode == 40)) | 1685 if (target != document.activeElement || !(key == 'Up' || key == 'Down')) |
1689 return; | 1686 return; |
1690 | 1687 |
1691 var entry = findAncestorByClass(e.target, 'entry'); | 1688 var entry = findAncestorByClass(e.target, 'entry'); |
1692 var visit = entry && entry.visit; | 1689 var visit = entry && entry.visit; |
1693 this.swapFocusedVisit_(keyCode == 38 ? this.getVisitBefore_(visit) : | 1690 this.swapFocusedVisit_(key == 'Up' ? this.getVisitBefore_(visit) : |
1694 this.getVisitAfter_(visit)); | 1691 this.getVisitAfter_(visit)); |
1695 }; | 1692 }; |
1696 | 1693 |
1697 /** | 1694 /** |
1698 * @param {Event} e A mousedown event to handle. | 1695 * @param {Event} e A mousedown event to handle. |
1699 * @private | 1696 * @private |
1700 */ | 1697 */ |
1701 HistoryView.prototype.handleMousedown_ = function(e) { | 1698 HistoryView.prototype.handleMousedown_ = function(e) { |
1702 var target = e.target; | 1699 var target = e.target; |
1703 var entry = findAncestorByClass(target, 'entry'); | 1700 var entry = findAncestorByClass(target, 'entry'); |
1704 if (!entry || !entry.contains(target)) | 1701 if (!entry || !entry.contains(target)) |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 historyView.reload(); | 2327 historyView.reload(); |
2331 } | 2328 } |
2332 | 2329 |
2333 // Add handlers to HTML elements. | 2330 // Add handlers to HTML elements. |
2334 document.addEventListener('DOMContentLoaded', load); | 2331 document.addEventListener('DOMContentLoaded', load); |
2335 | 2332 |
2336 // This event lets us enable and disable menu items before the menu is shown. | 2333 // This event lets us enable and disable menu items before the menu is shown. |
2337 document.addEventListener('canExecute', function(e) { | 2334 document.addEventListener('canExecute', function(e) { |
2338 e.canExecute = true; | 2335 e.canExecute = true; |
2339 }); | 2336 }); |
OLD | NEW |