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 const OptionsPage = options.OptionsPage; | 6 const OptionsPage = options.OptionsPage; |
7 const SettingsDialog = options.SettingsDialog; | 7 const SettingsDialog = options.SettingsDialog; |
8 | 8 |
9 /** | 9 /** |
10 * HomePageOverlay class | 10 * HomePageOverlay class |
(...skipping 13 matching lines...) Expand all Loading... |
24 __proto__: SettingsDialog.prototype, | 24 __proto__: SettingsDialog.prototype, |
25 | 25 |
26 /** | 26 /** |
27 * Initialize the page. | 27 * Initialize the page. |
28 */ | 28 */ |
29 initializePage: function() { | 29 initializePage: function() { |
30 // Call base class implementation to start preference initialization. | 30 // Call base class implementation to start preference initialization. |
31 SettingsDialog.prototype.initializePage.call(this); | 31 SettingsDialog.prototype.initializePage.call(this); |
32 | 32 |
33 var self = this; | 33 var self = this; |
| 34 $('homepage-use-ntp').onchange = this.updateHomePageInput_.bind(this); |
| 35 $('homepage-use-url').onchange = this.updateHomePageInput_.bind(this); |
| 36 |
34 $('homepageURL').addEventListener('keydown', function(event) { | 37 $('homepageURL').addEventListener('keydown', function(event) { |
35 // Focus the 'OK' button when the user hits enter since people expect | 38 // Focus the 'OK' button when the user hits enter since people expect |
36 // feedback indicating that they are done editing. | 39 // feedback indicating that they are done editing. |
37 if (event.keyIdentifier == 'Enter') | 40 if (event.keyIdentifier == 'Enter') |
38 $('home-page-confirm').focus(); | 41 $('home-page-confirm').focus(); |
39 }); | 42 }); |
40 | 43 |
41 // TODO(jhawkins): Refactor BrowserOptions.autocompleteList and use it | 44 // TODO(jhawkins): Refactor BrowserOptions.autocompleteList and use it |
42 // here. | 45 // here. |
43 }, | 46 }, |
44 | 47 |
45 /** | 48 /** |
46 * Sets the 'show home button' and 'home page is new tab page' preferences. | 49 * @inheritDoc |
47 * (The home page url preference is set automatically by the SettingsDialog | |
48 * code.) | |
49 */ | 50 */ |
50 willConfirm: function() { | 51 didShowPage: function() { |
51 Preferences.setBooleanPref('browser.show_home_button', true); | 52 // Set initial state. |
52 Preferences.setBooleanPref('homepage_is_newtabpage', false); | 53 this.updateHomePageInput_(); |
53 }, | 54 }, |
54 | 55 |
55 /** | 56 /** |
56 * Resets the <select> on the browser options page to the appropriate value, | 57 * Updates the state of the homepage text input. The input is enabled only |
57 * based on the current preferences. | 58 * if the |homepageUseURLBUtton| radio is checked. |
| 59 * @private |
58 */ | 60 */ |
59 willCancel: function() { | 61 updateHomePageInput_: function() { |
60 BrowserOptions.getInstance().updateHomePageSelector(); | 62 var homepageInput = $('homepageURL'); |
| 63 var homepageUseURL = $('homepage-use-url'); |
| 64 homepageInput.setDisabled('radio-choice', !homepageUseURL.checked); |
61 }, | 65 }, |
62 }; | 66 }; |
63 | 67 |
64 // Export | 68 // Export |
65 return { | 69 return { |
66 HomePageOverlay: HomePageOverlay | 70 HomePageOverlay: HomePageOverlay |
67 }; | 71 }; |
68 }); | 72 }); |
OLD | NEW |