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
8 // http://www.apache.org/licenses/LICENSE-2.0
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");
14 goog.provide('i18n.input.chrome.inputview.elements.content.SpaceKey');
16 goog.require('goog.dom');
17 goog.require('goog.dom.classlist');
18 goog.require('i18n.input.chrome.inputview.Css');
19 goog.require('i18n.input.chrome.inputview.StateType');
20 goog.require('i18n.input.chrome.inputview.elements.ElementType');
21 goog.require('i18n.input.chrome.inputview.elements.content.FunctionalKey');
25 goog.scope(function() {
32 * @param {string} id the id.
33 * @param {!i18n.input.chrome.inputview.StateManager} stateManager The state
35 * @param {string} title The keyboard title.
36 * @param {!Array.<string>=} opt_characters The characters.
37 * @param {goog.events.EventTarget=} opt_eventTarget The event target.
38 * @param {string=} opt_iconCss The icon CSS class
40 * @extends {i18n.input.chrome.inputview.elements.content.FunctionalKey}
42 i18n.input.chrome.inputview.elements.content.SpaceKey = function(id,
43 stateManager, title, opt_characters, opt_eventTarget, opt_iconCss) {
44 goog.base(this, id, i18n.input.chrome.inputview.elements.ElementType.
45 SPACE_KEY, opt_iconCss ? '' : title, opt_iconCss || '', opt_eventTarget);
50 * @type {!Array.<string>}
53 this.characters_ = opt_characters || [];
58 * @type {!i18n.input.chrome.inputview.StateManager}
61 this.stateManager_ = stateManager;
63 // Double click on space key may convert two spaces to a period followed by a
65 this.pointerConfig.dblClick = true;
66 this.pointerConfig.dblClickDelay = 1000;
68 goog.inherits(i18n.input.chrome.inputview.elements.content.SpaceKey,
69 i18n.input.chrome.inputview.elements.content.FunctionalKey);
70 var SpaceKey = i18n.input.chrome.inputview.elements.content.SpaceKey;
74 SpaceKey.prototype.createDom = function() {
75 goog.base(this, 'createDom');
77 goog.dom.classlist.remove(this.bgElem,
78 i18n.input.chrome.inputview.Css.SPECIAL_KEY_BG);
85 * @return {string} The character.
87 SpaceKey.prototype.getCharacter = function() {
88 if (this.characters_) {
89 // The index is based on the characters in order:
94 var index = this.stateManager_.hasState(i18n.input.chrome.inputview.
95 StateType.SHIFT) ? 1 : 0 + this.stateManager_.hasState(
96 i18n.input.chrome.inputview.StateType.ALTGR) ? 2 : 0;
97 if (this.characters_.length > index && this.characters_[index]) {
98 return this.characters_[index];
106 * Updates the title on the space key.
108 * @param {string} title .
109 * @param {boolean} visible True to set title visible.
111 SpaceKey.prototype.updateTitle = function(title, visible) {
114 goog.dom.setTextContent(this.textElem, visible ? title : '');
115 goog.dom.classlist.add(this.textElem,
116 i18n.input.chrome.inputview.Css.TITLE);