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 24 matching lines...) Expand all Loading... |
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 (!this.indicator.errorText) { |
53 OptionsPage.showPageByName(this.name, false); | 53 PageManager.showPageByName(this.name, false); |
54 } else { | 54 } else { |
55 this.indicator.updateBasedOnError(); | 55 this.indicator.updateBasedOnError(); |
56 this.handleCancel(); | 56 this.handleCancel(); |
57 } | 57 } |
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 |