OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 ///////////////////////////////////////////////////////////////////////////// | 6 ///////////////////////////////////////////////////////////////////////////// |
7 // OptionsPage class: | 7 // OptionsPage class: |
8 | 8 |
9 /** | 9 /** |
10 * Base class for options page. | 10 * Base class for options page. |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 this.showPageByName(overlay.parentPage.name, false); | 244 this.showPageByName(overlay.parentPage.name, false); |
245 | 245 |
246 if (!overlay.visible) { | 246 if (!overlay.visible) { |
247 overlay.visible = true; | 247 overlay.visible = true; |
248 if (overlay.didShowPage) overlay.didShowPage(); | 248 if (overlay.didShowPage) overlay.didShowPage(); |
249 } | 249 } |
250 | 250 |
251 // Update tab title. | 251 // Update tab title. |
252 this.setTitle_(overlay.title); | 252 this.setTitle_(overlay.title); |
253 | 253 |
| 254 $('searchBox').setAttribute('aria-hidden', true); |
| 255 |
254 return true; | 256 return true; |
255 }; | 257 }; |
256 | 258 |
257 /** | 259 /** |
258 * Returns whether or not an overlay is visible. | 260 * Returns whether or not an overlay is visible. |
259 * @return {boolean} True if an overlay is visible. | 261 * @return {boolean} True if an overlay is visible. |
260 * @private | 262 * @private |
261 */ | 263 */ |
262 OptionsPage.isOverlayVisible_ = function() { | 264 OptionsPage.isOverlayVisible_ = function() { |
263 return this.getVisibleOverlay_() != null; | 265 return this.getVisibleOverlay_() != null; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 var overlay = this.getVisibleOverlay_(); | 298 var overlay = this.getVisibleOverlay_(); |
297 if (!overlay) | 299 if (!overlay) |
298 return; | 300 return; |
299 | 301 |
300 overlay.visible = false; | 302 overlay.visible = false; |
301 | 303 |
302 if (overlay.didClosePage) overlay.didClosePage(); | 304 if (overlay.didClosePage) overlay.didClosePage(); |
303 this.updateHistoryState_(false, {ignoreHash: true}); | 305 this.updateHistoryState_(false, {ignoreHash: true}); |
304 | 306 |
305 this.restoreLastFocusedElement_(); | 307 this.restoreLastFocusedElement_(); |
| 308 if (!this.isOverlayVisible_()) |
| 309 $('searchBox').removeAttribute('aria-hidden'); |
306 }; | 310 }; |
307 | 311 |
308 /** | 312 /** |
309 * Cancels (closes) the overlay, due to the user pressing <Esc>. | 313 * Cancels (closes) the overlay, due to the user pressing <Esc>. |
310 */ | 314 */ |
311 OptionsPage.cancelOverlay = function() { | 315 OptionsPage.cancelOverlay = function() { |
312 // Blur the active element to ensure any changed pref value is saved. | 316 // Blur the active element to ensure any changed pref value is saved. |
313 document.activeElement.blur(); | 317 document.activeElement.blur(); |
314 var overlay = this.getVisibleOverlay_(); | 318 var overlay = this.getVisibleOverlay_(); |
315 // Let the overlay handle the <Esc> if it wants to. | 319 // Let the overlay handle the <Esc> if it wants to. |
316 if (overlay.handleCancel) { | 320 if (overlay.handleCancel) { |
317 overlay.handleCancel(); | 321 overlay.handleCancel(); |
318 this.restoreLastFocusedElement_(); | 322 this.restoreLastFocusedElement_(); |
319 } else { | 323 } else { |
320 this.closeOverlay(); | 324 this.closeOverlay(); |
321 } | 325 } |
322 } | 326 }; |
323 | 327 |
324 /** | 328 /** |
325 * Hides the visible overlay. Does not affect the history state. | 329 * Hides the visible overlay. Does not affect the history state. |
326 * @private | 330 * @private |
327 */ | 331 */ |
328 OptionsPage.hideOverlay_ = function() { | 332 OptionsPage.hideOverlay_ = function() { |
329 var overlay = this.getVisibleOverlay_(); | 333 var overlay = this.getVisibleOverlay_(); |
330 if (overlay) | 334 if (overlay) |
331 overlay.visible = false; | 335 overlay.visible = false; |
332 }; | 336 }; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 */ | 727 */ |
724 get visible() { | 728 get visible() { |
725 // If this is an overlay dialog it is no longer considered visible while | 729 // If this is an overlay dialog it is no longer considered visible while |
726 // the overlay is fading out. See http://crbug.com/118629. | 730 // the overlay is fading out. See http://crbug.com/118629. |
727 if (this.isOverlay && | 731 if (this.isOverlay && |
728 this.container.classList.contains('transparent')) { | 732 this.container.classList.contains('transparent')) { |
729 return false; | 733 return false; |
730 } | 734 } |
731 return !this.pageDiv.hidden; | 735 return !this.pageDiv.hidden; |
732 }, | 736 }, |
| 737 |
733 /** | 738 /** |
734 * Sets page visibility. | 739 * Sets page visibility. |
735 * @type {boolean} | 740 * @type {boolean} |
736 */ | 741 */ |
737 set visible(visible) { | 742 set visible(visible) { |
738 if ((this.visible && visible) || (!this.visible && !visible)) | 743 if ((this.visible && visible) || (!this.visible && !visible)) |
739 return; | 744 return; |
740 | 745 |
741 // If using an overlay, the visibility of the dialog is toggled at the | 746 // If using an overlay, the visibility of the dialog is toggled at the |
742 // same time as the overlay to show the dialog's out transition. This | 747 // same time as the overlay to show the dialog's out transition. This |
(...skipping 11 matching lines...) Expand all Loading... |
754 /** | 759 /** |
755 * Shows or hides an overlay (including any visible dialog). | 760 * Shows or hides an overlay (including any visible dialog). |
756 * @param {boolean} visible Whether the overlay should be visible or not. | 761 * @param {boolean} visible Whether the overlay should be visible or not. |
757 * @private | 762 * @private |
758 */ | 763 */ |
759 setOverlayVisible_: function(visible) { | 764 setOverlayVisible_: function(visible) { |
760 assert(this.isOverlay); | 765 assert(this.isOverlay); |
761 var pageDiv = this.pageDiv; | 766 var pageDiv = this.pageDiv; |
762 var container = this.container; | 767 var container = this.container; |
763 | 768 |
764 if (visible) | 769 if (visible) { |
765 uber.invokeMethodOnParent('beginInterceptingEvents'); | 770 uber.invokeMethodOnParent('beginInterceptingEvents'); |
| 771 this.pageDiv.removeAttribute('aria-hidden'); |
| 772 this.parentPage.pageDiv.setAttribute('aria-hidden', true); |
| 773 } else { |
| 774 this.parentPage.pageDiv.removeAttribute('aria-hidden'); |
| 775 } |
766 | 776 |
767 if (container.hidden != visible) { | 777 if (container.hidden != visible) { |
768 if (visible) { | 778 if (visible) { |
769 // If the container is set hidden and then immediately set visible | 779 // If the container is set hidden and then immediately set visible |
770 // again, the fadeCompleted_ callback would cause it to be erroneously | 780 // again, the fadeCompleted_ callback would cause it to be erroneously |
771 // hidden again. Removing the transparent tag avoids that. | 781 // hidden again. Removing the transparent tag avoids that. |
772 container.classList.remove('transparent'); | 782 container.classList.remove('transparent'); |
773 | 783 |
774 // Hide all dialogs in this container since a different one may have | 784 // Hide all dialogs in this container since a different one may have |
775 // been previously visible before fading out. | 785 // been previously visible before fading out. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 canShowPage: function() { | 887 canShowPage: function() { |
878 return true; | 888 return true; |
879 }, | 889 }, |
880 }; | 890 }; |
881 | 891 |
882 // Export | 892 // Export |
883 return { | 893 return { |
884 OptionsPage: OptionsPage | 894 OptionsPage: OptionsPage |
885 }; | 895 }; |
886 }); | 896 }); |
OLD | NEW |