| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 Panel = function() { | 25 Panel = function() { |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @enum {string} | 29 * @enum {string} |
| 30 */ | 30 */ |
| 31 Panel.Mode = { | 31 Panel.Mode = { |
| 32 COLLAPSED: 'collapsed', | 32 COLLAPSED: 'collapsed', |
| 33 FOCUSED: 'focused', | 33 FOCUSED: 'focused', |
| 34 FULLSCREEN_MENUS: 'menus', | 34 FULLSCREEN_MENUS: 'menus', |
| 35 FULLSCREEN_TUTORIAL: 'tutorial' | 35 FULLSCREEN_TUTORIAL: 'tutorial', |
| 36 SEARCH: 'search' |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 /** | 39 /** |
| 40 * @type {!Object<string, {title: string, location: (string|undefined)}>} |
| 41 */ |
| 42 Panel.ModeInfo = { |
| 43 collapsed: {title: 'panel_title', location: '#'}, |
| 44 focused: {title: 'panel_title', location: '#focus'}, |
| 45 menus: {title: 'panel_menus_title', location: '#fullscreen'}, |
| 46 tutorial: {title: 'panel_tutorial_title', location: '#fullscreen'}, |
| 47 search: {title: 'panel_title', location: '#focus'} |
| 48 }; |
| 49 |
| 50 /** |
| 39 * A callback function to be executed to perform the action from selecting | 51 * A callback function to be executed to perform the action from selecting |
| 40 * a menu item after the menu has been closed and focus has been restored | 52 * a menu item after the menu has been closed and focus has been restored |
| 41 * to the page or wherever it was previously. | 53 * to the page or wherever it was previously. |
| 42 * @param {?Function} callback | 54 * @param {?Function} callback |
| 43 */ | 55 */ |
| 44 Panel.setPendingCallback = function(callback) { | 56 Panel.setPendingCallback = function(callback) { |
| 45 /** @type {?Function} @private */ | 57 /** @type {?Function} @private */ |
| 46 Panel.pendingCallback_ = callback; | 58 Panel.pendingCallback_ = callback; |
| 47 }; | 59 }; |
| 48 | 60 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 100 |
| 89 /** | 101 /** |
| 90 * True if the menu button in the panel is enabled at all. It's disabled if | 102 * True if the menu button in the panel is enabled at all. It's disabled if |
| 91 * ChromeVox Next is not active. | 103 * ChromeVox Next is not active. |
| 92 * @type {boolean} | 104 * @type {boolean} |
| 93 * @private | 105 * @private |
| 94 */ | 106 */ |
| 95 this.menusEnabled_ = localStorage['useNext'] == 'true'; | 107 this.menusEnabled_ = localStorage['useNext'] == 'true'; |
| 96 | 108 |
| 97 /** | 109 /** |
| 98 * True if we're currently in incremental search mode. | |
| 99 * @type {boolean} | |
| 100 * @private | |
| 101 */ | |
| 102 this.searching_ = false; | |
| 103 | |
| 104 /** | |
| 105 * @type {Tutorial} | 110 * @type {Tutorial} |
| 106 * @private | 111 * @private |
| 107 */ | 112 */ |
| 108 this.tutorial_ = new Tutorial(); | 113 this.tutorial_ = new Tutorial(); |
| 109 | 114 |
| 110 Panel.setPendingCallback(null); | 115 Panel.setPendingCallback(null); |
| 111 Panel.updateFromPrefs(); | 116 Panel.updateFromPrefs(); |
| 112 | 117 |
| 113 Msgs.addTranslatedMessagesToDom(document); | 118 Msgs.addTranslatedMessagesToDom(document); |
| 114 | 119 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 139 return; | 144 return; |
| 140 | 145 |
| 141 Panel.closeMenusAndRestoreFocus(); | 146 Panel.closeMenusAndRestoreFocus(); |
| 142 }, false); | 147 }, false); |
| 143 }; | 148 }; |
| 144 | 149 |
| 145 /** | 150 /** |
| 146 * Update the display based on prefs. | 151 * Update the display based on prefs. |
| 147 */ | 152 */ |
| 148 Panel.updateFromPrefs = function() { | 153 Panel.updateFromPrefs = function() { |
| 149 if (Panel.searching_) { | 154 if (Panel.mode_ == Panel.Mode.SEARCH) { |
| 150 this.speechContainer_.hidden = true; | 155 this.speechContainer_.hidden = true; |
| 151 this.brailleContainer_.hidden = true; | 156 this.brailleContainer_.hidden = true; |
| 152 this.searchContainer_.hidden = false; | 157 this.searchContainer_.hidden = false; |
| 153 return; | 158 return; |
| 154 } | 159 } |
| 155 | 160 |
| 156 this.speechContainer_.hidden = false; | 161 this.speechContainer_.hidden = false; |
| 157 this.brailleContainer_.hidden = false; | 162 this.brailleContainer_.hidden = false; |
| 158 this.searchContainer_.hidden = true; | 163 this.searchContainer_.hidden = true; |
| 159 | 164 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 * Sets the mode, which determines the size of the panel and what objects | 256 * Sets the mode, which determines the size of the panel and what objects |
| 252 * are shown or hidden. | 257 * are shown or hidden. |
| 253 * @param {Panel.Mode} mode The new mode. | 258 * @param {Panel.Mode} mode The new mode. |
| 254 */ | 259 */ |
| 255 Panel.setMode = function(mode) { | 260 Panel.setMode = function(mode) { |
| 256 if (this.mode_ == mode) | 261 if (this.mode_ == mode) |
| 257 return; | 262 return; |
| 258 | 263 |
| 259 this.mode_ = mode; | 264 this.mode_ = mode; |
| 260 | 265 |
| 261 if (this.mode_ == Panel.Mode.FULLSCREEN_MENUS || | 266 document.title = Msgs.getMsg(Panel.ModeInfo[this.mode_].title); |
| 262 this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL) { | 267 window.location = Panel.ModeInfo[this.mode_].location; |
| 263 // Change the url fragment to 'fullscreen', which signals the native | |
| 264 // host code to make the window fullscreen and give it focus. | |
| 265 window.location = '#fullscreen'; | |
| 266 } else if (this.mode_ == Panel.Mode.FOCUSED) { | |
| 267 // Change the url fragment to 'focus', which signals the native | |
| 268 // host code to give the window focus. | |
| 269 window.location = '#focus'; | |
| 270 } else { | |
| 271 // Remove the url fragment, which signals the native host code to | |
| 272 // collapse the panel to its normal size and cause it to lose focus. | |
| 273 window.location = '#'; | |
| 274 } | |
| 275 | |
| 276 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); | 268 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); |
| 277 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); | 269 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); |
| 278 $('tutorial').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_TUTORIAL); | 270 $('tutorial').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_TUTORIAL); |
| 279 }; | 271 }; |
| 280 | 272 |
| 281 /** | 273 /** |
| 282 * Open / show the ChromeVox Menus. | 274 * Open / show the ChromeVox Menus. |
| 283 * @param {Event=} opt_event An optional event that triggered this. | 275 * @param {Event=} opt_event An optional event that triggered this. |
| 284 * @param {*=} opt_activateMenuTitle Title msg id of menu to open. | 276 * @param {*=} opt_activateMenuTitle Title msg id of menu to open. |
| 285 */ | 277 */ |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 var selectedMenu = Panel.menus_[0]; | 412 var selectedMenu = Panel.menus_[0]; |
| 421 for (var i = 0; i < Panel.menus_.length; i++) { | 413 for (var i = 0; i < Panel.menus_.length; i++) { |
| 422 if (this.menus_[i].menuMsg == opt_activateMenuTitle) | 414 if (this.menus_[i].menuMsg == opt_activateMenuTitle) |
| 423 selectedMenu = this.menus_[i]; | 415 selectedMenu = this.menus_[i]; |
| 424 } | 416 } |
| 425 Panel.activateMenu(selectedMenu); | 417 Panel.activateMenu(selectedMenu); |
| 426 }; | 418 }; |
| 427 | 419 |
| 428 /** Open incremental search. */ | 420 /** Open incremental search. */ |
| 429 Panel.onSearch = function() { | 421 Panel.onSearch = function() { |
| 422 Panel.setMode(Panel.Mode.SEARCH); |
| 430 Panel.clearMenus(); | 423 Panel.clearMenus(); |
| 431 Panel.pendingCallback_ = null; | 424 Panel.pendingCallback_ = null; |
| 432 Panel.searching_ = true; | |
| 433 Panel.updateFromPrefs(); | 425 Panel.updateFromPrefs(); |
| 434 Panel.setMode(Panel.Mode.FOCUSED); | |
| 435 | 426 |
| 436 ISearchUI.init(Panel.searchInput_); | 427 ISearchUI.init(Panel.searchInput_); |
| 437 }; | 428 }; |
| 438 | 429 |
| 439 /** | 430 /** |
| 440 * Clear any previous menus. The menus are all regenerated each time the | 431 * Clear any previous menus. The menus are all regenerated each time the |
| 441 * menus are opened. | 432 * menus are opened. |
| 442 */ | 433 */ |
| 443 Panel.clearMenus = function() { | 434 Panel.clearMenus = function() { |
| 444 while (this.menus_.length) { | 435 while (this.menus_.length) { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 }, false); | 861 }, false); |
| 871 | 862 |
| 872 window.addEventListener('hashchange', function() { | 863 window.addEventListener('hashchange', function() { |
| 873 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 864 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 874 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 865 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 875 cvox.ChromeVox.isStickyPrefOn = false; | 866 cvox.ChromeVox.isStickyPrefOn = false; |
| 876 } else { | 867 } else { |
| 877 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 868 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 878 } | 869 } |
| 879 }, false); | 870 }, false); |
| OLD | NEW |