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");
16 * @fileoverview Defines the class i18n.input.hwt.util.
17 * @author fengyuan@google.com (Feng Yuan)
20 goog.provide('i18n.input.hwt.util');
23 goog.require('goog.array');
24 goog.require('goog.events.EventType');
25 goog.require('i18n.input.common.dom');
29 * Listens MOUSEUP on page scope.
31 * @param {goog.events.EventHandler} eventHandler The event handler.
32 * @param {Document} topDocument The top document.
33 * @param {goog.events.EventType | !Array.<goog.events.EventType>} eventType
34 * The event type to listen.
35 * @param {Function} callback The callback method.
37 i18n.input.hwt.util.listenPageEvent = function(eventHandler, topDocument,
38 eventType, callback) {
39 // Ideally we'd just listen for MOUSEUP on the canvas, but that
40 // doesn't work if the mouseup event happens outside the canvas,
41 // and in particular if it happens in an iframe. So we have to
42 // listen on the document and any embedded iframes. We'll also
43 // use this handler to cancel auto-repeat when holding down
44 // the backspace button, in case the user releases the button
46 eventHandler.listen(topDocument, goog.events.EventType.MOUSEUP,
48 goog.array.forEach(i18n.input.common.dom.getSameDomainDocuments(topDocument),
51 // In IE and FF3.5, some iframe is not allowed to access.
52 // It throws exception when access the iframe property.
53 eventHandler.listen(frameDoc, goog.events.EventType.MOUSEUP,
61 * The default candidate map of handwriting pad.
63 * Value: candidate list.
65 * @type {!Object.<string, !Array.<string>>}
67 i18n.input.hwt.util.DEFAULT_CANDIDATE_MAP = {
68 '': [',', '.', '?', '!', ':', '\'', '"', ';', '@'],
69 'es': [',', '.', '¿', '?', '¡', '!', ':', '\'', '"'],
70 'ja': [',', '。', '?', '!', ':', '「', '」', ';'],
71 'zh-Hans': [',', '。', '?', '!', ':', '“', '”', ';'],
72 'zh-Hant': [',', '。', '?', '!', ':', '「', '」', ';']