diff options
author | rsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 23:27:24 +0000 |
---|---|---|
committer | rsadam@chromium.org <rsadam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-06 23:27:24 +0000 |
commit | d00c8764450d87025a31769af9b41ca72a0ed981 (patch) | |
tree | 332f0f28e356ee7e652ad10b5ea9e458d1c03a2f | |
parent | fceaf8b0e5f28f14502f7766794a308da46f6f63 (diff) | |
download | chromium_src-d00c8764450d87025a31769af9b41ca72a0ed981.zip chromium_src-d00c8764450d87025a31769af9b41ca72a0ed981.tar.gz chromium_src-d00c8764450d87025a31769af9b41ca72a0ed981.tar.bz2 |
Clean up code in the virtual keyboard.
BUG=
Review URL: https://codereview.chromium.org/148593005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249530 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/keyboard/resources/constants.js | 17 | ||||
-rw-r--r-- | ui/keyboard/resources/elements/kb-keyboard.html | 12 | ||||
-rw-r--r-- | ui/keyboard/resources/main.js | 10 |
3 files changed, 9 insertions, 30 deletions
diff --git a/ui/keyboard/resources/constants.js b/ui/keyboard/resources/constants.js index 0369c9a..6761543 100644 --- a/ui/keyboard/resources/constants.js +++ b/ui/keyboard/resources/constants.js @@ -2,12 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/** - * Aspect ratio of keyboard. - * @type {number} - */ -var ASPECT_RATIO = 3.5; - var RowAlignment = { STRETCH: "stretch", LEFT: "left", @@ -33,20 +27,11 @@ var LayoutAlignment = { } /** - * The number of rows in each keyset. - * @type {number} - */ -// TODO(bshe): The number of rows should equal to the number of kb-row elements -// in kb-keyset. Remove this variable once figure out how to calculate the -// number from keysets. -var ROW_LENGTH = 4; - -/** * The enumeration of swipe directions. * @const * @type {Enum} */ -var SWIPE_DIRECTION = { +var SwipeDirection = { RIGHT: 0x1, LEFT: 0x2, UP: 0x4, diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html index 2143fa2..9fef851 100644 --- a/ui/keyboard/resources/elements/kb-keyboard.html +++ b/ui/keyboard/resources/elements/kb-keyboard.html @@ -212,17 +212,17 @@ // Checks for horizontal swipe. if (Math.abs(this.offset_x) > MIN_SWIPE_DIST_X) { if (this.offset_x > 0) { - direction |= SWIPE_DIRECTION.RIGHT; + direction |= SwipeDirection.RIGHT; } else { - direction |= SWIPE_DIRECTION.LEFT; + direction |= SwipeDirection.LEFT; } } // Checks for vertical swipe. if (Math.abs(this.offset_y) > MIN_SWIPE_DIST_Y) { if (this.offset_y < 0) { - direction |= SWIPE_DIRECTION.UP; + direction |= SwipeDirection.UP; } else { - direction |= SWIPE_DIRECTION.DOWN; + direction |= SwipeDirection.DOWN; } } return direction; @@ -417,7 +417,7 @@ if (!direction) console.error("Swipe direction cannot be: " + direction); // Triggers swipe editting if it's a purely horizontal swipe. - if (!(direction & (SWIPE_DIRECTION.UP | SWIPE_DIRECTION.DOWN))) { + if (!(direction & (SwipeDirection.UP | SwipeDirection.DOWN))) { // Nothing to do if the swipe has ended. if (detail.endSwipe) return; @@ -432,7 +432,7 @@ return; } // Triggers swipe hintText if it's a purely vertical swipe. - if (!(direction & (SWIPE_DIRECTION.LEFT | SWIPE_DIRECTION.RIGHT))) { + if (!(direction & (SwipeDirection.LEFT | SwipeDirection.RIGHT))) { // Check if event is relevant to us. if ((!detail.endSwipe) || (detail.isComplex)) return; diff --git a/ui/keyboard/resources/main.js b/ui/keyboard/resources/main.js index 6014c87..0660f26 100644 --- a/ui/keyboard/resources/main.js +++ b/ui/keyboard/resources/main.js @@ -176,11 +176,7 @@ * Callback function for when the window is resized. */ var onResize = function() { - var bounds = exports.getKeyboardBounds(); - var height = (bounds.width > ASPECT_RATIO * bounds.height) ? - bounds.height : Math.floor(bounds.width / ASPECT_RATIO); var keyboard = $('keyboard'); - keyboard.style.fontSize = (height / FONT_SIZE_RATIO / ROW_LENGTH) + 'px'; keyboard.stale = true; var keyset = keyboard.activeKeyset; if (keyset) @@ -531,10 +527,8 @@ */ function realignKeyset(keyset, params) { var rows = keyset.querySelectorAll('kb-row').array(); - var maxSize = getKeyboardBounds(); - var height = (maxSize.width > ASPECT_RATIO * maxSize.height) ? - maxSize.height : Math.floor(maxSize.width / ASPECT_RATIO); - keyset.style.fontSize = (height / FONT_SIZE_RATIO / rows.length) + 'px'; + keyset.style.fontSize = (params.availableHeight / + FONT_SIZE_RATIO / rows.length) + 'px'; var heightOffset = 0; for (var i = 0; i < rows.length; i++) { |