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

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

Issue 2418253002: Make updates to Panel menu (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview The ChromeVox panel and menus. 6 * @fileoverview The ChromeVox panel and menus.
7 */ 7 */
8 8
9 goog.provide('Panel'); 9 goog.provide('Panel');
10 10
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 var jumpMenu = Panel.addMenu('panel_menu_jump'); 264 var jumpMenu = Panel.addMenu('panel_menu_jump');
265 var speechMenu = Panel.addMenu('panel_menu_speech'); 265 var speechMenu = Panel.addMenu('panel_menu_speech');
266 var tabsMenu = Panel.addMenu('panel_menu_tabs'); 266 var tabsMenu = Panel.addMenu('panel_menu_tabs');
267 var chromevoxMenu = Panel.addMenu('panel_menu_chromevox'); 267 var chromevoxMenu = Panel.addMenu('panel_menu_chromevox');
268 268
269 // Create a mapping between categories from CommandStore, and our 269 // Create a mapping between categories from CommandStore, and our
270 // top-level menus. Some categories aren't mapped to any menu. 270 // top-level menus. Some categories aren't mapped to any menu.
271 var categoryToMenu = { 271 var categoryToMenu = {
272 'navigation': jumpMenu, 272 'navigation': jumpMenu,
273 'jump_commands': jumpMenu, 273 'jump_commands': jumpMenu,
274 'overview': jumpMenu,
275 'tables': jumpMenu,
274 'controlling_speech': speechMenu, 276 'controlling_speech': speechMenu,
277 'information': speechMenu,
275 'modifier_keys': chromevoxMenu, 278 'modifier_keys': chromevoxMenu,
276 'help_commands': chromevoxMenu, 279 'help_commands': chromevoxMenu,
277 280
278 'information': null, // Get link URL, get page title, etc.
279 'overview': null, // Headings list, etc.
280 'tables': null, // Table navigation.
281 'braille': null, 281 'braille': null,
282 'developer': null}; 282 'developer': null};
283 283
284 // Get the key map from the background page. 284 // Get the key map from the background page.
285 var bkgnd = chrome.extension.getBackgroundPage(); 285 var bkgnd = chrome.extension.getBackgroundPage();
286 var keymap = bkgnd['cvox']['KeyMap']['fromCurrentKeyMap'](); 286 var keymap = bkgnd['cvox']['KeyMap']['fromCurrentKeyMap']();
287 287
288 // Make a copy of the key bindings, get the localized title of each 288 // Make a copy of the key bindings, get the localized title of each
289 // command, and then sort them. 289 // command, and then sort them.
290 var sortedBindings = keymap.bindings().slice(); 290 var sortedBindings = keymap.bindings().slice();
(...skipping 12 matching lines...) Expand all
303 title = title.replace(/\w\S*/g, function(word) { 303 title = title.replace(/\w\S*/g, function(word) {
304 return word.charAt(0).toUpperCase() + word.substr(1); 304 return word.charAt(0).toUpperCase() + word.substr(1);
305 }); 305 });
306 binding.title = title; 306 binding.title = title;
307 }, this)); 307 }, this));
308 sortedBindings.sort(function(binding1, binding2) { 308 sortedBindings.sort(function(binding1, binding2) {
309 return binding1.title.localeCompare(binding2.title); 309 return binding1.title.localeCompare(binding2.title);
310 }); 310 });
311 311
312 // Insert items from the bindings into the menus. 312 // Insert items from the bindings into the menus.
313 var sawBindingSet = {};
313 sortedBindings.forEach(goog.bind(function(binding) { 314 sortedBindings.forEach(goog.bind(function(binding) {
315 var command = binding.command;
316 if (sawBindingSet[command])
317 return;
318 sawBindingSet[command] = true;
314 var category = cvox.CommandStore.categoryForCommand(binding.command); 319 var category = cvox.CommandStore.categoryForCommand(binding.command);
315 var menu = category ? categoryToMenu[category] : null; 320 var menu = category ? categoryToMenu[category] : null;
316 if (binding.title && menu) { 321 if (binding.title && menu) {
317 menu.addMenuItem( 322 menu.addMenuItem(
318 binding.title, 323 binding.title,
319 binding.keySeq, 324 binding.keySeq,
320 function() { 325 function() {
321 var CommandHandler = 326 var CommandHandler =
322 chrome.extension.getBackgroundPage()['CommandHandler']; 327 chrome.extension.getBackgroundPage()['CommandHandler'];
323 CommandHandler['onCommand'](binding.command); 328 CommandHandler['onCommand'](binding.command);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 }, false); 696 }, false);
692 697
693 window.addEventListener('hashchange', function() { 698 window.addEventListener('hashchange', function() {
694 if (location.hash == '#fullscreen' || location.hash == '#focus') { 699 if (location.hash == '#fullscreen' || location.hash == '#focus') {
695 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 700 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
696 cvox.ChromeVox.isStickyPrefOn = false; 701 cvox.ChromeVox.isStickyPrefOn = false;
697 } else { 702 } else {
698 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 703 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
699 } 704 }
700 }, false); 705 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698