Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/browser/resources/options/home_page_overlay.js

Issue 11096020: Add first batch of controlled setting indicators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit addressed. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 */ var OptionsPage = options.OptionsPage; 6 /** @const */ var OptionsPage = options.OptionsPage;
7 /** @const */ var SettingsDialog = options.SettingsDialog; 7 /** @const */ var SettingsDialog = options.SettingsDialog;
8 8
9 /** 9 /**
10 * HomePageOverlay class 10 * HomePageOverlay class
(...skipping 20 matching lines...) Expand all
31 autocompleteList_: null, 31 autocompleteList_: null,
32 32
33 /** 33 /**
34 * Initialize the page. 34 * Initialize the page.
35 */ 35 */
36 initializePage: function() { 36 initializePage: function() {
37 // Call base class implementation to start preference initialization. 37 // Call base class implementation to start preference initialization.
38 SettingsDialog.prototype.initializePage.call(this); 38 SettingsDialog.prototype.initializePage.call(this);
39 39
40 var self = this; 40 var self = this;
41 $('homepage-use-ntp').onchange = this.updateHomePageInput_.bind(this); 41 options.Preferences.getInstance().addEventListener(
42 $('homepage-use-url').onchange = this.updateHomePageInput_.bind(this); 42 'homepage_is_newtabpage',
43 this.handleHomepageIsNTPPrefChange.bind(this));
43 44
44 var urlField = $('homepage-url-field'); 45 var urlField = $('homepage-url-field');
45 urlField.addEventListener('keydown', function(event) { 46 urlField.addEventListener('keydown', function(event) {
46 // Focus the 'OK' button when the user hits enter since people expect 47 // Focus the 'OK' button when the user hits enter since people expect
47 // feedback indicating that they are done editing. 48 // feedback indicating that they are done editing.
48 if (event.keyIdentifier == 'Enter' && self.autocompleteList_.hidden) 49 if (event.keyIdentifier == 'Enter' && self.autocompleteList_.hidden)
49 $('home-page-confirm').focus(); 50 $('home-page-confirm').focus();
50 }); 51 });
51 urlField.addEventListener('change', this.updateFavicon_.bind(this)); 52 urlField.addEventListener('change', this.updateFavicon_.bind(this));
52 53
(...skipping 13 matching lines...) Expand all
66 67
67 // Text fields may change widths when the window changes size, so make 68 // Text fields may change widths when the window changes size, so make
68 // sure the suggestion list stays in sync. 69 // sure the suggestion list stays in sync.
69 window.addEventListener('resize', function() { 70 window.addEventListener('resize', function() {
70 self.autocompleteList_.syncWidthToInput(); 71 self.autocompleteList_.syncWidthToInput();
71 }); 72 });
72 }, 73 },
73 74
74 /** @inheritDoc */ 75 /** @inheritDoc */
75 didShowPage: function() { 76 didShowPage: function() {
76 this.updateHomePageInput_();
77 this.updateFavicon_(); 77 this.updateFavicon_();
78 }, 78 },
79 79
80 /** 80 /**
81 * Updates the state of the homepage text input. The input is enabled only 81 * Updates the state of the homepage text input and its controlled setting
82 * if the |homepage-use-url| radio button is checked. 82 * indicator when the |homepage_is_newtabpage| pref changes. The input is
83 * @private 83 * enabled only if the homepage is not the NTP. The indicator is always
84 * enabled but treats the input's value as read-only if the homepage is the
85 * NTP.
86 * @param {Event} Pref change event.
84 */ 87 */
85 updateHomePageInput_: function() { 88 handleHomepageIsNTPPrefChange: function(event) {
86 var urlField = $('homepage-url-field'); 89 var urlField = $('homepage-url-field');
87 var homePageUseURL = $('homepage-use-url'); 90 var urlFieldIndicator = $('homepage-url-field-indicator');
88 urlField.setDisabled('radio-choice', !homePageUseURL.checked); 91 urlField.setDisabled('homepage-is-ntp', event.value.value);
92 urlFieldIndicator.readOnly = event.value.value;
89 }, 93 },
90 94
91 /** 95 /**
92 * Updates the background of the url field to show the favicon for the 96 * Updates the background of the url field to show the favicon for the
93 * URL that is currently typed in. 97 * URL that is currently typed in.
94 * @private 98 * @private
95 */ 99 */
96 updateFavicon_: function() { 100 updateFavicon_: function() {
97 var urlField = $('homepage-url-field'); 101 var urlField = $('homepage-url-field');
98 urlField.style.backgroundImage = url('chrome://favicon/' + 102 urlField.style.backgroundImage = url('chrome://favicon/' +
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 HomePageOverlay.updateAutocompleteSuggestions = function() { 153 HomePageOverlay.updateAutocompleteSuggestions = function() {
150 var instance = HomePageOverlay.getInstance(); 154 var instance = HomePageOverlay.getInstance();
151 instance.updateAutocompleteSuggestions_.apply(instance, arguments); 155 instance.updateAutocompleteSuggestions_.apply(instance, arguments);
152 }; 156 };
153 157
154 // Export 158 // Export
155 return { 159 return {
156 HomePageOverlay: HomePageOverlay 160 HomePageOverlay: HomePageOverlay
157 }; 161 };
158 }); 162 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/home_page_overlay.html ('k') | chrome/test/data/policy/policy_test_cases.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698