| 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 OptionsPage = options.OptionsPage; | 8 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * A dialog that will pop up when the user attempts to set the value of the | 11 * A dialog that will pop up when the user attempts to set the value of the |
| 12 * Boolean |pref| to |true|, asking for confirmation. It will first check for | 12 * Boolean |pref| to |true|, asking for confirmation. It will first check for |
| 13 * any errors and if any exist, not display the dialog but toggle the | 13 * any errors and if any exist, not display the dialog but toggle the |
| 14 * indicator. Like its superclass, if the user clicks OK, the new value is | 14 * indicator. Like its superclass, if the user clicks OK, the new value is |
| 15 * committed to Chrome. If the user clicks Cancel or leaves the settings page, | 15 * committed to Chrome. If the user clicks Cancel or leaves the settings page, |
| 16 * the new value is discarded. | 16 * the new value is discarded. |
| 17 * @constructor | 17 * @constructor |
| 18 * @extends {ConfirmDialog} | 18 * @extends {ConfirmDialog} |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 * change, depending on whether confirmation is needed. | 41 * change, depending on whether confirmation is needed. |
| 42 * @param {Event} event Change event. | 42 * @param {Event} event Change event. |
| 43 * @private | 43 * @private |
| 44 */ | 44 */ |
| 45 onPrefChanged_: function(event) { | 45 onPrefChanged_: function(event) { |
| 46 if (!event.value.uncommitted) | 46 if (!event.value.uncommitted) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 if (event.value.value && !this.confirmed_) { | 49 if (event.value.value && !this.confirmed_) { |
| 50 if (!this.indicator.errorText) { | 50 if (!this.indicator.errorText) { |
| 51 OptionsPage.showPageByName(this.name, false); | 51 PageManager.showPageByName(this.name, false); |
| 52 } else { | 52 } else { |
| 53 this.indicator.updateBasedOnError(); | 53 this.indicator.updateBasedOnError(); |
| 54 this.handleCancel(); | 54 this.handleCancel(); |
| 55 } | 55 } |
| 56 } else { | 56 } else { |
| 57 Preferences.getInstance().commitPref(this.pref, this.metric); | 57 Preferences.getInstance().commitPref(this.pref, this.metric); |
| 58 } | 58 } |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Override the initializePage function so that an updated version of | 62 * Override the initializePage function so that an updated version of |
| 63 * onPrefChanged_ can be used. | 63 * onPrefChanged_ can be used. |
| 64 * @override */ | 64 * @override */ |
| 65 initializePage: function() { | 65 initializePage: function() { |
| 66 SettingsDialog.prototype.initializePage.call(this); | 66 SettingsDialog.prototype.initializePage.call(this); |
| 67 | 67 |
| 68 this.okButton.onclick = this.handleConfirm.bind(this); | 68 this.okButton.onclick = this.handleConfirm.bind(this); |
| 69 this.cancelButton.onclick = this.handleCancel.bind(this); | 69 this.cancelButton.onclick = this.handleCancel.bind(this); |
| 70 Preferences.getInstance().addEventListener( | 70 Preferences.getInstance().addEventListener( |
| 71 this.pref, this.onPrefChanged_.bind(this)); | 71 this.pref, this.onPrefChanged_.bind(this)); |
| 72 } | 72 } |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 return { | 75 return { |
| 76 HotwordConfirmDialog: HotwordConfirmDialog | 76 HotwordConfirmDialog: HotwordConfirmDialog |
| 77 }; | 77 }; |
| 78 }); | 78 }); |
| OLD | NEW |