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

Side by Side Diff: chrome/browser/resources/settings/controls/controlled_radio_button.js

Issue 2210063002: MD Settings: add a <controlled-radio-button> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove radio-group tests Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer({ 5 Polymer({
6 is: 'controlled-button', 6 is: 'controlled-radio-button',
7 7
8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], 8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior],
9 9
10 properties: { 10 properties: {
11 name: {
12 type: String,
13 notify: true,
14 },
15
11 /** @private */ 16 /** @private */
12 controlled_: { 17 controlled_: {
13 type: Boolean, 18 type: Boolean,
14 computed: 'computeControlled_(pref)', 19 computed: 'computeControlled_(pref)',
15 reflectToAttribute: true, 20 reflectToAttribute: true,
16 }, 21 },
17 }, 22 },
18 23
19 /** 24 /**
20 * @param {!chrome.settingsPrivate.PrefObject} pref 25 * @param {chrome.settingsPrivate.PrefObject} pref
21 * @return {boolean} Whether the button is disabled. 26 * @return {boolean} Whether the button is disabled.
22 * @private 27 * @private
23 */ 28 */
24 computeControlled_: function(pref) { 29 computeControlled_: function(pref) {
30 var pref = /** @type {!chrome.settingsPrivate.PrefObject} */(this.pref);
25 return this.isPrefPolicyControlled(pref); 31 return this.isPrefPolicyControlled(pref);
26 }, 32 },
27 33
28 /** 34 /**
35 * @param {boolean} controlled
36 * @param {string} name
37 * @param {chrome.settingsPrivate.PrefObject} pref
38 * @return {boolean}
39 * @private
40 */
41 showIndicator_: function(controlled, name, pref) {
42 return controlled && name == Settings.PrefUtil.prefToString(pref);
43 },
44
45 /**
29 * @param {!Event} e 46 * @param {!Event} e
30 * @private 47 * @private
31 */ 48 */
32 onIndicatorTap_: function(e) { 49 onIndicatorTap_: function(e) {
33 // Disallow <controlled-button on-tap="..."> when controlled. 50 // Disallow <controlled-radio-button on-tap="..."> when controlled.
34 e.preventDefault(); 51 e.preventDefault();
35 e.stopPropagation(); 52 e.stopPropagation();
36 }, 53 },
37 }); 54 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698