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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 /** | 752 /** |
753 * Initializes page content. | 753 * Initializes page content. |
754 */ | 754 */ |
755 initializePage: function() {}, | 755 initializePage: function() {}, |
756 | 756 |
757 /** | 757 /** |
758 * Sets focus on the first focusable element. Override for a custom focus | 758 * Sets focus on the first focusable element. Override for a custom focus |
759 * strategy. | 759 * strategy. |
760 */ | 760 */ |
761 focus: function() { | 761 focus: function() { |
| 762 // Do not change focus if any control on this page is already focused. |
| 763 if (this.pageDiv.contains(document.activeElement)) |
| 764 return; |
| 765 |
762 var elements = this.pageDiv.querySelectorAll( | 766 var elements = this.pageDiv.querySelectorAll( |
763 'input, list, select, textarea, button'); | 767 'input, list, select, textarea, button'); |
764 for (var i = 0; i < elements.length; i++) { | 768 for (var i = 0; i < elements.length; i++) { |
765 var element = elements[i]; | 769 var element = elements[i]; |
766 // Try to focus. If fails, then continue. | 770 // Try to focus. If fails, then continue. |
767 element.focus(); | 771 element.focus(); |
768 if (document.activeElement == element) | 772 if (document.activeElement == element) |
769 return; | 773 return; |
770 } | 774 } |
771 }, | 775 }, |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 canShowPage: function() { | 955 canShowPage: function() { |
952 return true; | 956 return true; |
953 }, | 957 }, |
954 }; | 958 }; |
955 | 959 |
956 // Export | 960 // Export |
957 return { | 961 return { |
958 OptionsPage: OptionsPage | 962 OptionsPage: OptionsPage |
959 }; | 963 }; |
960 }); | 964 }); |
OLD | NEW |