OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 ConfirmDialog = options.ConfirmDialog; | 6 /** @const */ var ConfirmDialog = options.ConfirmDialog; |
7 /** @const */ var SettingsDialog = options.SettingsDialog; | 7 /** @const */ var SettingsDialog = options.SettingsDialog; |
8 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 8 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
9 | 9 |
10 /** | 10 /** |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * Pop up the dialog if there are no errors from the indicator or commit the | 42 * Pop up the dialog if there are no errors from the indicator or commit the |
43 * change, depending on whether confirmation is needed. | 43 * change, depending on whether confirmation is needed. |
44 * @param {Event} event Change event. | 44 * @param {Event} event Change event. |
45 * @private | 45 * @private |
46 */ | 46 */ |
47 onPrefChanged_: function(event) { | 47 onPrefChanged_: function(event) { |
48 if (!event.value.uncommitted) | 48 if (!event.value.uncommitted) |
49 return; | 49 return; |
50 | 50 |
51 if (event.value.value && !this.confirmed_) { | 51 if (event.value.value && !this.confirmed_) { |
52 if (!this.indicator.errorText) { | 52 // If there is an error, show the indicator icon with more information. |
53 PageManager.showPageByName(this.name, false); | 53 if (this.indicator.errorText) |
54 } else { | |
55 this.indicator.updateBasedOnError(); | 54 this.indicator.updateBasedOnError(); |
56 this.handleCancel(); | 55 |
57 } | 56 // Show confirmation dialog (regardless of whether there is an error). |
| 57 PageManager.showPageByName(this.name, false); |
58 } else { | 58 } else { |
59 Preferences.getInstance().commitPref(this.pref, this.metric); | 59 Preferences.getInstance().commitPref(this.pref, this.metric); |
60 } | 60 } |
61 }, | 61 }, |
62 | 62 |
63 /** | 63 /** |
64 * Override the initializePage function so that an updated version of | 64 * Override the initializePage function so that an updated version of |
65 * onPrefChanged_ can be used. | 65 * onPrefChanged_ can be used. |
66 * @override | 66 * @override |
67 */ | 67 */ |
68 initializePage: function() { | 68 initializePage: function() { |
69 SettingsDialog.prototype.initializePage.call(this); | 69 SettingsDialog.prototype.initializePage.call(this); |
70 | 70 |
71 this.okButton.onclick = this.handleConfirm.bind(this); | 71 this.okButton.onclick = this.handleConfirm.bind(this); |
72 this.cancelButton.onclick = this.handleCancel.bind(this); | 72 this.cancelButton.onclick = this.handleCancel.bind(this); |
73 Preferences.getInstance().addEventListener( | 73 Preferences.getInstance().addEventListener( |
74 this.pref, this.onPrefChanged_.bind(this)); | 74 this.pref, this.onPrefChanged_.bind(this)); |
75 } | 75 } |
76 }; | 76 }; |
77 | 77 |
78 return { | 78 return { |
79 HotwordConfirmDialog: HotwordConfirmDialog | 79 HotwordConfirmDialog: HotwordConfirmDialog |
80 }; | 80 }; |
81 }); | 81 }); |
OLD | NEW |