| OLD | NEW |
| 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 |
| 11 goog.require('BrailleCommandHandler'); |
| 11 goog.require('ISearchUI'); | 12 goog.require('ISearchUI'); |
| 12 goog.require('Msgs'); | 13 goog.require('Msgs'); |
| 13 goog.require('PanelCommand'); | 14 goog.require('PanelCommand'); |
| 14 goog.require('PanelMenu'); | 15 goog.require('PanelMenu'); |
| 15 goog.require('PanelMenuItem'); | 16 goog.require('PanelMenuItem'); |
| 16 goog.require('Tutorial'); | 17 goog.require('Tutorial'); |
| 17 goog.require('cvox.ChromeVoxKbHandler'); | 18 goog.require('cvox.ChromeVoxKbHandler'); |
| 18 goog.require('cvox.CommandStore'); | 19 goog.require('cvox.CommandStore'); |
| 19 | 20 |
| 20 /** | 21 /** |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 var command = binding.command; | 356 var command = binding.command; |
| 356 if (sawBindingSet[command]) | 357 if (sawBindingSet[command]) |
| 357 return; | 358 return; |
| 358 sawBindingSet[command] = true; | 359 sawBindingSet[command] = true; |
| 359 var category = cvox.CommandStore.categoryForCommand(binding.command); | 360 var category = cvox.CommandStore.categoryForCommand(binding.command); |
| 360 var menu = category ? categoryToMenu[category] : null; | 361 var menu = category ? categoryToMenu[category] : null; |
| 361 if (binding.title && menu) { | 362 if (binding.title && menu) { |
| 362 menu.addMenuItem( | 363 menu.addMenuItem( |
| 363 binding.title, | 364 binding.title, |
| 364 binding.keySeq, | 365 binding.keySeq, |
| 366 BrailleCommandHandler.getDotShortcut(binding.command, true), |
| 365 function() { | 367 function() { |
| 366 var CommandHandler = | 368 var CommandHandler = |
| 367 chrome.extension.getBackgroundPage()['CommandHandler']; | 369 chrome.extension.getBackgroundPage()['CommandHandler']; |
| 368 CommandHandler['onCommand'](binding.command); | 370 CommandHandler['onCommand'](binding.command); |
| 369 }); | 371 }); |
| 370 } | 372 } |
| 371 }, this)); | 373 }, this)); |
| 372 | 374 |
| 373 // Add all open tabs to the Tabs menu. | 375 // Add all open tabs to the Tabs menu. |
| 374 bkgnd.chrome.windows.getLastFocused(function(lastFocusedWindow) { | 376 bkgnd.chrome.windows.getLastFocused(function(lastFocusedWindow) { |
| 375 bkgnd.chrome.windows.getAll({'populate': true}, function(windows) { | 377 bkgnd.chrome.windows.getAll({'populate': true}, function(windows) { |
| 376 for (var i = 0; i < windows.length; i++) { | 378 for (var i = 0; i < windows.length; i++) { |
| 377 var tabs = windows[i].tabs; | 379 var tabs = windows[i].tabs; |
| 378 for (var j = 0; j < tabs.length; j++) { | 380 for (var j = 0; j < tabs.length; j++) { |
| 379 var title = tabs[j].title; | 381 var title = tabs[j].title; |
| 380 if (tabs[j].active && windows[i].id == lastFocusedWindow.id) | 382 if (tabs[j].active && windows[i].id == lastFocusedWindow.id) |
| 381 title += ' ' + Msgs.getMsg('active_tab'); | 383 title += ' ' + Msgs.getMsg('active_tab'); |
| 382 tabsMenu.addMenuItem(title, '', (function(win, tab) { | 384 tabsMenu.addMenuItem(title, '', '', (function(win, tab) { |
| 383 bkgnd.chrome.windows.update(win.id, {focused: true}, function() { | 385 bkgnd.chrome.windows.update(win.id, {focused: true}, function() { |
| 384 bkgnd.chrome.tabs.update(tab.id, {active: true}); | 386 bkgnd.chrome.tabs.update(tab.id, {active: true}); |
| 385 }); | 387 }); |
| 386 }).bind(this, windows[i], tabs[j])); | 388 }).bind(this, windows[i], tabs[j])); |
| 387 } | 389 } |
| 388 } | 390 } |
| 389 }); | 391 }); |
| 390 }); | 392 }); |
| 391 | 393 |
| 392 // Add a menu item that disables / closes ChromeVox. | 394 // Add a menu item that disables / closes ChromeVox. |
| 393 chromevoxMenu.addMenuItem( | 395 chromevoxMenu.addMenuItem( |
| 394 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', function() { | 396 Msgs.getMsg('disable_chromevox'), 'Ctrl+Alt+Z', '', function() { |
| 395 Panel.onClose(); | 397 Panel.onClose(); |
| 396 }); | 398 }); |
| 397 | 399 |
| 398 var roleListMenuMapping = [ | 400 var roleListMenuMapping = [ |
| 399 { menuTitle: 'role_heading', predicate: AutomationPredicate.heading }, | 401 { menuTitle: 'role_heading', predicate: AutomationPredicate.heading }, |
| 400 { menuTitle: 'role_landmark', predicate: AutomationPredicate.landmark }, | 402 { menuTitle: 'role_landmark', predicate: AutomationPredicate.landmark }, |
| 401 { menuTitle: 'role_link', predicate: AutomationPredicate.link }, | 403 { menuTitle: 'role_link', predicate: AutomationPredicate.link }, |
| 402 { menuTitle: 'role_form', predicate: AutomationPredicate.formField }, | 404 { menuTitle: 'role_form', predicate: AutomationPredicate.formField }, |
| 403 { menuTitle: 'role_table', predicate: AutomationPredicate.table }]; | 405 { menuTitle: 'role_table', predicate: AutomationPredicate.table }]; |
| 404 | 406 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 }, false); | 842 }, false); |
| 841 | 843 |
| 842 window.addEventListener('hashchange', function() { | 844 window.addEventListener('hashchange', function() { |
| 843 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 845 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 844 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 846 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 845 cvox.ChromeVox.isStickyPrefOn = false; | 847 cvox.ChromeVox.isStickyPrefOn = false; |
| 846 } else { | 848 } else { |
| 847 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 849 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 848 } | 850 } |
| 849 }, false); | 851 }, false); |
| OLD | NEW |