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

Unified Diff: chrome/browser/resources/keyboard/main.js

Issue 7754019: Enable the keyboard to show the popup keyboard for inputting accented characters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/keyboard/main.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/keyboard/main.js
diff --git a/chrome/browser/resources/keyboard/main.js b/chrome/browser/resources/keyboard/main.js
index 729df6c31e85411e4af92a3b260622ffabbd4a23..109df3f8cf375bdf1e3efa3806b027ab34bf5ce2 100644
--- a/chrome/browser/resources/keyboard/main.js
+++ b/chrome/browser/resources/keyboard/main.js
@@ -7,12 +7,6 @@
*/
/**
- * The keyboard layout name currently in use.
- * @type {string}
- */
-var currentKeyboardLayout = 'us';
-
-/**
* The ratio of the row height to the font size.
* @type {number}
*/
@@ -48,25 +42,15 @@ function getKeyboardHeight() {
}
/**
- * Set the keyboard mode.
- * @param {string} mode The new mode.
- * @return {void}
- */
-function setMode(mode) {
- var rows = KEYBOARDS[currentKeyboardLayout]['rows'];
- for (var i = 0; i < rows.length; ++i) {
- rows[i].showMode(mode);
- }
-}
-
-/**
* Create a DOM of the keyboard rows for the given keyboard layout.
* Do nothing if the DOM is already created.
* @param {string} layout The keyboard layout for which rows are created.
- * @param {Element} The DOM Element to which rows are appended.
+ * @param {Element} element The DOM Element to which rows are appended.
+ * @param {boolean} autoPadding True if padding needs to be added to both side
+ * of the rows that have less keys.
* @return {void}
*/
-function initRows(layout, element) {
+function initRows(layout, element, autoPadding) {
var keyboard = KEYBOARDS[layout];
if ('rows' in keyboard) {
return;
@@ -78,11 +62,24 @@ function initRows(layout, element) {
}
keyboard['rows'] = rows;
+ var maxRowLength = -1;
+ for (var i = 0; i < rows.length; ++i) {
+ if (rows[i].length > maxRowLength) {
+ maxRowLength = rows[i].length;
+ }
+ }
+
// A div element which holds rows for the layout.
var rowsDiv = document.createElement('div');
rowsDiv.className = 'rows';
for (var i = 0; i < rows.length; ++i) {
- rowsDiv.appendChild(rows[i].makeDOM());
+ var rowDiv = rows[i].makeDOM();
+ if (autoPadding && rows[i].length < maxRowLength) {
+ var padding = 50 * (maxRowLength - rows[i].length) / maxRowLength;
+ rowDiv.style.paddingLeft = padding + '%';
+ rowDiv.style.paddingRight = padding + '%';
+ }
+ rowsDiv.appendChild(rowDiv);
rows[i].showMode(currentMode);
}
keyboard['rowsDiv'] = rowsDiv;
@@ -134,6 +131,22 @@ function initKeyboard(layout, element) {
}
/**
+ * Create a DOM of the popup keyboard.
+ * @param {Element} The DOM Element to which the popup keyboard is appended.
+ * @return {void}
+ */
+function initPopupKeyboard(element) {
+ var popupDiv = document.createElement('div');
+ popupDiv.id = 'popup';
+ popupDiv.className = 'keyboard popup';
+ popupDiv.style.visibility = 'hidden';
+ element.appendChild(popupDiv);
+ element.addEventListener('mouseup', function(evt) {
+ hidePopupKeyboard(evt);
+ });
+}
+
+/**
* Resize the keyboard according to the new window size.
* @return {void}
*/
@@ -171,6 +184,7 @@ window.onload = function() {
initIme(mainDiv);
initKeyboard(currentKeyboardLayout, mainDiv);
+ initPopupKeyboard(body);
window.onhashchange();
« no previous file with comments | « chrome/browser/resources/keyboard/main.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698