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

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/imewindows/accents.js

Issue 701603002: Update to google-input-tools version 1.0.5.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
(Empty)
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 //
14 goog.provide('i18n.input.chrome.inputview.Accents');
15
16 goog.require('goog.dom');
17 goog.require('goog.style');
18
19
20 goog.scope(function() {
21 var Accents = i18n.input.chrome.inputview.Accents;
22
23
24 /**
25 * The highlighted element.
26 *
27 * @type {Element}
28 * @private
29 */
30 Accents.highlightedItem_ = null;
31
32
33 /**
34 * Gets the highlighted character.
35 *
36 * @return {string} The character.
37 * @private
38 */
39 Accents.getHighlightedAccent_ = function() {
40 return Accents.highlightedItem_ ? Accents.highlightedItem_.textContent : '';
41 };
42
43
44 /**
45 * Highlights the item according to the current coordinate of the finger.
46 *
47 * @param {number} x The x position of finger in screen coordinate system.
48 * @param {number} y The y position of finger in screen coordinate system.
49 * @private
50 */
51 Accents.highlightItem_ = function(x, y) {
52 // TODO(bshe): support multiple rows.
53 var dom = goog.dom.getDomHelper();
54 var child = dom.getFirstElementChild(dom.getElement('container'));
55 while (child) {
56 var coordinate = goog.style.getClientPosition(child);
57 var size = goog.style.getSize(child);
58 var screenCoordinate = {};
59 screenCoordinate.x = coordinate.x + window.screenX;
60 screenCoordinate.y = coordinate.y + window.screenY;
61
62 if (screenCoordinate.x < x && (screenCoordinate.x + size.width) > x &&
63 Accents.highlightedItem_ != child) {
64 if (Accents.highlightedItem_) {
65 Accents.highlightedItem_.classList.remove('highlight');
66 }
67 Accents.highlightedItem_ = child;
68 Accents.highlightedItem_.classList.add('highlight');
69 return;
70 }
71 // TODO(bshe): If y is off by 100, cancel the accented char selection.
72 child = dom.getNextElementSibling(child);
73 }
74 };
75
76
77 /**
78 * Sets the accents which this window should display.
79 *
80 * @param {!Array.<string>} accents .
81 * @private
82 */
83 Accents.setAccents_ = function(accents) {
84 var container = document.createElement('div');
85 container.id = 'container';
86 container.classList.add('accent-container');
87 for (var i = 0; i < accents.length; i++) {
88 var keyElem = document.createElement('div');
89 var textDiv = document.createElement('div');
90 textDiv.textContent = accents[i];
91 keyElem.appendChild(textDiv);
92 container.appendChild(keyElem);
93 }
94 document.body.appendChild(container);
95 };
96
97
98 goog.exportSymbol('accents.highlightedAccent', Accents.getHighlightedAccent_);
99 goog.exportSymbol('accents.highlightItem', Accents.highlightItem_);
100 goog.exportSymbol('accents.setAccents', Accents.setAccents_);
101
102 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698