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

Unified Diff: third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 years, 5 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
Index: third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js
diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js
index 04de039b0932908d575e2d84a3f378930e23c283..72b045c6a482acf9c3efba1cd6e2637d68b6ee49 100644
--- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js
+++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/spacekey.js
@@ -14,15 +14,19 @@
goog.provide('i18n.input.chrome.inputview.elements.content.SpaceKey');
goog.require('goog.dom');
+goog.require('goog.dom.TagName');
goog.require('goog.dom.classlist');
+goog.require('goog.style');
goog.require('i18n.input.chrome.inputview.Css');
goog.require('i18n.input.chrome.inputview.StateType');
goog.require('i18n.input.chrome.inputview.elements.ElementType');
-goog.require('i18n.input.chrome.inputview.elements.content.FunctionalKey');
+goog.require('i18n.input.chrome.inputview.elements.content.SoftKey');
goog.scope(function() {
+var Css = i18n.input.chrome.inputview.Css;
+var content = i18n.input.chrome.inputview.elements.content;
@@ -36,13 +40,15 @@ goog.scope(function() {
* @param {!Array.<string>=} opt_characters The characters.
* @param {goog.events.EventTarget=} opt_eventTarget The event target.
* @param {string=} opt_iconCss The icon CSS class
+ * @param {string=} opt_toKeyset The id of the keyset to switch to if spacebar
+ * is pressed after a symbol.
* @constructor
- * @extends {i18n.input.chrome.inputview.elements.content.FunctionalKey}
+ * @extends {i18n.input.chrome.inputview.elements.content.SoftKey}
*/
-i18n.input.chrome.inputview.elements.content.SpaceKey = function(id,
- stateManager, title, opt_characters, opt_eventTarget, opt_iconCss) {
+content.SpaceKey = function(id, stateManager, title, opt_characters,
+ opt_eventTarget, opt_iconCss, opt_toKeyset) {
goog.base(this, id, i18n.input.chrome.inputview.elements.ElementType.
- SPACE_KEY, opt_iconCss ? '' : title, opt_iconCss || '', opt_eventTarget);
+ SPACE_KEY, opt_eventTarget);
/**
* The characters.
@@ -53,6 +59,13 @@ i18n.input.chrome.inputview.elements.content.SpaceKey = function(id,
this.characters_ = opt_characters || [];
/**
+ * The title on the space key.
+ *
+ * @private {string}
+ */
+ this.title_ = title;
+
+ /**
* The state manager.
*
* @type {!i18n.input.chrome.inputview.StateManager}
@@ -60,24 +73,58 @@ i18n.input.chrome.inputview.elements.content.SpaceKey = function(id,
*/
this.stateManager_ = stateManager;
+ /** @private {string} */
+ this.iconCss_ = opt_iconCss || '';
+
+ /**
+ * The id of the keyset to go to (if necessary).
+ * This is used to return to the letter keyset when pressing space
+ * after a symbol.
+ *
+ * @type {string}
+ */
+ this.toKeyset = opt_toKeyset || '';
+
// Double click on space key may convert two spaces to a period followed by a
// space.
this.pointerConfig.dblClick = true;
this.pointerConfig.dblClickDelay = 1000;
};
-goog.inherits(i18n.input.chrome.inputview.elements.content.SpaceKey,
- i18n.input.chrome.inputview.elements.content.FunctionalKey);
-var SpaceKey = i18n.input.chrome.inputview.elements.content.SpaceKey;
+goog.inherits(content.SpaceKey, i18n.input.chrome.inputview.elements.
+ content.SoftKey);
+var SpaceKey = content.SpaceKey;
+
+
+/**
+ * The height of the space key.
+ *
+ * @type {number}
+ */
+SpaceKey.HEIGHT = 43;
+
+
+/**
+ * The wrapper inside the space key.
+ *
+ * @private {!Element}
+ */
+SpaceKey.prototype.wrapper_;
/** @override */
SpaceKey.prototype.createDom = function() {
goog.base(this, 'createDom');
- goog.dom.classlist.remove(this.bgElem,
- i18n.input.chrome.inputview.Css.SPECIAL_KEY_BG);
-
- this.setAriaLabel(this.getChromeVoxMessage());
+ var dom = this.getDomHelper();
+ this.wrapper_ = dom.createDom(goog.dom.TagName.DIV, Css.SPACE_WRAPPER);
+ dom.appendChild(this.getElement(), this.wrapper_);
+ if (this.iconCss_) {
+ var iconElem = dom.createDom(goog.dom.TagName.DIV, this.iconCss_);
+ dom.appendChild(this.wrapper_, iconElem);
+ } else {
+ goog.dom.classlist.add(this.wrapper_, Css.SPACE_GREY_BG);
+ goog.dom.setTextContent(this.wrapper_, this.title_);
+ }
};
@@ -111,18 +158,45 @@ SpaceKey.prototype.getCharacter = function() {
* @param {boolean} visible True to set title visible.
*/
SpaceKey.prototype.updateTitle = function(title, visible) {
- if (this.textElem) {
- this.text = title;
- goog.dom.setTextContent(this.textElem, visible ? title : '');
- goog.dom.classlist.add(this.textElem,
- i18n.input.chrome.inputview.Css.TITLE);
+ if (this.iconCss_) {
+ return;
}
+ this.text = title;
+ goog.dom.setTextContent(this.wrapper_, visible ? title : '');
+ goog.dom.classlist.add(this.wrapper_,
+ i18n.input.chrome.inputview.Css.TITLE);
};
/** @override */
+SpaceKey.prototype.setHighlighted = function(highlight) {
+ if (highlight) {
+ goog.dom.classlist.add(this.wrapper_, i18n.input.chrome.inputview.Css.
+ ELEMENT_HIGHLIGHT);
+ } else {
+ goog.dom.classlist.remove(this.wrapper_, i18n.input.chrome.inputview.Css.
+ ELEMENT_HIGHLIGHT);
+ }
+};
+
+
+/**
+ * Gets the message for chromevox.
+ *
+ * @return {string} .
+ */
SpaceKey.prototype.getChromeVoxMessage = function() {
return chrome.i18n.getMessage('SPACE');
};
+
+/** @override */
+SpaceKey.prototype.resize = function(width, height) {
+ goog.base(this, 'resize', width, height);
+
+ goog.style.setSize(this.wrapper_, width, SpaceKey.HEIGHT);
+ // Positions the wrapper in the middle.
+ this.wrapper_.style.top = (this.availableHeight - SpaceKey.HEIGHT) / 2 + 'px';
+};
+
}); // goog.scope

Powered by Google App Engine
This is Rietveld 408576698