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" extends="kb-key-base" | 7 <polymer-element name="kb-key" extends="kb-key-base" |
8 attributes="keyCode shiftModifier weight"> | 8 attributes="keyCode shiftModifier weight"> |
9 <template> | 9 <template> |
10 <style> | 10 <style> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 }, | 53 }, |
54 }); | 54 }); |
55 </script> | 55 </script> |
56 </polymer-element> | 56 </polymer-element> |
57 | 57 |
58 <!-- Special keys --> | 58 <!-- Special keys --> |
59 | 59 |
60 <polymer-element name="kb-shift-key" attributes="unlockedCase lockedCase" | 60 <polymer-element name="kb-shift-key" attributes="unlockedCase lockedCase" |
61 class="shift dark" char="Shift" extends="kb-key"> | 61 class="shift dark" char="Shift" extends="kb-key"> |
62 <script> | 62 <script> |
63 Polymer('kb-shift-key', { | |
64 /** | |
65 * Defines how capslock effects keyset transition. We always transition | |
66 * from the unlockedCase to the lockedCase if capslock is on. | |
67 * @type {string} | |
68 */ | |
69 unlockedCase: 'lower', | |
70 lockedCase: 'upper', | |
71 | 63 |
72 down: function(event) { | 64 (function () { |
73 this.super(); | 65 /** |
74 var detail = {}; | 66 * Uses a closure to define one long press timer among all shift keys |
75 if (this.keysetRules && this.keysetRules.dbl != undefined) { | 67 * regardless of the layout they are in. |
76 detail.char = this.char || this.textContent; | 68 * @type {function} |
77 detail.toKeyset = this.keysetRules.dbl[TO_KEYSET - OFFSET]; | 69 */ |
78 detail.nextKeyset = this.keysetRules.dbl[NEXT_KEYSET - OFFSET]; | 70 var shiftLongPressTimer = undefined; |
79 } | 71 |
80 this.fire('enable-dbl', detail); | 72 Polymer('kb-shift-key', { |
81 this.fire('enable-sel'); | 73 /** |
82 }, | 74 * Defines how capslock effects keyset transition. We always transition |
83 }); | 75 * from the unlockedCase to the lockedCase if capslock is on. |
| 76 * @type {string} |
| 77 */ |
| 78 unlockedCase: 'lower', |
| 79 lockedCase: 'upper', |
| 80 control: true, |
| 81 |
| 82 down: function(event) { |
| 83 this.super(); |
| 84 var detail = {}; |
| 85 if (this.keysetRules && this.keysetRules.dbl != undefined) { |
| 86 detail.char = this.char || this.textContent; |
| 87 detail.toKeyset = this.keysetRules.dbl[TO_KEYSET - OFFSET]; |
| 88 detail.nextKeyset = this.keysetRules.dbl[NEXT_KEYSET - OFFSET]; |
| 89 } |
| 90 this.fire('enable-dbl', detail); |
| 91 this.fire('enable-sel'); |
| 92 }, |
| 93 |
| 94 /** |
| 95 * Overrides longPressTimer for the shift key. |
| 96 */ |
| 97 get longPressTimer() { |
| 98 return shiftLongPressTimer; |
| 99 }, |
| 100 |
| 101 set longPressTimer(timer) { |
| 102 shiftLongPressTimer = timer; |
| 103 }, |
| 104 }); |
| 105 })(); |
| 106 |
84 </script> | 107 </script> |
85 </polymer-element> | 108 </polymer-element> |
86 | 109 |
87 <!-- | 110 <!-- |
88 -- TODO(kevers): Display popup menu for selecting layout on keypress. Display | 111 -- TODO(kevers): Display popup menu for selecting layout on keypress. Display |
89 -- code for keyboard layout in place of image. | 112 -- code for keyboard layout in place of image. |
90 --> | 113 --> |
91 <polymer-element name="kb-layout-selector" class="layout-selector dark" char="In
valid" | 114 <polymer-element name="kb-layout-selector" class="layout-selector dark" char="In
valid" |
92 extends="kb-key"> | 115 extends="kb-key"> |
93 <script> | 116 <script> |
94 Polymer('kb-layout-selector', { | 117 Polymer('kb-layout-selector', { |
95 toLayout: 'qwerty' | 118 toLayout: 'qwerty' |
96 }); | 119 }); |
97 </script> | 120 </script> |
98 </polymer-element> | 121 </polymer-element> |
OLD | NEW |