OLD | NEW |
1 <!-- | 1 <!-- |
2 -- Copyright 2013 The Chromium Authors. All rights reserved. | 2 -- Copyright 2013 The Chromium Authors. All rights reserved. |
3 -- Use of this source code is governed by a BSD-style license that can be | 3 -- Use of this source code is governed by a BSD-style license that can be |
4 -- found in the LICENSE file. | 4 -- found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <polymer-element name="kb-key-sequence" attributes="keys hintTexts keyCodes"> | 7 <polymer-element name="kb-key-sequence" |
| 8 attributes="keys hintTexts keyCodes invert"> |
8 <template> | 9 <template> |
9 <style> | 10 <style> |
10 @host { | 11 @host { |
11 * { | 12 * { |
12 display: none; | 13 display: none; |
13 } | 14 } |
14 } | 15 } |
15 </style> | 16 </style> |
16 <kb-key-codes id="keyCodeMetadata"></kb-key-codes> | 17 <kb-key-codes id="keyCodeMetadata"></kb-key-codes> |
17 </template> | 18 </template> |
(...skipping 16 matching lines...) Expand all Loading... |
34 console.error('keys and keyCodes do not match'); | 35 console.error('keys and keyCodes do not match'); |
35 return; | 36 return; |
36 } | 37 } |
37 var replacement = document.createDocumentFragment(); | 38 var replacement = document.createDocumentFragment(); |
38 for (var i = 0; i < newKeys.length; i++) { | 39 for (var i = 0; i < newKeys.length; i++) { |
39 var key = document.createElement('kb-key'); | 40 var key = document.createElement('kb-key'); |
40 key.innerText = newKeys[i]; | 41 key.innerText = newKeys[i]; |
41 key.accents = newKeys[i]; | 42 key.accents = newKeys[i]; |
42 if (newHintTexts) | 43 if (newHintTexts) |
43 key.hintText = newHintTexts[i]; | 44 key.hintText = newHintTexts[i]; |
| 45 var keyCodeIndex = keyCodes[i]; |
| 46 |
| 47 if (this.invert) { |
| 48 key.invert = true; |
| 49 key.char = newKeys[i]; |
| 50 keyCodeIndex = key.hintText; |
| 51 } |
44 var state = this.$.keyCodeMetadata.GetKeyCodeAndModifiers( | 52 var state = this.$.keyCodeMetadata.GetKeyCodeAndModifiers( |
45 keyCodes[i]); | 53 keyCodeIndex); |
46 if (state) { | 54 if (state) { |
47 key.keyCode = state.keyCode; | 55 key.keyCode = state.keyCode; |
48 key.shiftModifier = state.shiftModifier; | 56 key.shiftModifier = state.shiftModifier; |
49 } | 57 } |
50 replacement.appendChild(key); | 58 replacement.appendChild(key); |
51 } | 59 } |
52 result = replacement; | 60 result = replacement; |
53 } | 61 } |
54 return result; | 62 return result; |
55 } | 63 } |
56 }); | 64 }); |
57 </script> | 65 </script> |
58 </polymer-element> | 66 </polymer-element> |
OLD | NEW |