Commit 58786c2a authored by rsadam@chromium.org's avatar rsadam@chromium.org

Added persistent capitalization to the Virtual Keyboard.

BUG=280147

Review URL: https://chromiumcodereview.appspot.com/23534021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220628 0039d316-1c4b-4281-b951-d872f2087c98
parent 04123796
......@@ -49,6 +49,20 @@
*/
var DBL_INTERVAL_MSEC = 300;
/**
* The index of the name of the keyset when searching for all keysets.
* @const
* @type {number}
*/
var REGEX_KEYSET_INDEX = 1;
/**
* The integer number of matches when searching for keysets.
* @const
* @type {number}
*/
var REGEX_MATCH_COUNT = 2;
/**
* The boolean to decide if keyboard should transit to upper case keyset
* when spacebar is pressed. If a closing punctuation is followed by a
......@@ -186,9 +200,10 @@
var keysetId = '#' + this.layout + '-' + this.keyset;
var keyset = this.querySelector(keysetId);
// Unlocks the keyboard if the current keyset is not lockable.
if (!keyset.getAttribute('lockable'))
this.classList.remove('locked');
// If capslock is enabled and capsLockTo is not null,
// redirect to keyset specified by capsLockTo.
if (this.classList.contains('caps-locked') && keyset.capsLocksTo)
this.keyset = keyset.capsLocksTo;
},
......@@ -348,9 +363,7 @@
keyset.nextKeyset = this.dblTimer_.nextKeyset;
clearTimeout(this.dblTimer_);
// Checks if shift is capitalized.
if (keyset.getAttribute('lockable'))
this.classList.add('locked');
this.classList.add('caps-locked');
this.dblDetail_ = null;
}
......@@ -385,17 +398,17 @@
repeatKey.cancel();
return;
}
var toKeyset = detail.toKeyset;
var toKeysetId = detail.toKeyset;
// Keyset transition key.
if (toKeyset) {
this.keyset = toKeyset;
if (toKeysetId) {
this.keyset = toKeysetId;
this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset =
detail.nextKeyset;
}
var toLayout = detail.toLayout;
var toLayoutId = detail.toLayout;
// Layout transition key.
if (toLayout)
this.layout = toLayout;
if (toLayoutId)
this.layout = toLayoutId;
var char = detail.char;
if (enterUpperOnSpace) {
enterUpperOnSpace = false;
......@@ -404,8 +417,13 @@
}
switch(char) {
case 'Invalid':
swipeStatus.swipeFlags = 0;
return;
case 'Shift':
swipeStatus.swipeFlags = 0;
// We have reverted to lower case.
if(this.classList.contains('caps-locked'))
this.classList.remove('caps-locked');
return;
case 'Microphone':
this.voiceInput_.onDown();
......@@ -438,7 +456,7 @@
detail.nextKeyset;
// Locks the keyset before removing active to prevent flicker.
this.classList.add('locked');
this.classList.add('caps-locked');
// Makes last pressed key inactive if transit to a new keyset on long
// press.
this.lastPressedKey.classList.remove('active');
......@@ -474,10 +492,10 @@
var keysetsLoaded = false;
for (var i = 0; i < keysets.length; i++) {
var matches = keysets[i].id.match(regex);
if (matches && matches.length == 2) {
if (matches && matches.length == REGEX_MATCH_COUNT) {
keysetsLoaded = true;
if (keysets[i].isDefault) {
this.keyset = matches[1];
this.keyset = matches[REGEX_KEYSET_INDEX];
return true;
}
}
......
......@@ -4,8 +4,9 @@
-- found in the LICENSE file.
-->
<polymer-element name="kb-keyset" attributes="nextKeyset isDefault"
on-key-up="keyUp" on-key-longpress="keyLongpress">
<polymer-element name="kb-keyset" attributes="nextKeyset isDefault
capsLocksTo capsLockable" on-key-up="keyUp"
on-key-longpress="keyLongpress">
<template>
<style>
@host {
......
......@@ -9,7 +9,7 @@
<link id="spacebar-row" rel="import" href="spacebar-row.html">
<template>
<kb-keyset id="dvorak-upper" lockable="true">
<kb-keyset id="dvorak-upper" capsLockable=true>
<kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="&quot;,.PYFGCRL" superscripts="1234567890"></kb-key-sequence>
......@@ -35,7 +35,7 @@
</kb-altkey-container>
</kb-keyset>
<kb-keyset id="dvorak-lower" isDefault=true>
<kb-keyset id="dvorak-lower" capsLocksTo="upper" isDefault=true>
<kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="&quot;,.pyfgcrl" superscripts="1234567890"></kb-key-sequence>
......
......@@ -9,7 +9,7 @@
<link id="spacebar-row" rel="import" href="spacebar-row.html">
<template>
<kb-keyset id="qwerty-upper" lockable="true">
<kb-keyset id="qwerty-upper" capsLockable=true>
<kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="QWERTYUIOP" superscripts="1234567890"></kb-key-sequence>
......@@ -37,7 +37,7 @@
</kb-altkey-container>
</kb-keyset>
<kb-keyset id="qwerty-lower" isDefault=true>
<kb-keyset id="qwerty-lower" capsLocksTo="upper" isDefault=true>
<kb-row>
<kb-key class="tab dark" char="&#x0009;" align="left">tab</kb-key>
<kb-key-sequence keys="qwertyuiop" superscripts="1234567890"></kb-key-sequence>
......
......@@ -5,7 +5,7 @@
-->
<template>
<kb-keyset id="qwerty-upper" lockable="true">
<kb-keyset id="qwerty-upper" capsLockable=true>
<kb-row class="top">
<kb-key>Q</kb-key><kb-key>W</kb-key><kb-key>E</kb-key><kb-key>R</kb-key>
<kb-key>T</kb-key><kb-key>Y</kb-key><kb-key>U</kb-key>
......@@ -36,7 +36,7 @@
</kb-altkey-container>
</kb-keyset>
<kb-keyset id="qwerty-lower" isDefault=true>
<kb-keyset id="qwerty-lower" capsLocksTo="upper" isDefault=true>
<kb-row class="top">
<kb-key>q</kb-key><kb-key>w</kb-key><kb-key>e</kb-key><kb-key>r</kb-key>
<kb-key>t</kb-key><kb-key>y</kb-key><kb-key>u</kb-key>
......
......@@ -72,7 +72,7 @@ kb-key::x-superscript[inverted] {
* Controls whether the shift key should be highlighted or not.
* Only highlights if we are in a lockable keyboard which is not locked.
*/
kb-keyboard:not(.locked) kb-keyset[lockable] kb-shift-key {
kb-keyboard:not(.caps-locked) kb-keyset[capsLockable] kb-shift-key {
color: lightblue;
}
......@@ -95,7 +95,7 @@ kb-altkey::x-key {
text-align: center;
}
.locked kb-shift-key,
.caps-locked kb-shift-key,
.active {
background-color: #848490 !important;
border-top: 2px solid #A9A9AF !important;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment