OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview Base class for dialogs that require saving preferences on | 6 * @fileoverview Base class for dialogs that require saving preferences on |
7 * confirm and resetting preference inputs on cancel. | 7 * confirm and resetting preference inputs on cancel. |
8 */ | 8 */ |
9 | 9 |
10 cr.define('options', function() { | 10 cr.define('options', function() { |
(...skipping 24 matching lines...) Expand all Loading... |
35 initializePage: function() { | 35 initializePage: function() { |
36 this.okButton.onclick = this.handleConfirm_.bind(this); | 36 this.okButton.onclick = this.handleConfirm_.bind(this); |
37 this.cancelButton.onclick = this.handleCancel_.bind(this); | 37 this.cancelButton.onclick = this.handleCancel_.bind(this); |
38 }, | 38 }, |
39 | 39 |
40 /** | 40 /** |
41 * Handles the confirm button by saving the dialog preferences. | 41 * Handles the confirm button by saving the dialog preferences. |
42 * @private | 42 * @private |
43 */ | 43 */ |
44 handleConfirm_: function() { | 44 handleConfirm_: function() { |
45 this.willConfirm(); | |
46 OptionsPage.closeOverlay(); | 45 OptionsPage.closeOverlay(); |
47 | 46 |
48 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); | 47 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); |
49 for (var i = 0; i < els.length; i++) { | 48 for (var i = 0; i < els.length; i++) { |
50 if (els[i].savePrefState) | 49 if (els[i].savePrefState) |
51 els[i].savePrefState(); | 50 els[i].savePrefState(); |
52 } | 51 } |
53 }, | 52 }, |
54 | 53 |
55 /** | 54 /** |
56 * Handles the cancel button by closing the overlay. | 55 * Handles the cancel button by closing the overlay. |
57 * @private | 56 * @private |
58 */ | 57 */ |
59 handleCancel_: function() { | 58 handleCancel_: function() { |
60 this.willCancel(); | |
61 OptionsPage.closeOverlay(); | 59 OptionsPage.closeOverlay(); |
62 | 60 |
63 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); | 61 var els = this.pageDiv.querySelectorAll('[dialog-pref]'); |
64 for (var i = 0; i < els.length; i++) { | 62 for (var i = 0; i < els.length; i++) { |
65 if (els[i].resetPrefState) | 63 if (els[i].resetPrefState) |
66 els[i].resetPrefState(); | 64 els[i].resetPrefState(); |
67 } | 65 } |
68 }, | 66 }, |
69 | |
70 /** | |
71 * Called when the user clicks the confirm button, just before the | |
72 * preferences are saved. This is a no-op, but subclasses can override it. | |
73 */ | |
74 willConfirm: function() {}, | |
75 | |
76 /** | |
77 * Called when the user cancels the dialog, just before the | |
78 * dialog is closed. This is a no-op, but subclasses can override it. | |
79 */ | |
80 willCancel: function() {}, | |
81 }; | 67 }; |
82 | 68 |
83 return { | 69 return { |
84 SettingsDialog: SettingsDialog | 70 SettingsDialog: SettingsDialog |
85 }; | 71 }; |
86 }); | 72 }); |
OLD | NEW |