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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js

Issue 1282593002: Add ChromeVox panel and implement caption display functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to accessibility_manager in this change Created 5 years, 4 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: 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 += '&nbsp;&nbsp;';
+ }
+ 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);

Powered by Google App Engine
This is Rietveld 408576698