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

Unified Diff: chrome/browser/resources/options2/browser_options.js

Issue 9317114: Settings: Clean up browser_options page according to style guide. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options2/browser_options.js
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index 1fbe3cce331ade70497a647e0c82d70d7880e1ae..5b8eddc64c5857573f83d6410d2496efac06c669 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -3,24 +3,22 @@
// found in the LICENSE file.
cr.define('options', function() {
- const OptionsPage = options.OptionsPage;
- const ArrayDataModel = cr.ui.ArrayDataModel;
- const RepeatingButton = cr.ui.RepeatingButton;
+ var OptionsPage = options.OptionsPage;
+ var ArrayDataModel = cr.ui.ArrayDataModel;
+ var RepeatingButton = cr.ui.RepeatingButton;
csilv 2012/02/07 00:56:57 it's const better for these?
csilv 2012/02/07 00:58:05 of course, i meant to say "isn't const better for
James Hawkins 2012/02/07 01:28:00 No, const is not valid JS and V8 is slower when co
Dan Beam 2012/02/07 09:33:53 We're not using ES5-strict any where options2, so
//
// BrowserOptions class
// Encapsulated handling of browser options page.
//
function BrowserOptions() {
- OptionsPage.call(this, 'browser',
- templateData.browserPageTabTitle,
- 'browserPage');
+ OptionsPage.call(this, 'settings', templateData.settingsTitle,
+ 'settings');
}
cr.addSingletonGetter(BrowserOptions);
BrowserOptions.prototype = {
- // Inherit BrowserOptions from OptionsPage.
__proto__: options.OptionsPage.prototype,
// State variables.
@@ -35,65 +33,66 @@ cr.define('options', function() {
*/
autocompleteList_: null,
- // The cached value of the instant.confirm_dialog_shown preference.
+ /**
+ * The cached value of the instant.confirm_dialog_shown preference.
+ * @type {bool}
+ * @private
+ */
instantConfirmDialogShown_: false,
/**
- * Initialize BrowserOptions page.
+ * @inheritDoc
*/
initializePage: function() {
- // Call base class implementation to start preference initialization.
OptionsPage.prototype.initializePage.call(this);
- var self = this;
-
// Sync (Sign in) section.
- $('sync-action-link').addEventListener('click', function(event) {
+ $('sync-action-link').onclick = function(event) {
SyncSetupOverlay.showErrorUI();
- });
- $('start-stop-sync').addEventListener('click', function(event) {
+ };
+ $('start-stop-sync').onclick = function(event) {
if (self.syncSetupCompleted)
SyncSetupOverlay.showStopSyncingUI();
else
SyncSetupOverlay.showSetupUI();
- });
- $('customize-sync').addEventListener('click', function(event) {
+ };
+ $('customize-sync').onclick = function(event) {
SyncSetupOverlay.showSetupUI();
- });
+ };
// Internet connection section (ChromeOS only).
if (cr.isChromeOS) {
- $('internet-options-button').addEventListener('click', function(event) {
+ $('internet-options-button').onclick = function(event) {
OptionsPage.navigateToPage('internet');
chrome.send('coreOptionsUserMetricsAction',
['Options_InternetOptions']);
- });
+ };
}
// On Startup section.
- $('startupSetPages').addEventListener('click', function() {
+ $('startup-set-pages').onclick = function() {
OptionsPage.navigateToPage('startup');
- });
+ };
// Appearance section.
- $('change-home-page').addEventListener('click', function(event) {
+ $('change-home-page').onclick = function(event) {
OptionsPage.navigateToPage('homePageOverlay');
- });
- $('themes-gallery').addEventListener('click', function(event) {
+ };
+ $('themes-gallery').onclick = function(event) {
window.open(localStrings.getString('themesGalleryURL'));
- });
- $('themes-reset').addEventListener('click', function(event) {
+ };
+ $('themes-reset').onclick = function(event) {
chrome.send('themesReset');
- });
+ };
// Device section (ChromeOS only).
if (cr.isChromeOS) {
- $('keyboard-settings-button').addEventListener('click', function(evt) {
+ $('keyboard-settings-button').onclick = function(evt) {
OptionsPage.navigateToPage('keyboard-overlay');
- });
- $('pointer-settings-button').addEventListener('click', function(evt) {
+ };
+ $('pointer-settings-button').onclick = function(evt) {
OptionsPage.navigateToPage('pointer-overlay');
- });
+ };
this.initBrightnessButton_('brightness-decrease-button',
'decreaseScreenBrightness');
this.initBrightnessButton_('brightness-increase-button',
@@ -101,15 +100,14 @@ cr.define('options', function() {
}
// Search section.
- $('defaultSearchManageEnginesButton').addEventListener('click',
- function(event) {
- OptionsPage.navigateToPage('searchEngines');
- chrome.send('coreOptionsUserMetricsAction',
- ['Options_ManageSearchEngines']);
- });
- $('defaultSearchEngine').addEventListener('change',
+ $('defaultSearchManageEnginesButton').onclick = function(event) {
+ OptionsPage.navigateToPage('searchEngines');
+ chrome.send('coreOptionsUserMetricsAction',
+ ['Options_ManageSearchEngines']);
+ };
+ $('default-search-engine').addEventListener('change',
this.setDefaultSearchEngine_);
- $('instantEnabledCheckbox').customChangeHandler = function(event) {
+ $('instant-enabled-control').customChangeHandler = function(event) {
if (this.checked) {
if (self.instantConfirmDialogShown_)
chrome.send('enableInstant');
@@ -120,10 +118,10 @@ cr.define('options', function() {
}
return true;
};
- $('instantFieldTrialCheckbox').addEventListener('change', function(evt) {
+ $('instant-field-trial-control').onchange = function(evt) {
this.checked = true;
chrome.send('disableInstant');
- });
+ };
Preferences.getInstance().addEventListener('instant.confirm_dialog_shown',
this.onInstantConfirmDialogShownChanged_.bind(this));
Preferences.getInstance().addEventListener('instant.enabled',
@@ -131,15 +129,11 @@ cr.define('options', function() {
// Text fields may change widths when the window changes size, so make
// sure the suggestion list stays in sync.
+ var self = this;
window.addEventListener('resize', function() {
self.autocompleteList_.syncWidthToInput();
});
- if (cr.commandLine && cr.commandLine.options['--bwsi']) {
- // Hide the startup section in Guest mode.
- $('startupSection').hidden = true;
- }
-
var suggestionList = new cr.ui.AutocompleteList();
suggestionList.autoExpands = true;
suggestionList.suggestionUpdateRequestCallback =
@@ -153,29 +147,29 @@ cr.define('options', function() {
profilesList.autoExpands = true;
profilesList.addEventListener('change',
- self.setProfileViewButtonsStatus_);
- $('profiles-create').addEventListener('click', function(event) {
+ this.setProfileViewButtonsStatus_);
+ $('profiles-create').onclick = function(event) {
chrome.send('createProfile');
- });
- $('profiles-manage').addEventListener('click', function(event) {
+ };
+ $('profiles-manage').onclick = function(event) {
var selectedProfile = self.getSelectedProfileItem_();
if (selectedProfile)
ManageProfileOverlay.showManageDialog(selectedProfile);
- });
- $('profiles-delete').addEventListener('click', function(event) {
+ };
+ $('profiles-delete').onclick = function(event) {
var selectedProfile = self.getSelectedProfileItem_();
if (selectedProfile)
ManageProfileOverlay.showDeleteDialog(selectedProfile);
- });
+ };
if (cr.isChromeOS) {
// Username (canonical email) of the currently logged in user or
// |kGuestUser| if a guest session is active.
this.username_ = localStrings.getString('username');
- $('change-picture-button').addEventListener('click', function(event) {
+ $('change-picture-button').onclick = function(event) {
OptionsPage.navigateToPage('changePicture');
- });
+ };
this.updateAccountPicture_();
if (cr.commandLine && cr.commandLine.options['--bwsi']) {
@@ -183,44 +177,46 @@ cr.define('options', function() {
// guest mode.
$('enable-screen-lock').disabled = true;
$('change-picture-button').disabled = true;
+
+ // Hide the startup section in Guest mode.
+ $('startup-section').hidden = true;
}
- $('manage-accounts-button').addEventListener('click', function(event) {
+ $('manage-accounts-button').onclick, function(event) {
OptionsPage.navigateToPage('accounts');
chrome.send('coreOptionsUserMetricsAction',
['Options_ManageAccounts']);
- });
+ };
} else {
- $('import-data').addEventListener('click', function(event) {
+ $('import-data').onclick = function(event) {
// Make sure that any previous import success message is hidden, and
// we're showing the UI to import further data.
$('import-data-configure').hidden = false;
$('import-data-success').hidden = true;
OptionsPage.navigateToPage('importData');
chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']);
- });
+ };
if ($('themes-GTK-button')) {
- $('themes-GTK-button').addEventListener('click', function(event) {
+ $('themes-GTK-button').onclick = function(event) {
chrome.send('themesSetGTK');
- });
+ };
}
}
// Default browser section.
if (!cr.isChromeOS) {
- $('defaultBrowserUseAsDefaultButton').addEventListener('click',
- function(event) {
- chrome.send('becomeDefaultBrowser');
- });
+ $('set-as-default-browser').onclick = function(event) {
+ chrome.send('becomeDefaultBrowser');
+ };
}
// Under the hood section.
- $('advancedOptionsButton').addEventListener('click', function(event) {
+ $('advanced-settings').onclick = function(event) {
OptionsPage.navigateToPage('advanced');
chrome.send('coreOptionsUserMetricsAction',
- ['Options_OpenUnderTheHood']);
- });
+ ['Options_OpenUnderTheHood']);
+ };
},
/**
@@ -348,10 +344,10 @@ cr.define('options', function() {
* @private
*/
setInstantFieldTrialStatus_: function(enabled) {
- $('instantEnabledCheckbox').hidden = enabled;
- $('instantFieldTrialCheckbox').hidden = !enabled;
- $('instantLabel').htmlFor = enabled ? 'instantFieldTrialCheckbox'
- : 'instantEnabledCheckbox';
+ $('instant-enabled-control').hidden = enabled;
+ $('instant-field-trial-control').hidden = !enabled;
+ $('instant-label').htmlFor = enabled ? 'instant-field-trial-control'
+ : 'instant-enabled-control';
},
/**
@@ -364,10 +360,10 @@ cr.define('options', function() {
*/
updateDefaultBrowserState_: function(statusString, isDefault,
canBeDefault) {
- var label = $('defaultBrowserState');
+ var label = $('default-browser-state');
label.textContent = statusString;
- $('defaultBrowserUseAsDefaultButton').hidden = !canBeDefault || isDefault;
+ $('set-as-default-browser').hidden = !canBeDefault || isDefault;
},
/**
@@ -375,7 +371,7 @@ cr.define('options', function() {
* @private
*/
clearSearchEngines_: function() {
- $('defaultSearchEngine').textContent = '';
+ $('default-search-engine').textContent = '';
},
/**
@@ -388,7 +384,7 @@ cr.define('options', function() {
*/
updateSearchEngines_: function(engines, defaultValue, defaultManaged) {
this.clearSearchEngines_();
- engineSelect = $('defaultSearchEngine');
+ engineSelect = $('default-search-engine');
engineSelect.disabled = defaultManaged;
engineCount = engines.length;
var defaultIndex = -1;
@@ -410,7 +406,7 @@ cr.define('options', function() {
* enabled.
*/
shouldEnableCustomStartupPageControls: function(pages) {
- return $('startupShowPagesButton').checked &&
+ return $('startup-show-pages').checked &&
!this.startup_pages_pref_.disabled;
},
@@ -436,7 +432,7 @@ cr.define('options', function() {
* @private
*/
setDefaultSearchEngine_: function() {
- var engineSelect = $('defaultSearchEngine');
+ var engineSelect = $('default-search-engine');
var selectedIndex = engineSelect.selectedIndex;
if (selectedIndex >= 0) {
var selection = engineSelect.options[selectedIndex];
@@ -544,9 +540,8 @@ cr.define('options', function() {
},
setGtkThemeButtonEnabled_: function(enabled) {
- if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) {
+ if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i))
$('themes-GTK-button').disabled = !enabled;
- }
},
setThemesResetButtonEnabled_: function(enabled) {
@@ -555,6 +550,7 @@ cr.define('options', function() {
/**
* (Re)loads IMG element with current user account picture.
+ * @private
*/
updateAccountPicture_: function() {
var picture = $('account-picture');
@@ -621,5 +617,4 @@ cr.define('options', function() {
return {
BrowserOptions: BrowserOptions
};
-
});

Powered by Google App Engine
This is Rietveld 408576698