| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 $('close_tutorial').addEventListener('click', Panel.onCloseTutorial, false); | 158 $('close_tutorial').addEventListener('click', Panel.onCloseTutorial, false); |
| 159 | 159 |
| 160 document.addEventListener('keydown', Panel.onKeyDown, false); | 160 document.addEventListener('keydown', Panel.onKeyDown, false); |
| 161 document.addEventListener('mouseup', Panel.onMouseUp, false); | 161 document.addEventListener('mouseup', Panel.onMouseUp, false); |
| 162 window.addEventListener('blur', function(evt) { | 162 window.addEventListener('blur', function(evt) { |
| 163 if (evt.target != window || document.activeElement == document.body) | 163 if (evt.target != window || document.activeElement == document.body) |
| 164 return; | 164 return; |
| 165 | 165 |
| 166 Panel.closeMenusAndRestoreFocus(); | 166 Panel.closeMenusAndRestoreFocus(); |
| 167 }, false); | 167 }, false); |
| 168 |
| 169 /** @type {Window} */ |
| 170 Panel.ownerWindow = window; |
| 168 }; | 171 }; |
| 169 | 172 |
| 170 /** | 173 /** |
| 171 * Update the display based on prefs. | 174 * Update the display based on prefs. |
| 172 */ | 175 */ |
| 173 Panel.updateFromPrefs = function() { | 176 Panel.updateFromPrefs = function() { |
| 174 if (Panel.mode_ == Panel.Mode.SEARCH) { | 177 if (Panel.mode_ == Panel.Mode.SEARCH) { |
| 175 this.speechContainer_.hidden = true; | 178 this.speechContainer_.hidden = true; |
| 176 this.brailleContainer_.hidden = true; | 179 this.brailleContainer_.hidden = true; |
| 177 this.searchContainer_.hidden = false; | 180 this.searchContainer_.hidden = false; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 Panel.setMode = function(mode) { | 287 Panel.setMode = function(mode) { |
| 285 if (this.mode_ == mode) | 288 if (this.mode_ == mode) |
| 286 return; | 289 return; |
| 287 | 290 |
| 288 if (this.isUserSessionBlocked_ && | 291 if (this.isUserSessionBlocked_ && |
| 289 mode != Panel.Mode.COLLAPSED && mode != Panel.Mode.FOCUSED) | 292 mode != Panel.Mode.COLLAPSED && mode != Panel.Mode.FOCUSED) |
| 290 return; | 293 return; |
| 291 this.mode_ = mode; | 294 this.mode_ = mode; |
| 292 | 295 |
| 293 document.title = Msgs.getMsg(Panel.ModeInfo[this.mode_].title); | 296 document.title = Msgs.getMsg(Panel.ModeInfo[this.mode_].title); |
| 294 window.location = Panel.ModeInfo[this.mode_].location; | 297 |
| 298 // Fully qualify the path here because this function might be called with a |
| 299 // window object belonging to the background page. |
| 300 Panel.ownerWindow.location = |
| 301 chrome.extension.getURL('cvox2/background/panel.html') + |
| 302 Panel.ModeInfo[this.mode_].location; |
| 303 |
| 295 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); | 304 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); |
| 296 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); | 305 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); |
| 297 $('tutorial').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_TUTORIAL); | 306 $('tutorial').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_TUTORIAL); |
| 298 }; | 307 }; |
| 299 | 308 |
| 300 /** | 309 /** |
| 301 * Open / show the ChromeVox Menus. | 310 * Open / show the ChromeVox Menus. |
| 302 * @param {Event=} opt_event An optional event that triggered this. | 311 * @param {Event=} opt_event An optional event that triggered this. |
| 303 * @param {*=} opt_activateMenuTitle Title msg id of menu to open. | 312 * @param {*=} opt_activateMenuTitle Title msg id of menu to open. |
| 304 */ | 313 */ |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 bkgnd['showOptionsPage'](); | 806 bkgnd['showOptionsPage'](); |
| 798 Panel.setMode(Panel.Mode.COLLAPSED); | 807 Panel.setMode(Panel.Mode.COLLAPSED); |
| 799 }; | 808 }; |
| 800 | 809 |
| 801 /** | 810 /** |
| 802 * Exit ChromeVox. | 811 * Exit ChromeVox. |
| 803 */ | 812 */ |
| 804 Panel.onClose = function() { | 813 Panel.onClose = function() { |
| 805 // Change the url fragment to 'close', which signals the native code | 814 // Change the url fragment to 'close', which signals the native code |
| 806 // to exit ChromeVox. | 815 // to exit ChromeVox. |
| 807 window.location = '#close'; | 816 Panel.ownerWindow.location = |
| 817 chrome.extension.getURL('cvox2/background/panel.html') + '#close'; |
| 808 }; | 818 }; |
| 809 | 819 |
| 810 /** | 820 /** |
| 811 * Get the callback for whatever item is currently selected. | 821 * Get the callback for whatever item is currently selected. |
| 812 * @return {Function} The callback for the current item. | 822 * @return {Function} The callback for the current item. |
| 813 */ | 823 */ |
| 814 Panel.getCallbackForCurrentItem = function() { | 824 Panel.getCallbackForCurrentItem = function() { |
| 815 if (this.activeMenu_) | 825 if (this.activeMenu_) |
| 816 return this.activeMenu_.getCallbackForCurrentItem(); | 826 return this.activeMenu_.getCallbackForCurrentItem(); |
| 817 return null; | 827 return null; |
| 818 }; | 828 }; |
| 819 | 829 |
| 820 /** | 830 /** |
| 821 * Close the menus and restore focus to the page. If a menu item's callback | 831 * Close the menus and restore focus to the page. If a menu item's callback |
| 822 * was queued, execute it once focus is restored. | 832 * was queued, execute it once focus is restored. |
| 823 */ | 833 */ |
| 824 Panel.closeMenusAndRestoreFocus = function() { | 834 Panel.closeMenusAndRestoreFocus = function() { |
| 825 // Watch for the next focus event. | 835 // Watch for the next focus event. |
| 826 var onFocus = function(desktop, evt) { | 836 var onFocus = function(desktop, evt) { |
| 827 desktop.removeEventListener(chrome.automation.EventType.FOCUS, onFocus); | 837 desktop.removeEventListener(chrome.automation.EventType.FOCUS, onFocus); |
| 828 if (Panel.pendingCallback_) { | 838 if (Panel.pendingCallback_) { |
| 829 // Clear it before calling it, in case the callback itself triggers | 839 // Clear it before calling it, in case the callback itself triggers |
| 830 // another pending callback. | 840 // another pending callback. |
| 831 var pendingCallback = Panel.pendingCallback_; | 841 var pendingCallback = Panel.pendingCallback_; |
| 832 Panel.pendingCallback_ = null; | 842 Panel.pendingCallback_ = null; |
| 833 pendingCallback(); | 843 pendingCallback(); |
| 834 } | 844 } |
| 835 }.bind(this); | 845 }.bind(this); |
| 836 | 846 |
| 837 chrome.automation.getDesktop(function(desktop) { | 847 var bkgnd = chrome.extension.getBackgroundPage(); |
| 848 bkgnd.chrome.automation.getDesktop(function(desktop) { |
| 838 onFocus = /** @type {function(chrome.automation.AutomationEvent)} */( | 849 onFocus = /** @type {function(chrome.automation.AutomationEvent)} */( |
| 839 onFocus.bind(this, desktop)); | 850 onFocus.bind(this, desktop)); |
| 840 desktop.addEventListener(chrome.automation.EventType.FOCUS, | 851 desktop.addEventListener(chrome.automation.EventType.FOCUS, |
| 841 onFocus, | 852 onFocus, |
| 842 true); | 853 true); |
| 843 | 854 |
| 844 // Make sure all menus are cleared to avoid bogous output when we re-open. | 855 // Make sure all menus are cleared to avoid bogous output when we re-open. |
| 845 Panel.clearMenus(); | 856 Panel.clearMenus(); |
| 846 | 857 |
| 847 // Make sure we're not in full-screen mode. | 858 // Make sure we're not in full-screen mode. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 }, false); | 911 }, false); |
| 901 | 912 |
| 902 window.addEventListener('hashchange', function() { | 913 window.addEventListener('hashchange', function() { |
| 903 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 914 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 904 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 915 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 905 cvox.ChromeVox.isStickyPrefOn = false; | 916 cvox.ChromeVox.isStickyPrefOn = false; |
| 906 } else { | 917 } else { |
| 907 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 918 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 908 } | 919 } |
| 909 }, false); | 920 }, false); |
| OLD | NEW |