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

Unified Diff: chrome/browser/resources/options/chromeos/internet_detail.js

Issue 8815014: Add support for recommended settings to the internet details dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years 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
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/internet_options.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/chromeos/internet_detail.js
diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js
index 5fb1e4e14bc8334612620393a2c9a6dd6151174b..2b13ecee7428500e7abef5aafcf5e7be6fc3639d 100644
--- a/chrome/browser/resources/options/chromeos/internet_detail.js
+++ b/chrome/browser/resources/options/chromeos/internet_detail.js
@@ -41,6 +41,70 @@ cr.define('options.internet', function() {
},
/**
+ * Initializes the controlled setting indicators for the page.
+ * @param {Object} data Dictionary with metadata about the settings.
+ */
+ initializeControlledSettingIndicators: function(data) {
+ indicators =
+ this.pageDiv.querySelectorAll('.controlled-setting-indicator');
+ for (var i = 0; i < indicators.length; i++) {
+ var dataProperty = indicators[i].getAttribute('data');
+ if (dataProperty && data[dataProperty]) {
+ this.initializeIndicator_(indicators[i],
+ data[dataProperty].controlledBy,
+ data[dataProperty].default);
+ }
+ }
+ },
+
+ /**
+ * Sets up a single controlled setting indicator, setting the controlledBy
+ * property and an event handler for resetting to the default value if
+ * appropriate.
+ * @param {Object} indicator The indicator element.
+ * @param {string} controlledBy The entity that controls the setting.
+ * @param {Object} defaultValue The default value to reset to, if
+ * applicable.
+ */
+ initializeIndicator_ : function(indicator, controlledBy, defaultValue) {
+ var forElement = $(indicator.getAttribute('for'));
+ var recommended = controlledBy == 'recommended';
+ if (!controlledBy || (recommended && !defaultValue))
+ controlledBy = null;
+
+ indicator.controlledBy = controlledBy;
+
+ if (forElement) {
+ forElement.disabled = !recommended;
+
+ // Special handling for radio buttons:
+ // - If the setting is recommended, show the recommended indicator
+ // next to the choice that is recommended.
+ // - Else, show the indicator next to the selected choice.
+ if (forElement.type == 'radio') {
+ if (recommended)
+ indicator.hidden = (defaultValue != forElement.value);
+ else
+ indicator.hidden = !forElement.checked;
+ }
+
+ indicator.setAttribute('allow-reset');
+ indicator.addEventListener(
+ 'reset',
+ function(element, e) {
+ if (forElement.type == 'radio' || forElement.type == 'checkbox') {
+ // The recommended setting indicator is always shown next to
+ // the recommended choice.
+ forElement.checked = true;
+ } else {
+ forElement.value = defaultValue;
+ }
+ e.preventDefault();
+ });
+ }
+ },
+
+ /**
* Update details page controls.
* @private
*/
« no previous file with comments | « no previous file | chrome/browser/resources/options/chromeos/internet_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698