| 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-keyboard" on-key-over="keyOver" on-key-up="keyUp" | 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" |
| 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" | 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" |
| 9 on-pointerdown="down" on-enable-sel="enableSel" | 9 on-pointerdown="down" on-enable-sel="enableSel" |
| 10 on-enable-dbl="enableDbl" on-key-out="keyOut" | 10 on-enable-dbl="enableDbl" on-key-out="keyOut" on-show-options="showOptions" |
| 11 attributes="keyset layout rows inputType inputTypeToLayoutMap"> | 11 attributes="keyset layout rows inputType inputTypeToLayoutMap"> |
| 12 <template> | 12 <template> |
| 13 <style> | 13 <style> |
| 14 @host { | 14 @host { |
| 15 * { | 15 * { |
| 16 position: relative; | 16 position: relative; |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 </style> | 19 </style> |
| 20 <!-- The ID for a keyset follows the naming convention of combining the | 20 <!-- The ID for a keyset follows the naming convention of combining the |
| 21 -- layout name with a base keyset name. This convention is used to | 21 -- layout name with a base keyset name. This convention is used to |
| 22 -- allow multiple layouts to be loaded (enablign fast switching) while | 22 -- allow multiple layouts to be loaded (enablign fast switching) while |
| 23 -- allowing the shift and spacebar keys to be common across multiple | 23 -- allowing the shift and spacebar keys to be common across multiple |
| 24 -- keyboard layouts. | 24 -- keyboard layouts. |
| 25 --> | 25 --> |
| 26 <content select="#{{layout}}-{{keyset}}"></content> | 26 <content select="#{{layout}}-{{keyset}}"></content> |
| 27 <kb-keyboard-overlay id="overlay" hidden></kb-keyboard-overlay> |
| 27 <kb-key-codes id="keyCodeMetadata"></kb-key-codes> | 28 <kb-key-codes id="keyCodeMetadata"></kb-key-codes> |
| 28 </template> | 29 </template> |
| 29 <script> | 30 <script> |
| 30 /** | 31 /** |
| 31 * The repeat delay in milliseconds before a key starts repeating. Use the | 32 * The repeat delay in milliseconds before a key starts repeating. Use the |
| 32 * same rate as Chromebook. | 33 * same rate as Chromebook. |
| 33 * (See chrome/browser/chromeos/language_preferences.cc) | 34 * (See chrome/browser/chromeos/language_preferences.cc) |
| 34 * @const | 35 * @const |
| 35 * @type {number} | 36 * @type {number} |
| 36 */ | 37 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 voiceInput_: null, | 209 voiceInput_: null, |
| 209 | 210 |
| 210 /** | 211 /** |
| 211 * The default input type to keyboard layout map. The key must be one of | 212 * The default input type to keyboard layout map. The key must be one of |
| 212 * the input box type values. | 213 * the input box type values. |
| 213 * @type {object} | 214 * @type {object} |
| 214 */ | 215 */ |
| 215 inputTypeToLayoutMap: { | 216 inputTypeToLayoutMap: { |
| 216 number: "numeric", | 217 number: "numeric", |
| 217 text: "qwerty", | 218 text: "qwerty", |
| 218 password: "system-qwerty" | 219 password: "qwerty" |
| 219 }, | 220 }, |
| 220 | 221 |
| 221 /** | 222 /** |
| 222 * Changes the current keyset. | 223 * Changes the current keyset. |
| 223 * @param {Object} detail The detail of the event that called this | 224 * @param {Object} detail The detail of the event that called this |
| 224 * function. | 225 * function. |
| 225 */ | 226 */ |
| 226 changeKeyset: function(detail) { | 227 changeKeyset: function(detail) { |
| 227 if (detail.relegateToShift && this.shift) { | 228 if (detail.relegateToShift && this.shift) { |
| 228 this.keyset = this.shift.textKeyset; | 229 this.keyset = this.shift.textKeyset; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // Locks the keyset before removing active to prevent flicker. | 567 // Locks the keyset before removing active to prevent flicker. |
| 567 this.classList.add('caps-locked'); | 568 this.classList.add('caps-locked'); |
| 568 // Makes last pressed key inactive if transit to a new keyset on long | 569 // Makes last pressed key inactive if transit to a new keyset on long |
| 569 // press. | 570 // press. |
| 570 if (this.lastPressedKey) | 571 if (this.lastPressedKey) |
| 571 this.lastPressedKey.classList.remove('active'); | 572 this.lastPressedKey.classList.remove('active'); |
| 572 } | 573 } |
| 573 }, | 574 }, |
| 574 | 575 |
| 575 /** | 576 /** |
| 577 * Show menu for selecting a keyboard layout. |
| 578 * @param {!Event} event The triggering event. |
| 579 * @param {{left: number, top: number, width: number}} details Location of |
| 580 * the button that triggered the popup. |
| 581 */ |
| 582 showOptions: function(event, details) { |
| 583 var overlay = this.$.overlay; |
| 584 if (!overlay) { |
| 585 console.error('Missing overlay.'); |
| 586 return; |
| 587 } |
| 588 var menu = overlay.$.options; |
| 589 if (!menu) { |
| 590 console.error('Missing options menu.'); |
| 591 } |
| 592 |
| 593 menu.hidden = false; |
| 594 overlay.hidden = false; |
| 595 var left = details.left + details.width - menu.clientWidth; |
| 596 var top = details.top - menu.clientHeight; |
| 597 menu.style.left = left + 'px'; |
| 598 menu.style.top = top + 'px'; |
| 599 }, |
| 600 |
| 601 /** |
| 576 * Handles a change in the keyboard layout. Auto-selects the default | 602 * Handles a change in the keyboard layout. Auto-selects the default |
| 577 * keyset for the new layout. | 603 * keyset for the new layout. |
| 578 */ | 604 */ |
| 579 layoutChanged: function() { | 605 layoutChanged: function() { |
| 580 if (!this.selectDefaultKeyset()) { | 606 if (!this.selectDefaultKeyset()) { |
| 581 this.isReady = false; | 607 this.isReady = false; |
| 582 this.fire('stateChange', {state: 'loadingKeyset'}); | 608 this.fire('stateChange', {state: 'loadingKeyset'}); |
| 583 | 609 |
| 584 // Keyset selection fails if the keysets have not been loaded yet. | 610 // Keyset selection fails if the keysets have not been loaded yet. |
| 585 var keysets = document.querySelector('#' + this.layout); | 611 var keysets = document.querySelector('#' + this.layout); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 } | 740 } |
| 715 } | 741 } |
| 716 } | 742 } |
| 717 if (keysetsLoaded) | 743 if (keysetsLoaded) |
| 718 console.error('No default keyset found for ' + this.layout); | 744 console.error('No default keyset found for ' + this.layout); |
| 719 return false; | 745 return false; |
| 720 } | 746 } |
| 721 }); | 747 }); |
| 722 </script> | 748 </script> |
| 723 </polymer-element> | 749 </polymer-element> |
| OLD | NEW |