| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 $('options').addEventListener('click', Panel.onOptions, false); | 123 $('options').addEventListener('click', Panel.onOptions, false); |
| 124 $('close').addEventListener('click', Panel.onClose, false); | 124 $('close').addEventListener('click', Panel.onClose, false); |
| 125 | 125 |
| 126 $('tutorial_next').addEventListener('click', Panel.onTutorialNext, false); | 126 $('tutorial_next').addEventListener('click', Panel.onTutorialNext, false); |
| 127 $('tutorial_previous').addEventListener( | 127 $('tutorial_previous').addEventListener( |
| 128 'click', Panel.onTutorialPrevious, false); | 128 'click', Panel.onTutorialPrevious, false); |
| 129 $('close_tutorial').addEventListener('click', Panel.onCloseTutorial, false); | 129 $('close_tutorial').addEventListener('click', Panel.onCloseTutorial, false); |
| 130 | 130 |
| 131 document.addEventListener('keydown', Panel.onKeyDown, false); | 131 document.addEventListener('keydown', Panel.onKeyDown, false); |
| 132 document.addEventListener('mouseup', Panel.onMouseUp, false); | 132 document.addEventListener('mouseup', Panel.onMouseUp, false); |
| 133 window.addEventListener('blur', function(evt) { |
| 134 if (evt.target != window || document.activeElement == document.body) |
| 135 return; |
| 136 |
| 137 Panel.closeMenusAndRestoreFocus(); |
| 138 }, false); |
| 133 | 139 |
| 134 Panel.searchInput_.addEventListener('blur', Panel.onSearchInputBlur, false); | 140 Panel.searchInput_.addEventListener('blur', Panel.onSearchInputBlur, false); |
| 135 }; | 141 }; |
| 136 | 142 |
| 137 /** | 143 /** |
| 138 * Update the display based on prefs. | 144 * Update the display based on prefs. |
| 139 */ | 145 */ |
| 140 Panel.updateFromPrefs = function() { | 146 Panel.updateFromPrefs = function() { |
| 141 if (Panel.searching_) { | 147 if (Panel.searching_) { |
| 142 this.speechContainer_.hidden = true; | 148 this.speechContainer_.hidden = true; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 break; | 214 break; |
| 209 case PanelCommandType.OPEN_MENUS: | 215 case PanelCommandType.OPEN_MENUS: |
| 210 Panel.onOpenMenus(undefined, command.data); | 216 Panel.onOpenMenus(undefined, command.data); |
| 211 break; | 217 break; |
| 212 case PanelCommandType.SEARCH: | 218 case PanelCommandType.SEARCH: |
| 213 Panel.onSearch(); | 219 Panel.onSearch(); |
| 214 break; | 220 break; |
| 215 case PanelCommandType.TUTORIAL: | 221 case PanelCommandType.TUTORIAL: |
| 216 Panel.onTutorial(); | 222 Panel.onTutorial(); |
| 217 break; | 223 break; |
| 224 case PanelCommandType.UPDATE_NOTES: |
| 225 Panel.onTutorial('updateNotes'); |
| 226 break; |
| 218 } | 227 } |
| 219 }; | 228 }; |
| 220 | 229 |
| 221 /** | 230 /** |
| 222 * Enable the ChromeVox Menus. | 231 * Enable the ChromeVox Menus. |
| 223 */ | 232 */ |
| 224 Panel.onEnableMenus = function() { | 233 Panel.onEnableMenus = function() { |
| 225 Panel.menusEnabled_ = true; | 234 Panel.menusEnabled_ = true; |
| 226 $('menus_button').disabled = false; | 235 $('menus_button').disabled = false; |
| 227 $('triangle').hidden = false; | 236 $('triangle').hidden = false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 246 return; | 255 return; |
| 247 | 256 |
| 248 this.mode_ = mode; | 257 this.mode_ = mode; |
| 249 | 258 |
| 250 if (this.mode_ == Panel.Mode.FULLSCREEN_MENUS || | 259 if (this.mode_ == Panel.Mode.FULLSCREEN_MENUS || |
| 251 this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL) { | 260 this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL) { |
| 252 // Change the url fragment to 'fullscreen', which signals the native | 261 // Change the url fragment to 'fullscreen', which signals the native |
| 253 // host code to make the window fullscreen and give it focus. | 262 // host code to make the window fullscreen and give it focus. |
| 254 window.location = '#fullscreen'; | 263 window.location = '#fullscreen'; |
| 255 } else if (this.mode_ == Panel.Mode.FOCUSED) { | 264 } else if (this.mode_ == Panel.Mode.FOCUSED) { |
| 256 // // Change the url fragment to 'focus', which signals the native | 265 // Change the url fragment to 'focus', which signals the native |
| 257 // host code to give the window focus. | 266 // host code to give the window focus. |
| 258 window.location = '#focus'; | 267 window.location = '#focus'; |
| 259 } else { | 268 } else { |
| 260 // Remove the url fragment, which signals the native host code to | 269 // Remove the url fragment, which signals the native host code to |
| 261 // collapse the panel to its normal size and cause it to lose focus. | 270 // collapse the panel to its normal size and cause it to lose focus. |
| 262 window.location = '#'; | 271 window.location = '#'; |
| 263 } | 272 } |
| 264 | 273 |
| 265 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); | 274 $('main').hidden = (this.mode_ == Panel.Mode.FULLSCREEN_TUTORIAL); |
| 266 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); | 275 $('menus_background').hidden = (this.mode_ != Panel.Mode.FULLSCREEN_MENUS); |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 | 786 |
| 778 // Make sure we're not in full-screen mode. | 787 // Make sure we're not in full-screen mode. |
| 779 Panel.setMode(Panel.Mode.COLLAPSED); | 788 Panel.setMode(Panel.Mode.COLLAPSED); |
| 780 | 789 |
| 781 this.activeMenu_ = null; | 790 this.activeMenu_ = null; |
| 782 }); | 791 }); |
| 783 }; | 792 }; |
| 784 | 793 |
| 785 /** | 794 /** |
| 786 * Open the tutorial. | 795 * Open the tutorial. |
| 796 * @param {string=} opt_page Show a specific page. |
| 787 */ | 797 */ |
| 788 Panel.onTutorial = function() { | 798 Panel.onTutorial = function(opt_page) { |
| 789 // Change the url fragment to 'fullscreen', which signals the native | 799 // Change the url fragment to 'fullscreen', which signals the native |
| 790 // host code to make the window fullscreen, revealing the menus. | 800 // host code to make the window fullscreen, revealing the menus. |
| 791 Panel.setMode(Panel.Mode.FULLSCREEN_TUTORIAL); | 801 Panel.setMode(Panel.Mode.FULLSCREEN_TUTORIAL); |
| 792 | 802 |
| 793 Panel.tutorial_.firstPage(); | 803 switch (opt_page) { |
| 804 case 'updateNotes': |
| 805 Panel.tutorial_.updateNotes(); |
| 806 break; |
| 807 default: |
| 808 Panel.tutorial_.lastViewedPage(); |
| 809 } |
| 794 }; | 810 }; |
| 795 | 811 |
| 796 /** | 812 /** |
| 797 * Move to the next page in the tutorial. | 813 * Move to the next page in the tutorial. |
| 798 */ | 814 */ |
| 799 Panel.onTutorialNext = function() { | 815 Panel.onTutorialNext = function() { |
| 800 Panel.tutorial_.nextPage(); | 816 Panel.tutorial_.nextPage(); |
| 801 }; | 817 }; |
| 802 | 818 |
| 803 /** | 819 /** |
| (...skipping 20 matching lines...) Expand all Loading... |
| 824 }, false); | 840 }, false); |
| 825 | 841 |
| 826 window.addEventListener('hashchange', function() { | 842 window.addEventListener('hashchange', function() { |
| 827 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 843 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 828 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 844 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 829 cvox.ChromeVox.isStickyPrefOn = false; | 845 cvox.ChromeVox.isStickyPrefOn = false; |
| 830 } else { | 846 } else { |
| 831 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 847 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 832 } | 848 } |
| 833 }, false); | 849 }, false); |
| OLD | NEW |