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-keyboard' is the settings subpage with keyboard settings. | 7 * 'settings-keyboard' is the settings subpage with keyboard settings. |
| 8 */ | 8 */ |
| 9 | |
| 10 // TODO(michaelpg): The docs below are duplicates of settings_dropdown_menu, | |
| 11 // because we can't depend on settings_dropdown_menu in compiled_resources2.gyp | |
| 12 // withhout first converting settings_dropdown_menu to compiled_resources2.gyp. | |
| 13 // After the conversion, we should remove these. | |
| 14 /** @typedef {{name: string, value: (number|string)}} */ | |
| 15 var DropdownMenuOption; | |
| 16 /** @typedef {!Array<!DropdownMenuOption>} */ | |
| 17 var DropdownMenuOptionList; | |
| 18 | |
| 19 Polymer({ | 9 Polymer({ |
| 20 is: 'settings-keyboard', | 10 is: 'settings-keyboard', |
| 21 | 11 |
| 22 properties: { | 12 properties: { |
| 23 /** Preferences state. */ | 13 /** Preferences state. */ |
| 24 prefs: { | 14 prefs: { |
| 25 type: Object, | 15 type: Object, |
| 26 notify: true, | 16 notify: true, |
| 27 }, | 17 }, |
| 28 | 18 |
| 29 /** @private Whether to show Caps Lock options. */ | 19 /** @private Whether to show Caps Lock options. */ |
| 30 showCapsLock_: Boolean, | 20 showCapsLock_: Boolean, |
| 31 | 21 |
| 32 /** @private Whether to show diamond key options. */ | 22 /** @private Whether to show diamond key options. */ |
| 33 showDiamondKey_: Boolean, | 23 showDiamondKey_: Boolean, |
| 34 | 24 |
| 35 /** @private {!DropdownMenuOptionList} Menu items for key mapping. */ | 25 /** @private {!DropdownMenuOptionList} Menu items for key mapping. */ |
| 36 keyMapTargets_: Object, | 26 keyMapTargets_: Object, |
| 37 | 27 |
| 38 /** | 28 /** |
| 39 * @private {!DropdownMenuOptionList} Menu items for key mapping, including | |
| 40 * Caps Lock. | |
| 41 */ | |
| 42 keyMapTargetsWithCapsLock_: Object, | |
| 43 | |
| 44 /** | |
| 45 * Auto-repeat delays (in ms) for the corresponding slider values, from | 29 * Auto-repeat delays (in ms) for the corresponding slider values, from |
| 46 * long to short. The values were chosen to provide a large range while | 30 * long to short. The values were chosen to provide a large range while |
| 47 * giving several options near the defaults. | 31 * giving several options near the defaults. |
| 48 * @private {!Array<number>} | 32 * @private {!Array<number>} |
| 49 */ | 33 */ |
| 50 autoRepeatDelays_: { | 34 autoRepeatDelays_: { |
| 51 type: Array, | 35 type: Array, |
| 52 value: [2000, 1500, 1000, 500, 300, 200, 150], | 36 value: [2000, 1500, 1000, 500, 300, 200, 150], |
| 53 readOnly: true, | 37 readOnly: true, |
| 54 }, | 38 }, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 71 cr.addWebUIListener('show-keys-changed', this.onShowKeysChange_.bind(this)); | 55 cr.addWebUIListener('show-keys-changed', this.onShowKeysChange_.bind(this)); |
| 72 settings.DevicePageBrowserProxyImpl.getInstance().initializeKeyboard(); | 56 settings.DevicePageBrowserProxyImpl.getInstance().initializeKeyboard(); |
| 73 this.setUpKeyMapTargets_(); | 57 this.setUpKeyMapTargets_(); |
| 74 }, | 58 }, |
| 75 | 59 |
| 76 /** | 60 /** |
| 77 * Initializes the dropdown menu options for remapping keys. | 61 * Initializes the dropdown menu options for remapping keys. |
| 78 * @private | 62 * @private |
| 79 */ | 63 */ |
| 80 setUpKeyMapTargets_: function() { | 64 setUpKeyMapTargets_: function() { |
| 65 // Ordering is according to UX, but values must match | |
| 66 // the chromeos::input_method::ModifierKey enum. | |
|
stevenjb
2016/10/25 16:49:39
optional nit: It would be nice (but much more verb
michaelpg
2016/10/26 02:24:38
Done. (A bit more verbose, but probably easier to
| |
| 81 this.keyMapTargets_ = [ | 67 this.keyMapTargets_ = [ |
| 82 {value: 0, name: loadTimeData.getString('keyboardKeySearch')}, | 68 {value: 0, name: loadTimeData.getString('keyboardKeySearch')}, |
| 83 {value: 1, name: loadTimeData.getString('keyboardKeyCtrl')}, | 69 {value: 1, name: loadTimeData.getString('keyboardKeyCtrl')}, |
| 84 {value: 2, name: loadTimeData.getString('keyboardKeyAlt')}, | 70 {value: 2, name: loadTimeData.getString('keyboardKeyAlt')}, |
| 71 {value: 4, name: loadTimeData.getString('keyboardKeyCapsLock')}, | |
| 72 {value: 5, name: loadTimeData.getString('keyboardKeyEscape')}, | |
| 73 {value: 6, name: loadTimeData.getString('keyboardKeyBackspace')}, | |
| 85 {value: 3, name: loadTimeData.getString('keyboardKeyDisabled')}, | 74 {value: 3, name: loadTimeData.getString('keyboardKeyDisabled')}, |
| 86 {value: 5, name: loadTimeData.getString('keyboardKeyEscape')}, | |
| 87 ]; | 75 ]; |
| 88 | |
| 89 var keyMapTargetsWithCapsLock = this.keyMapTargets_.slice(); | |
| 90 // Add Caps Lock, for keys allowed to be mapped to Caps Lock. | |
| 91 keyMapTargetsWithCapsLock.splice(4, 0, { | |
| 92 value: 4, name: loadTimeData.getString('keyboardKeyCapsLock'), | |
| 93 }); | |
| 94 this.keyMapTargetsWithCapsLock_ = keyMapTargetsWithCapsLock; | |
| 95 }, | 76 }, |
| 96 | 77 |
| 97 /** | 78 /** |
| 98 * Handler for updating which keys to show. | 79 * Handler for updating which keys to show. |
| 99 * @param {boolean} showCapsLock | 80 * @param {boolean} showCapsLock |
| 100 * @param {boolean} showDiamondKey | 81 * @param {boolean} showDiamondKey |
| 101 * @private | 82 * @private |
| 102 */ | 83 */ |
| 103 onShowKeysChange_: function(showCapsLock, showDiamondKey) { | 84 onShowKeysChange_: function(showCapsLock, showDiamondKey) { |
| 104 this.showCapsLock_ = showCapsLock; | 85 this.showCapsLock_ = showCapsLock; |
| 105 this.showDiamondKey_ = showDiamondKey; | 86 this.showDiamondKey_ = showDiamondKey; |
| 106 }, | 87 }, |
| 107 | 88 |
| 108 onShowKeyboardShortcutsOverlayTap_: function() { | 89 onShowKeyboardShortcutsOverlayTap_: function() { |
| 109 settings.DevicePageBrowserProxyImpl.getInstance() | 90 settings.DevicePageBrowserProxyImpl.getInstance() |
| 110 .showKeyboardShortcutsOverlay(); | 91 .showKeyboardShortcutsOverlay(); |
| 111 }, | 92 }, |
| 112 | 93 |
| 113 onShowLanguageInputTap_: function() { | 94 onShowLanguageInputTap_: function() { |
| 114 settings.navigateTo(settings.Route.LANGUAGES); | 95 settings.navigateTo(settings.Route.LANGUAGES); |
| 115 }, | 96 }, |
| 116 }); | 97 }); |
| OLD | NEW |