1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Queries the document for an element with a matching id.
7 * @param {string} id is a case-sensitive string representing the unique ID of
8 * the element being sought.
9 * @return {?Element} The element with that id.
11 var $ = function(id) {
12 return document.getElementById(id);
15 function logIfError() {
16 if (chrome.runtime.lastError) {
17 console.log(chrome.runtime.lastError);
21 function insertText(text) {
22 chrome.virtualKeyboardPrivate.insertText(text, logIfError);
25 function MoveCursor(swipe_direction, swipe_flags) {
26 chrome.virtualKeyboardPrivate.moveCursor(swipe_direction, swipe_flags);
29 function sendKeyEvent(event) {
30 chrome.virtualKeyboardPrivate.sendKeyEvent(event, logIfError);
34 var keyboardLocked_ = false;
37 * Check the lock state of virtual keyboard.
38 * @return {boolean} True if virtual keyboard is locked.
40 function keyboardLocked() {
41 return keyboardLocked_;
45 * Lock or unlock virtual keyboard.
46 * @param {boolean} lock Whether or not to lock the virtual keyboard.
48 function lockKeyboard(lock) {
49 keyboardLocked_ = lock;
50 chrome.virtualKeyboardPrivate.lockKeyboard(lock);
53 scope.keyboardLocked = keyboardLocked;
54 scope.lockKeyboard = lockKeyboard;
57 function hideKeyboard() {
59 chrome.virtualKeyboardPrivate.hideKeyboard(logIfError);
62 function keyboardLoaded() {
63 chrome.virtualKeyboardPrivate.keyboardLoaded(logIfError);
66 function getKeyboardConfig(callback) {
67 chrome.virtualKeyboardPrivate.getKeyboardConfig(function (config) {
72 chrome.virtualKeyboardPrivate.onTextInputBoxFocused.addListener(
73 function (inputContext) {
74 $('keyboard').inputTypeValue = inputContext.type;