Commit 87b762f2 authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

DOMUI: Use dispatchSimpleEvent instead of programatically clicking the checkbox

to notify the control that the checked state has changed.

BUG=69613
TEST=none

Review URL: http://codereview.chromium.org/6285003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71973 0039d316-1c4b-4281-b951-d872f2087c98
parent 82aff3f9
...@@ -100,15 +100,21 @@ cr.define('options', function() { ...@@ -100,15 +100,21 @@ cr.define('options', function() {
var idx = $('sync-select').selectedIndex; var idx = $('sync-select').selectedIndex;
var syncCheckboxes = $('sync-table').getElementsByTagName('input'); var syncCheckboxes = $('sync-table').getElementsByTagName('input');
if (idx == 0) { if (idx == 0) {
// 'Choose what to sync.'
for (var i = 0; i < syncCheckboxes.length; i++) { for (var i = 0; i < syncCheckboxes.length; i++) {
syncCheckboxes[i].disabled = false; syncCheckboxes[i].disabled = false;
} }
} else if (idx == 1) { } else if (idx == 1) {
// 'Everything' is synced.
for (var i = 0; i < syncCheckboxes.length; i++) { for (var i = 0; i < syncCheckboxes.length; i++) {
if (!syncCheckboxes[i].checked) {
syncCheckboxes[i].checked = true;
// Merely setting checked = true is not enough to trigger the pref // Merely setting checked = true is not enough to trigger the pref
// being set; thus, we simulate the click. // being set; thus, we dispatch a change event to notify
if (!syncCheckboxes[i].checked) // PrefCheckbox |checked| has changed.
syncCheckboxes[i].click(); cr.dispatchSimpleEvent(syncCheckboxes[i], 'change');
}
syncCheckboxes[i].disabled = true; syncCheckboxes[i].disabled = true;
} }
......
...@@ -50,7 +50,7 @@ cr.define('options', function() { ...@@ -50,7 +50,7 @@ cr.define('options', function() {
// Listen to user events. // Listen to user events.
this.addEventListener( this.addEventListener(
'click', 'change',
function(e) { function(e) {
var value = self.inverted_pref ? !self.checked : self.checked; var value = self.inverted_pref ? !self.checked : self.checked;
switch(self.valueType) { switch(self.valueType) {
...@@ -72,7 +72,7 @@ cr.define('options', function() { ...@@ -72,7 +72,7 @@ cr.define('options', function() {
*/ */
initializeValueType: function(valueType) { initializeValueType: function(valueType) {
this.valueType = valueType || 'boolean'; this.valueType = valueType || 'boolean';
} },
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment