| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ea9d8a2135eedaf29da4ffa3aa6711af0c28c430
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js
|
| @@ -0,0 +1,121 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview ChromeVox panel.
|
| + *
|
| + */
|
| +
|
| +goog.provide('cvox.Panel');
|
| +
|
| +goog.require('cvox.ChromeVox');
|
| +goog.require('cvox.ExtensionBridge');
|
| +goog.require('cvox.Msgs');
|
| +goog.require('cvox.PanelCommand');
|
| +
|
| +/**
|
| + * Class to manage the options page.
|
| + * @constructor
|
| + */
|
| +cvox.Panel = function() {
|
| +};
|
| +
|
| +/**
|
| + * Initialize the panel.
|
| + */
|
| +cvox.Panel.init = function() {
|
| + cvox.ChromeVox.msgs = new cvox.Msgs();
|
| +
|
| + /** @type {Element} */
|
| + this.speechContainer_ = $('speech-container');
|
| +
|
| + /** @type {Element} */
|
| + this.speechElement_ = $('speech');
|
| +
|
| + /** @type {Element} */
|
| + this.brailleContainer_ = $('braille-container');
|
| +
|
| + /** @type {Element} */
|
| + this.brailleTextElement_ = $('braille-text');
|
| +
|
| + /** @type {Element} */
|
| + this.brailleCellsElement_ = $('braille-cells');
|
| +
|
| + cvox.Panel.updateFromPrefs();
|
| + window.addEventListener('storage', function(event) {
|
| + if (event.key == 'brailleCaptions') {
|
| + cvox.Panel.updateFromPrefs();
|
| + }
|
| + }, false);
|
| +
|
| + window.addEventListener('message', function(message) {
|
| + var command = JSON.parse(message.data);
|
| + cvox.Panel.exec(/** @type {cvox.PanelCommand} */(command));
|
| + }, false);
|
| +
|
| + $('options').addEventListener('click', cvox.Panel.onOptions, false);
|
| + $('close').addEventListener('click', cvox.Panel.onClose, false);
|
| +};
|
| +
|
| +/**
|
| + * Update the display based on prefs.
|
| + */
|
| +cvox.Panel.updateFromPrefs = function() {
|
| + if (localStorage['brailleCaptions'] === String(true)) {
|
| + this.speechContainer_.style.visibility = 'hidden';
|
| + this.brailleContainer_.style.visibility = 'visible';
|
| + } else {
|
| + this.speechContainer_.style.visibility = 'visible';
|
| + this.brailleContainer_.style.visibility = 'hidden';
|
| + }
|
| +};
|
| +
|
| +/**
|
| + * Execute a command to update the panel.
|
| + *
|
| + * @param {cvox.PanelCommand} command The command to execute.
|
| + */
|
| +cvox.Panel.exec = function(command) {
|
| + switch (command.type) {
|
| + case cvox.PanelCommandType.CLEAR_SPEECH:
|
| + this.speechElement_.innerHTML = '';
|
| + break;
|
| + case cvox.PanelCommandType.ADD_NORMAL_SPEECH:
|
| + if (this.speechElement_.innerHTML != '') {
|
| + this.speechElement_.innerHTML += ' ';
|
| + }
|
| + this.speechElement_.innerHTML += '<span class="usertext">' +
|
| + command.data +
|
| + '</span>';
|
| + break;
|
| + case cvox.PanelCommandType.ADD_ANNOTATION_SPEECH:
|
| + if (this.speechElement_.innerHTML != '') {
|
| + this.speechElement_.innerHTML += ' ';
|
| + }
|
| + this.speechElement_.innerHTML += command.data;
|
| + break;
|
| + case cvox.PanelCommandType.UPDATE_BRAILLE_TEXT:
|
| + this.brailleTextElement_.textContent = command.data;
|
| + break;
|
| + case cvox.PanelCommandType.UPDATE_BRAILLE_CELLS:
|
| + this.brailleCellsElement_.textContent = command.data;
|
| + break;
|
| + }
|
| +};
|
| +
|
| +/**
|
| + * Open the ChromeVox Options.
|
| + */
|
| +cvox.Panel.onOptions = function() {
|
| +};
|
| +
|
| +/**
|
| + * Exit ChromeVox.
|
| + */
|
| +cvox.Panel.onClose = function() {
|
| +};
|
| +
|
| +window.addEventListener('load', function() {
|
| + cvox.Panel.init();
|
| +}, false);
|
|
|