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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; |
7 | 8 |
8 /** | 9 /** |
9 * AlertOverlay class | 10 * AlertOverlay class |
10 * Encapsulated handling of a generic alert. | 11 * Encapsulated handling of a generic alert. |
11 * @class | 12 * @class |
12 */ | 13 */ |
13 function AlertOverlay() { | 14 function AlertOverlay() { |
14 OptionsPage.call(this, 'alertOverlay', '', 'alertOverlay'); | 15 Page.call(this, 'alertOverlay', '', 'alertOverlay'); |
15 } | 16 } |
16 | 17 |
17 cr.addSingletonGetter(AlertOverlay); | 18 cr.addSingletonGetter(AlertOverlay); |
18 | 19 |
19 AlertOverlay.prototype = { | 20 AlertOverlay.prototype = { |
20 // Inherit AlertOverlay from OptionsPage. | 21 // Inherit AlertOverlay from Page. |
21 __proto__: OptionsPage.prototype, | 22 __proto__: Page.prototype, |
22 | 23 |
23 /** | 24 /** |
24 * Whether the page can be shown. Used to make sure the page is only | 25 * Whether the page can be shown. Used to make sure the page is only |
25 * shown via AlertOverlay.Show(), and not via the address bar. | 26 * shown via AlertOverlay.Show(), and not via the address bar. |
26 * @private | 27 * @private |
27 */ | 28 */ |
28 canShow_: false, | 29 canShow_: false, |
29 | 30 |
30 /** | 31 /** |
31 * Initialize the page. | 32 * Initialize the page. |
32 */ | 33 */ |
33 initializePage: function() { | 34 initializePage: function() { |
34 // Call base class implementation to start preference initialization. | 35 Page.prototype.initializePage.call(this); |
35 OptionsPage.prototype.initializePage.call(this); | |
36 | 36 |
37 var self = this; | 37 var self = this; |
38 $('alertOverlayOk').onclick = function(event) { | 38 $('alertOverlayOk').onclick = function(event) { |
39 self.handleOK_(); | 39 self.handleOK_(); |
40 }; | 40 }; |
41 | 41 |
42 $('alertOverlayCancel').onclick = function(event) { | 42 $('alertOverlayCancel').onclick = function(event) { |
43 self.handleCancel_(); | 43 self.handleCancel_(); |
44 }; | 44 }; |
45 }, | 45 }, |
46 | 46 |
47 /** @override */ | 47 /** @override */ |
48 get nestingLevel() { | 48 get nestingLevel() { |
49 // AlertOverlay is special in that it is not tied to one page or overlay. | 49 // AlertOverlay is special in that it is not tied to one page or overlay. |
50 // Set the nesting level arbitrarily high so as to always be recognized as | 50 // Set the nesting level arbitrarily high so as to always be recognized as |
51 // the top-most visible page. | 51 // the top-most visible page. |
52 return 99; | 52 return 99; |
53 }, | 53 }, |
54 | 54 |
55 /** | 55 /** |
56 * Handle the 'ok' button. Clear the overlay and call the ok callback if | 56 * Handle the 'ok' button. Clear the overlay and call the ok callback if |
57 * available. | 57 * available. |
58 * @private | 58 * @private |
59 */ | 59 */ |
60 handleOK_: function() { | 60 handleOK_: function() { |
61 OptionsPage.closeOverlay(); | 61 PageManager.closeOverlay(); |
62 if (this.okCallback != undefined) { | 62 if (this.okCallback != undefined) { |
63 this.okCallback.call(); | 63 this.okCallback.call(); |
64 } | 64 } |
65 }, | 65 }, |
66 | 66 |
67 /** | 67 /** |
68 * Handle the 'cancel' button. Clear the overlay and call the cancel | 68 * Handle the 'cancel' button. Clear the overlay and call the cancel |
69 * callback if available. | 69 * callback if available. |
70 * @private | 70 * @private |
71 */ | 71 */ |
72 handleCancel_: function() { | 72 handleCancel_: function() { |
73 OptionsPage.closeOverlay(); | 73 PageManager.closeOverlay(); |
74 if (this.cancelCallback != undefined) { | 74 if (this.cancelCallback != undefined) { |
75 this.cancelCallback.call(); | 75 this.cancelCallback.call(); |
76 } | 76 } |
77 }, | 77 }, |
78 | 78 |
79 /** | 79 /** |
80 * The page is getting hidden. Don't let it be shown again. | 80 * The page is getting hidden. Don't let it be shown again. |
81 */ | 81 */ |
82 willHidePage: function() { | 82 willHidePage: function() { |
83 canShow_ = false; | 83 canShow_ = false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 $('alertOverlayCancel').style.display = 'none'; | 135 $('alertOverlayCancel').style.display = 'none'; |
136 } | 136 } |
137 | 137 |
138 var alertOverlay = AlertOverlay.getInstance(); | 138 var alertOverlay = AlertOverlay.getInstance(); |
139 alertOverlay.okCallback = okCallback; | 139 alertOverlay.okCallback = okCallback; |
140 alertOverlay.cancelCallback = cancelCallback; | 140 alertOverlay.cancelCallback = cancelCallback; |
141 alertOverlay.canShow_ = true; | 141 alertOverlay.canShow_ = true; |
142 | 142 |
143 // Intentionally don't show the URL in the location bar as we don't want | 143 // Intentionally don't show the URL in the location bar as we don't want |
144 // people trying to navigate here by hand. | 144 // people trying to navigate here by hand. |
145 OptionsPage.showPageByName('alertOverlay', false); | 145 PageManager.showPageByName('alertOverlay', false); |
146 }; | 146 }; |
147 | 147 |
148 // Export | 148 // Export |
149 return { | 149 return { |
150 AlertOverlay: AlertOverlay | 150 AlertOverlay: AlertOverlay |
151 }; | 151 }; |
152 }); | 152 }); |
OLD | NEW |