| 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 cr.define('ntp', function() { | 5 cr.define('ntp', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // We can't pass the currently dragging tile via dataTransfer because of | 8 // We can't pass the currently dragging tile via dataTransfer because of |
| 9 // http://crbug.com/31037 | 9 // http://crbug.com/31037 |
| 10 var currentlyDraggingTile = null; | 10 var currentlyDraggingTile = null; |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // We only handle up, down, left, right without control keys. | 698 // We only handle up, down, left, right without control keys. |
| 699 if (e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) | 699 if (e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) |
| 700 return; | 700 return; |
| 701 | 701 |
| 702 // Wrap the given index to |this.focusableElements_|. | 702 // Wrap the given index to |this.focusableElements_|. |
| 703 var wrap = function(idx) { | 703 var wrap = function(idx) { |
| 704 return (idx + this.focusableElements_.length) % | 704 return (idx + this.focusableElements_.length) % |
| 705 this.focusableElements_.length; | 705 this.focusableElements_.length; |
| 706 }.bind(this); | 706 }.bind(this); |
| 707 | 707 |
| 708 switch (e.keyIdentifier) { | 708 switch (e.key) { |
| 709 case 'Right': | 709 case 'ArrowRight': |
| 710 case 'Left': | 710 case 'ArrowLeft': |
| 711 var direction = e.keyIdentifier == 'Right' ? 1 : -1; | 711 var direction = e.key == 'ArrowRight' ? 1 : -1; |
| 712 this.focusElementIndex_ = wrap(this.focusElementIndex_ + direction); | 712 this.focusElementIndex_ = wrap(this.focusElementIndex_ + direction); |
| 713 break; | 713 break; |
| 714 case 'Up': | 714 case 'ArrowUp': |
| 715 case 'Down': | 715 case 'ArrowDown': |
| 716 // Look through all focusable elements. Find the first one that is | 716 // Look through all focusable elements. Find the first one that is |
| 717 // in the same column. | 717 // in the same column. |
| 718 var direction = e.keyIdentifier == 'Up' ? -1 : 1; | 718 var direction = e.key == 'ArrowUp' ? -1 : 1; |
| 719 var currentIndex = | 719 var currentIndex = |
| 720 Array.prototype.indexOf.call(this.focusableElements_, | 720 Array.prototype.indexOf.call(this.focusableElements_, |
| 721 this.currentFocusElement_); | 721 this.currentFocusElement_); |
| 722 var newFocusIdx = wrap(currentIndex + direction); | 722 var newFocusIdx = wrap(currentIndex + direction); |
| 723 var tile = this.currentFocusElement_.parentNode; | 723 var tile = this.currentFocusElement_.parentNode; |
| 724 for (;; newFocusIdx = wrap(newFocusIdx + direction)) { | 724 for (;; newFocusIdx = wrap(newFocusIdx + direction)) { |
| 725 var newTile = this.focusableElements_[newFocusIdx].parentNode; | 725 var newTile = this.focusableElements_[newFocusIdx].parentNode; |
| 726 var rowTiles = this.layoutValues_.numRowTiles; | 726 var rowTiles = this.layoutValues_.numRowTiles; |
| 727 if ((newTile.index - tile.index) % rowTiles == 0) | 727 if ((newTile.index - tile.index) % rowTiles == 0) |
| 728 break; | 728 break; |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 }; | 1327 }; |
| 1328 | 1328 |
| 1329 return { | 1329 return { |
| 1330 getCurrentlyDraggingTile: getCurrentlyDraggingTile, | 1330 getCurrentlyDraggingTile: getCurrentlyDraggingTile, |
| 1331 setCurrentDropEffect: setCurrentDropEffect, | 1331 setCurrentDropEffect: setCurrentDropEffect, |
| 1332 // Not used outside, just for usage in JSDoc inside this file. | 1332 // Not used outside, just for usage in JSDoc inside this file. |
| 1333 Tile: Tile, | 1333 Tile: Tile, |
| 1334 TilePage: TilePage, | 1334 TilePage: TilePage, |
| 1335 }; | 1335 }; |
| 1336 }); | 1336 }); |
| OLD | NEW |