Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/resources/settings/device_page/keyboard.js

Issue 2449723002: MD Settings: Add remapping options for Backspace and Escape (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cr.exportPath('settings');
9 10
10 // TODO(michaelpg): The docs below are duplicates of settings_dropdown_menu, 11 /**
11 // because we can't depend on settings_dropdown_menu in compiled_resources2.gyp 12 * Modifier key IDs corresponding to the ModifierKey enumerators in
12 // withhout first converting settings_dropdown_menu to compiled_resources2.gyp. 13 * /ui/base/ime/chromeos/ime_keyboard.h.
13 // After the conversion, we should remove these. 14 * @enum {number}
14 /** @typedef {{name: string, value: (number|string)}} */ 15 */
15 var DropdownMenuOption; 16 settings.ModifierKey = {
16 /** @typedef {!Array<!DropdownMenuOption>} */ 17 SEARCH_KEY: 0,
17 var DropdownMenuOptionList; 18 CONTROL_KEY: 1,
19 ALT_KEY: 2,
20 VOID_KEY: 3, // Represents a disabled key.
21 CAPS_LOCK_KEY: 4,
22 ESCAPE_KEY: 5,
23 BACKSPACE_KEY: 6,
24 };
18 25
19 Polymer({ 26 Polymer({
20 is: 'settings-keyboard', 27 is: 'settings-keyboard',
21 28
22 properties: { 29 properties: {
23 /** Preferences state. */ 30 /** Preferences state. */
24 prefs: { 31 prefs: {
25 type: Object, 32 type: Object,
26 notify: true, 33 notify: true,
27 }, 34 },
28 35
29 /** @private Whether to show Caps Lock options. */ 36 /** @private Whether to show Caps Lock options. */
30 showCapsLock_: Boolean, 37 showCapsLock_: Boolean,
31 38
32 /** @private Whether to show diamond key options. */ 39 /** @private Whether to show diamond key options. */
33 showDiamondKey_: Boolean, 40 showDiamondKey_: Boolean,
34 41
35 /** @private {!DropdownMenuOptionList} Menu items for key mapping. */ 42 /** @private {!DropdownMenuOptionList} Menu items for key mapping. */
36 keyMapTargets_: Object, 43 keyMapTargets_: Object,
37 44
38 /** 45 /**
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 46 * 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 47 * long to short. The values were chosen to provide a large range while
47 * giving several options near the defaults. 48 * giving several options near the defaults.
48 * @private {!Array<number>} 49 * @private {!Array<number>}
49 */ 50 */
50 autoRepeatDelays_: { 51 autoRepeatDelays_: {
51 type: Array, 52 type: Array,
52 value: [2000, 1500, 1000, 500, 300, 200, 150], 53 value: [2000, 1500, 1000, 500, 300, 200, 150],
53 readOnly: true, 54 readOnly: true,
54 }, 55 },
(...skipping 16 matching lines...) Expand all
71 cr.addWebUIListener('show-keys-changed', this.onShowKeysChange_.bind(this)); 72 cr.addWebUIListener('show-keys-changed', this.onShowKeysChange_.bind(this));
72 settings.DevicePageBrowserProxyImpl.getInstance().initializeKeyboard(); 73 settings.DevicePageBrowserProxyImpl.getInstance().initializeKeyboard();
73 this.setUpKeyMapTargets_(); 74 this.setUpKeyMapTargets_();
74 }, 75 },
75 76
76 /** 77 /**
77 * Initializes the dropdown menu options for remapping keys. 78 * Initializes the dropdown menu options for remapping keys.
78 * @private 79 * @private
79 */ 80 */
80 setUpKeyMapTargets_: function() { 81 setUpKeyMapTargets_: function() {
81 this.keyMapTargets_ = [ 82 // Ordering is according to UX, but values match settings.ModifierKey.
82 {value: 0, name: loadTimeData.getString('keyboardKeySearch')}, 83 this.keyMapTargets_ = [{
83 {value: 1, name: loadTimeData.getString('keyboardKeyCtrl')}, 84 value: settings.ModifierKey.SEARCH_KEY,
84 {value: 2, name: loadTimeData.getString('keyboardKeyAlt')}, 85 name: loadTimeData.getString('keyboardKeySearch'),
85 {value: 3, name: loadTimeData.getString('keyboardKeyDisabled')}, 86 }, {
86 {value: 5, name: loadTimeData.getString('keyboardKeyEscape')}, 87 value: settings.ModifierKey.CONTROL_KEY,
87 ]; 88 name: loadTimeData.getString('keyboardKeyCtrl')
88 89 }, {
89 var keyMapTargetsWithCapsLock = this.keyMapTargets_.slice(); 90 value: settings.ModifierKey.ALT_KEY,
90 // Add Caps Lock, for keys allowed to be mapped to Caps Lock. 91 name: loadTimeData.getString('keyboardKeyAlt')
91 keyMapTargetsWithCapsLock.splice(4, 0, { 92 }, {
92 value: 4, name: loadTimeData.getString('keyboardKeyCapsLock'), 93 value: settings.ModifierKey.CAPS_LOCK_KEY,
93 }); 94 name: loadTimeData.getString('keyboardKeyCapsLock')
94 this.keyMapTargetsWithCapsLock_ = keyMapTargetsWithCapsLock; 95 }, {
96 value: settings.ModifierKey.ESCAPE_KEY,
97 name: loadTimeData.getString('keyboardKeyEscape')
98 }, {
99 value: settings.ModifierKey.BACKSPACE_KEY,
100 name: loadTimeData.getString('keyboardKeyBackspace')
101 }, {
102 value: settings.ModifierKey.VOID_KEY,
103 name: loadTimeData.getString('keyboardKeyDisabled')
104 }];
95 }, 105 },
96 106
97 /** 107 /**
98 * Handler for updating which keys to show. 108 * Handler for updating which keys to show.
99 * @param {boolean} showCapsLock 109 * @param {boolean} showCapsLock
100 * @param {boolean} showDiamondKey 110 * @param {boolean} showDiamondKey
101 * @private 111 * @private
102 */ 112 */
103 onShowKeysChange_: function(showCapsLock, showDiamondKey) { 113 onShowKeysChange_: function(showCapsLock, showDiamondKey) {
104 this.showCapsLock_ = showCapsLock; 114 this.showCapsLock_ = showCapsLock;
105 this.showDiamondKey_ = showDiamondKey; 115 this.showDiamondKey_ = showDiamondKey;
106 }, 116 },
107 117
108 onShowKeyboardShortcutsOverlayTap_: function() { 118 onShowKeyboardShortcutsOverlayTap_: function() {
109 settings.DevicePageBrowserProxyImpl.getInstance() 119 settings.DevicePageBrowserProxyImpl.getInstance()
110 .showKeyboardShortcutsOverlay(); 120 .showKeyboardShortcutsOverlay();
111 }, 121 },
112 122
113 onShowLanguageInputTap_: function() { 123 onShowLanguageInputTap_: function() {
114 settings.navigateTo(settings.Route.LANGUAGES); 124 settings.navigateTo(settings.Route.LANGUAGES);
115 }, 125 },
116 }); 126 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698