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

Unified Diff: chrome/browser/resources/access_chromevox/chromevox/injected/tools/choice_widget.js

Issue 6254007: Adding ChromeVox as a component extensions (enabled only for ChromeOS, for no... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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/access_chromevox/chromevox/injected/tools/choice_widget.js
===================================================================
--- chrome/browser/resources/access_chromevox/chromevox/injected/tools/choice_widget.js (revision 0)
+++ chrome/browser/resources/access_chromevox/chromevox/injected/tools/choice_widget.js (revision 0)
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 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 A floating choice widget that can be used as
+ * a replacement for the standard alert() popup, a disambiguation
+ * dialog if multiple targets are available, etc.
+ */
+
+goog.provide('cvox.ChromeVoxChoiceWidget');
+
+goog.require('cvox.AbstractEarcons');
+goog.require('cvox.AbstractTts');
+goog.require('cvox.ChromeVox');
+
+/**
+ * @constructor
+ */
+cvox.ChromeVoxChoiceWidget = function() {
+ this.powerKey = new PowerKey('main', null);
+ this.powerKey.createCompletionField(document.body, 50, null, null, null,
+ false);
+ this.powerKey.setAutoHideCompletionField(true);
+ this.powerKey.setDefaultCSSStyle();
+};
+
+/**
+ * Creates an alert dialog widget given a set of descriptions and associated
+ * functions.
+ *
+ * @param {Array.<string>} descriptions The array of strings to present
+ * to the user.
+ * @param {Array.<string>} functions The array of functions associated
+ * with the descriptions.
+ * @param {string} prompt The message to be spoken to the user.
+ */
+cvox.ChromeVoxChoiceWidget.prototype.show = function(descriptions, functions,
+ prompt) {
+ this.powerKey.setCompletionList(descriptions);
+ var completionActionMap = new Object();
+ for (var i = 0, description; description = descriptions[i]; i++) {
+ var action = new Object();
+ action['main'] = functions[i];
+ completionActionMap[description.toLowerCase()] = action;
+ }
+ this.powerKey.setCompletionActionMap(completionActionMap);
+ this.powerKey.setCompletionPromptStr(descriptions.toString());
+ this.powerKey.setBrowseCallback(function(text) {
+ cvox.ChromeVox.tts.speak(text, cvox.AbstractTts.QUEUE_MODE_FLUSH,
+ null);
+ });
+ this.powerKey.updateCompletionField(PowerKey.status.VISIBLE, true, 40, 20);
+ cvox.ChromeVox.earcons.playEarcon(cvox.AbstractEarcons.LISTBOX);
+ window.setTimeout(function() {
+ cvox.ChromeVox.tts.speak(prompt);
+ }, 0);
+};
Property changes on: chrome/browser/resources/access_chromevox/chromevox/injected/tools/choice_widget.js
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698