| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * ImageEditor is the top level object that holds together and connects | 6 * ImageEditor is the top level object that holds together and connects |
| 7 * everything needed for image editing. | 7 * everything needed for image editing. |
| 8 * | 8 * |
| 9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
| 10 * @param {!ImageView} imageView The ImageView containing the images to edit. | 10 * @param {!ImageView} imageView The ImageView containing the images to edit. |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 741 } |
| 742 console.error('Mode "' + name + '" not found.'); | 742 console.error('Mode "' + name + '" not found.'); |
| 743 }; | 743 }; |
| 744 | 744 |
| 745 /** | 745 /** |
| 746 * Key down handler. | 746 * Key down handler. |
| 747 * @param {!Event} event The keydown event. | 747 * @param {!Event} event The keydown event. |
| 748 * @return {boolean} True if handled. | 748 * @return {boolean} True if handled. |
| 749 */ | 749 */ |
| 750 ImageEditor.prototype.onKeyDown = function(event) { | 750 ImageEditor.prototype.onKeyDown = function(event) { |
| 751 switch (util.getKeyModifiers(event) + event.keyIdentifier) { | 751 switch (util.getKeyModifiers(event) + event.key) { |
| 752 case 'U+001B': // Escape | 752 case 'Escape': |
| 753 case 'Enter': | 753 case 'Enter': |
| 754 if (this.getMode()) { | 754 if (this.getMode()) { |
| 755 this.leaveModeInternal_(event.keyIdentifier === 'Enter', | 755 this.leaveModeInternal_(event.key === 'Enter', |
| 756 false /* not to switch mode */); | 756 false /* not to switch mode */); |
| 757 return true; | 757 return true; |
| 758 } | 758 } |
| 759 break; | 759 break; |
| 760 | 760 |
| 761 case 'Ctrl-U+005A': // Ctrl+Z | 761 case 'Ctrl-z': // Ctrl+Z |
| 762 if (this.commandQueue_.canUndo()) { | 762 if (this.commandQueue_.canUndo()) { |
| 763 this.undo(); | 763 this.undo(); |
| 764 return true; | 764 return true; |
| 765 } | 765 } |
| 766 break; | 766 break; |
| 767 | 767 |
| 768 case 'Ctrl-U+0059': // Ctrl+Y | 768 case 'Ctrl-y': // Ctrl+Y |
| 769 if (this.commandQueue_.canRedo()) { | 769 if (this.commandQueue_.canRedo()) { |
| 770 this.redo(); | 770 this.redo(); |
| 771 return true; | 771 return true; |
| 772 } | 772 } |
| 773 break; | 773 break; |
| 774 | 774 |
| 775 case 'U+0041': // 'a' | 775 case 'a': |
| 776 this.enterModeByName_('autofix'); | 776 this.enterModeByName_('autofix'); |
| 777 return true; | 777 return true; |
| 778 | 778 |
| 779 case 'U+0042': // 'b' | 779 case 'b': |
| 780 this.enterModeByName_('exposure'); | 780 this.enterModeByName_('exposure'); |
| 781 return true; | 781 return true; |
| 782 | 782 |
| 783 case 'U+0043': // 'c' | 783 case 'c': |
| 784 this.enterModeByName_('crop'); | 784 this.enterModeByName_('crop'); |
| 785 return true; | 785 return true; |
| 786 | 786 |
| 787 case 'U+004C': // 'l' | 787 case 'l': |
| 788 this.enterModeByName_('rotate_left'); | 788 this.enterModeByName_('rotate_left'); |
| 789 return true; | 789 return true; |
| 790 | 790 |
| 791 case 'U+0052': // 'r' | 791 case 'r': |
| 792 this.enterModeByName_('rotate_right'); | 792 this.enterModeByName_('rotate_right'); |
| 793 return true; | 793 return true; |
| 794 } | 794 } |
| 795 return false; | 795 return false; |
| 796 }; | 796 }; |
| 797 | 797 |
| 798 /** | 798 /** |
| 799 * Double tap handler. | 799 * Double tap handler. |
| 800 * @param {number} x X coordinate of the event. | 800 * @param {number} x X coordinate of the event. |
| 801 * @param {number} y Y coordinate of the event. | 801 * @param {number} y Y coordinate of the event. |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 | 1266 |
| 1267 button.label = strf(title); | 1267 button.label = strf(title); |
| 1268 button.setAttribute('aria-label', strf(title)); | 1268 button.setAttribute('aria-label', strf(title)); |
| 1269 | 1269 |
| 1270 GalleryUtil.decorateMouseFocusHandling(button); | 1270 GalleryUtil.decorateMouseFocusHandling(button); |
| 1271 | 1271 |
| 1272 button.addEventListener('click', handler, false); | 1272 button.addEventListener('click', handler, false); |
| 1273 button.addEventListener('keydown', function(event) { | 1273 button.addEventListener('keydown', function(event) { |
| 1274 // Stop propagation of Enter key event to prevent it from being captured by | 1274 // Stop propagation of Enter key event to prevent it from being captured by |
| 1275 // image editor. | 1275 // image editor. |
| 1276 if (event.keyIdentifier === 'Enter') | 1276 if (event.key === 'Enter') |
| 1277 event.stopPropagation(); | 1277 event.stopPropagation(); |
| 1278 }); | 1278 }); |
| 1279 | 1279 |
| 1280 return button; | 1280 return button; |
| 1281 }; | 1281 }; |
| 1282 | 1282 |
| 1283 /** | 1283 /** |
| 1284 * Add a button. | 1284 * Add a button. |
| 1285 * | 1285 * |
| 1286 * @param {string} title Button title. | 1286 * @param {string} title Button title. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 range.appendChild(slider); | 1336 range.appendChild(slider); |
| 1337 | 1337 |
| 1338 range.name = name; | 1338 range.name = name; |
| 1339 range.getValue = function(slider, scale) { | 1339 range.getValue = function(slider, scale) { |
| 1340 return slider.value / scale; | 1340 return slider.value / scale; |
| 1341 }.bind(this, slider, scale); | 1341 }.bind(this, slider, scale); |
| 1342 | 1342 |
| 1343 // Swallow the left and right keys, so they are not handled by other | 1343 // Swallow the left and right keys, so they are not handled by other |
| 1344 // listeners. | 1344 // listeners. |
| 1345 range.addEventListener('keydown', function(e) { | 1345 range.addEventListener('keydown', function(e) { |
| 1346 if (e.keyIdentifier === 'Left' || e.keyIdentifier === 'Right') | 1346 if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') |
| 1347 e.stopPropagation(); | 1347 e.stopPropagation(); |
| 1348 }); | 1348 }); |
| 1349 | 1349 |
| 1350 this.add(range); | 1350 this.add(range); |
| 1351 | 1351 |
| 1352 return range; | 1352 return range; |
| 1353 }; | 1353 }; |
| 1354 | 1354 |
| 1355 /** | 1355 /** |
| 1356 * @return {!Object} options A map of options. | 1356 * @return {!Object} options A map of options. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 | 1528 |
| 1529 /** | 1529 /** |
| 1530 * Hide the prompt. | 1530 * Hide the prompt. |
| 1531 */ | 1531 */ |
| 1532 ImageEditor.Prompt.prototype.hide = function() { | 1532 ImageEditor.Prompt.prototype.hide = function() { |
| 1533 if (!this.prompt_) return; | 1533 if (!this.prompt_) return; |
| 1534 this.prompt_.setAttribute('state', 'fadeout'); | 1534 this.prompt_.setAttribute('state', 'fadeout'); |
| 1535 // Allow some time for the animation to play out. | 1535 // Allow some time for the animation to play out. |
| 1536 this.setTimer(this.reset.bind(this), 500); | 1536 this.setTimer(this.reset.bind(this), 500); |
| 1537 }; | 1537 }; |
| OLD | NEW |