Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-display-overscan-dialog' is the dialog for display overscan | 7 * 'settings-display-overscan-dialog' is the dialog for display overscan |
| 8 * adjustments. | 8 * adjustments. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 comitted_: Boolean, | 23 comitted_: Boolean, |
| 24 }, | 24 }, |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Keyboard event handler for overscan adjustments. | 27 * Keyboard event handler for overscan adjustments. |
| 28 * @type {?function(!Event)} | 28 * @type {?function(!Event)} |
| 29 * @private | 29 * @private |
| 30 */ | 30 */ |
| 31 keyHandler_: null, | 31 keyHandler_: null, |
| 32 | 32 |
| 33 /** @override */ | 33 open: function() { |
| 34 attached: function() { | |
| 35 this.keyHandler_ = this.handleKeyEvent_.bind(this); | 34 this.keyHandler_ = this.handleKeyEvent_.bind(this); |
| 36 window.addEventListener('keydown', this.keyHandler_); | 35 window.addEventListener('keydown', this.keyHandler_); |
|
Dan Beam
2016/09/27 00:04:52
why are we using window.addEventListener() rather
stevenjb
2016/09/28 17:49:35
Because I'm still fairly new to web development an
| |
| 37 }, | |
| 38 | |
| 39 /** @override */ | |
| 40 detached: function() { | |
| 41 window.removeEventListener('keydown', this.keyHandler_); | |
| 42 }, | |
| 43 | |
| 44 open: function() { | |
| 45 this.comitted_ = false; | 36 this.comitted_ = false; |
| 46 this.$.dialog.showModal(); | 37 this.$.dialog.showModal(); |
| 47 }, | 38 }, |
| 48 | 39 |
| 49 close: function() { | 40 close: function() { |
| 41 window.removeEventListener('keydown', this.keyHandler_); | |
| 42 | |
| 50 this.displayId = ''; // Will trigger displayIdChanged_. | 43 this.displayId = ''; // Will trigger displayIdChanged_. |
| 51 | 44 |
| 52 if (this.$.dialog.open) | 45 if (this.$.dialog.open) |
| 53 this.$.dialog.close(); | 46 this.$.dialog.close(); |
| 54 }, | 47 }, |
| 55 | 48 |
| 56 /** @private */ | 49 /** @private */ |
| 57 displayIdChanged_: function(newValue, oldValue) { | 50 displayIdChanged_: function(newValue, oldValue) { |
| 58 if (oldValue && !this.comitted_) { | 51 if (oldValue && !this.comitted_) { |
| 59 settings.display.systemDisplayApi.overscanCalibrationReset(oldValue); | 52 settings.display.systemDisplayApi.overscanCalibrationReset(oldValue); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 75 settings.display.systemDisplayApi.overscanCalibrationComplete( | 68 settings.display.systemDisplayApi.overscanCalibrationComplete( |
| 76 this.displayId); | 69 this.displayId); |
| 77 this.comitted_ = true; | 70 this.comitted_ = true; |
| 78 this.close(); | 71 this.close(); |
| 79 }, | 72 }, |
| 80 | 73 |
| 81 /** | 74 /** |
| 82 * @param {Event} event | 75 * @param {Event} event |
| 83 * @private | 76 * @private |
| 84 */ | 77 */ |
| 85 handleKeyEvent_: function(event) { | 78 handleKeyEvent_: function(event) { |
|
dschuyler
2016/09/27 23:45:24
IIUC, the above narrows the scope where alt-left
c
stevenjb
2016/09/28 17:49:35
Done.
| |
| 86 switch (event.keyCode) { | 79 switch (event.keyCode) { |
| 87 case 37: // left arrow | 80 case 37: // left arrow |
| 88 if (event.shiftKey) | 81 if (event.shiftKey) |
| 89 this.move_(-1, 0); | 82 this.move_(-1, 0); |
| 90 else | 83 else |
| 91 this.resize_(1, 0); | 84 this.resize_(1, 0); |
| 92 break; | 85 break; |
| 93 case 38: // up arrow | 86 case 38: // up arrow |
| 94 if (event.shiftKey) | 87 if (event.shiftKey) |
| 95 this.move_(0, -1); | 88 this.move_(0, -1); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 /** @type {!chrome.system.display.Insets} */ var delta = { | 132 /** @type {!chrome.system.display.Insets} */ var delta = { |
| 140 left: x, | 133 left: x, |
| 141 top: y, | 134 top: y, |
| 142 right: x, | 135 right: x, |
| 143 bottom: y, | 136 bottom: y, |
| 144 }; | 137 }; |
| 145 settings.display.systemDisplayApi.overscanCalibrationAdjust( | 138 settings.display.systemDisplayApi.overscanCalibrationAdjust( |
| 146 this.displayId, delta); | 139 this.displayId, delta); |
| 147 } | 140 } |
| 148 }); | 141 }); |
| OLD | NEW |