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

Side by Side Diff: ui/keyboard/resources/elements/kb-keyboard.html

Issue 43593003: Add layout switcher for virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix keyboard tests. Created 7 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 | Annotate | Revision Log
OLDNEW
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 on-set-layout="setLayout"
11 attributes="keyset layout inputType inputTypeToLayoutMap"> 12 attributes="keyset layout inputType inputTypeToLayoutMap">
12 <template> 13 <template>
13 <style> 14 <style>
14 @host { 15 @host {
15 * { 16 * {
16 position: relative; 17 position: relative;
17 } 18 }
18 } 19 }
19 </style> 20 </style>
20 <!-- The ID for a keyset follows the naming convention of combining the 21 <!-- 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 22 -- layout name with a base keyset name. This convention is used to
22 -- allow multiple layouts to be loaded (enablign fast switching) while 23 -- allow multiple layouts to be loaded (enablign fast switching) while
23 -- allowing the shift and spacebar keys to be common across multiple 24 -- allowing the shift and spacebar keys to be common across multiple
24 -- keyboard layouts. 25 -- keyboard layouts.
25 --> 26 -->
26 <content select="#{{layout}}-{{keyset}}"></content> 27 <content select="#{{layout}}-{{keyset}}"></content>
28 <kb-keyboard-overlay id="overlay" hidden></kb-keyboard-overlay>
27 <kb-key-codes id="keyCodeMetadata"></kb-key-codes> 29 <kb-key-codes id="keyCodeMetadata"></kb-key-codes>
28 </template> 30 </template>
29 <script> 31 <script>
30 /** 32 /**
31 * The repeat delay in milliseconds before a key starts repeating. Use the 33 * The repeat delay in milliseconds before a key starts repeating. Use the
32 * same rate as Chromebook. 34 * same rate as Chromebook.
33 * (See chrome/browser/chromeos/language_preferences.cc) 35 * (See chrome/browser/chromeos/language_preferences.cc)
34 * @const 36 * @const
35 * @type {number} 37 * @type {number}
36 */ 38 */
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 voiceInput_: null, 210 voiceInput_: null,
209 211
210 /** 212 /**
211 * The default input type to keyboard layout map. The key must be one of 213 * The default input type to keyboard layout map. The key must be one of
212 * the input box type values. 214 * the input box type values.
213 * @type {object} 215 * @type {object}
214 */ 216 */
215 inputTypeToLayoutMap: { 217 inputTypeToLayoutMap: {
216 number: "numeric", 218 number: "numeric",
217 text: "qwerty", 219 text: "qwerty",
218 password: "system-qwerty" 220 password: "qwerty"
219 }, 221 },
220 222
221 /** 223 /**
222 * Changes the current keyset. 224 * Changes the current keyset.
223 * @param {Object} detail The detail of the event that called this 225 * @param {Object} detail The detail of the event that called this
224 * function. 226 * function.
225 */ 227 */
226 changeKeyset: function(detail) { 228 changeKeyset: function(detail) {
227 if (detail.relegateToShift && this.shift) { 229 if (detail.relegateToShift && this.shift) {
228 this.keyset = this.shift.textKeyset; 230 this.keyset = this.shift.textKeyset;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // Locks the keyset before removing active to prevent flicker. 566 // Locks the keyset before removing active to prevent flicker.
565 this.classList.add('caps-locked'); 567 this.classList.add('caps-locked');
566 // Makes last pressed key inactive if transit to a new keyset on long 568 // Makes last pressed key inactive if transit to a new keyset on long
567 // press. 569 // press.
568 if (this.lastPressedKey) 570 if (this.lastPressedKey)
569 this.lastPressedKey.classList.remove('active'); 571 this.lastPressedKey.classList.remove('active');
570 } 572 }
571 }, 573 },
572 574
573 /** 575 /**
576 * Show menu for selecting a keyboard layout.
577 * @param {!Event} event The triggering event.
578 * @param {{left: number, top: number, width: number}} details Location of
579 * the button that triggered the popup.
580 */
581 showOptions: function(event, details) {
582 var overlay = this.$.overlay;
583 if (!overlay) {
584 console.error('Missing overlay.');
585 return;
586 }
587 var menu = overlay.$.options;
588 if (!menu) {
589 console.error('Missing options menu.');
590 }
591
592 menu.hidden = false;
593 overlay.hidden = false;
594 var left = details.left + details.width - menu.clientWidth;
595 var top = details.top - menu.clientHeight;
596 menu.style.left = left + 'px';
597 menu.style.top = top + 'px';
598 },
599
600 /**
601 * Handler for the 'set-layout' event.
602 * @param {!Event} event The triggering event.
603 * @param {{layout: string}} details Details of the event, which contains
604 * the name of the layout to activate.
605 */
606 setLayout: function(event, details) {
607 this.layout = details.layout;
608 },
609
610 /**
574 * Handles a change in the keyboard layout. Auto-selects the default 611 * Handles a change in the keyboard layout. Auto-selects the default
575 * keyset for the new layout. 612 * keyset for the new layout.
576 */ 613 */
577 layoutChanged: function() { 614 layoutChanged: function() {
578 if (!this.selectDefaultKeyset()) { 615 if (!this.selectDefaultKeyset()) {
579 this.isReady = false; 616 this.isReady = false;
580 this.fire('stateChange', {state: 'loadingKeyset'}); 617 this.fire('stateChange', {state: 'loadingKeyset'});
581 618
582 // Keyset selection fails if the keysets have not been loaded yet. 619 // Keyset selection fails if the keysets have not been loaded yet.
583 var keysets = document.querySelector('#' + this.layout); 620 var keysets = document.querySelector('#' + this.layout);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 768 }
732 } 769 }
733 } 770 }
734 if (keysetsLoaded) 771 if (keysetsLoaded)
735 console.error('No default keyset found for ' + this.layout); 772 console.error('No default keyset found for ' + this.layout);
736 return false; 773 return false;
737 } 774 }
738 }); 775 });
739 </script> 776 </script>
740 </polymer-element> 777 </polymer-element>
OLDNEW
« no previous file with comments | « ui/keyboard/resources/elements/kb-key.html ('k') | ui/keyboard/resources/elements/kb-options-menu.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698