OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview | |
7 * 'settings-keyboard' is the settings subpage with keyboard settings. | |
8 * | |
9 * @group Chrome Settings Elements | |
10 */ | |
11 | |
12 // TODO(michaelpg): don't duplicate these docs; convert settings_dropdown_menu | |
13 // and everything that depends on it to compiled_resources2.gyp? | |
dschuyler
2016/03/02 01:08:06
Is this referring to the comment below?
Maybe ment
michaelpg
2016/03/02 02:42:06
Done.
| |
14 | |
15 /** | |
16 * The |name| is shown in the gui. The |value| us use to set or compare with | |
17 * the preference value. | |
18 * @typedef {{ | |
19 * name: string, | |
20 * value: (number|string) | |
21 * }} | |
22 */ | |
23 var DropdownMenuOption; | |
24 | |
25 /** | |
26 * @typedef {!Array<!DropdownMenuOption>} | |
27 */ | |
28 var DropdownMenuOptionList; | |
29 | |
30 Polymer({ | |
31 is: 'settings-keyboard', | |
32 | |
33 behaviors: [ | |
34 I18nBehavior, | |
35 ], | |
36 | |
37 properties: { | |
38 /** Preferences state. */ | |
39 prefs: { | |
40 type: Object, | |
41 notify: true, | |
42 }, | |
43 | |
44 /** @private Whether to show Caps Lock options. */ | |
45 showCapsLock_: Boolean, | |
46 | |
47 /** @private Whether to show diamond key options. */ | |
48 showDiamondKey_: Boolean, | |
49 | |
50 /** @private {!DropdownMenuOptionList} Menu items for key mapping. */ | |
51 keyMapTargets_: Object, | |
52 | |
53 /** | |
54 * @private {!DropdownMenuOptionList} Menu items for key mapping, including | |
55 * Caps Lock. | |
56 */ | |
57 keyMapTargetsWithCapsLock_: Object, | |
58 }, | |
59 | |
60 /** @override */ | |
61 ready: function() { | |
62 cr.addWebUIListener('show-keys-changed', this.onShowKeysChange_.bind(this)); | |
63 chrome.send('initializeKeyboardSettings'); | |
64 this.setUpKeyMapTargets_(); | |
65 }, | |
66 | |
67 /** | |
68 * Initializes the dropdown menu options for remapping keys. | |
69 * @private | |
70 */ | |
71 setUpKeyMapTargets_: function() { | |
72 this.keyMapTargets_ = [ | |
73 {value: 0, name: loadTimeData.getString('keyboardKeySearch')}, | |
74 {value: 1, name: loadTimeData.getString('keyboardKeyCtrl')}, | |
75 {value: 2, name: loadTimeData.getString('keyboardKeyAlt')}, | |
76 {value: 3, name: loadTimeData.getString('keyboardKeyDisabled')}, | |
77 {value: 5, name: loadTimeData.getString('keyboardKeyEscape')}, | |
78 ]; | |
79 | |
80 var keyMapTargetsWithCapsLock = this.keyMapTargets_.slice(); | |
81 // Add Caps Lock, for keys allowed to be mapped to Caps Lock. | |
82 keyMapTargetsWithCapsLock.splice(4, 0, { | |
83 value: 4, name: loadTimeData.getString('keyboardKeyCapsLock'), | |
84 }); | |
85 this.keyMapTargetsWithCapsLock_ = keyMapTargetsWithCapsLock; | |
86 }, | |
87 | |
88 /** | |
89 * Handler for updating which keys to show. | |
90 * @param {boolean} showCapsLock | |
91 * @param {boolean} showDiamondKey | |
92 * @private | |
93 */ | |
94 onShowKeysChange_: function(showCapsLock, showDiamondKey) { | |
95 this.showCapsLock_ = showCapsLock; | |
96 this.showDiamondKey_ = showDiamondKey; | |
97 }, | |
98 }); | |
OLD | NEW |