Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/browser/resources/options/alert_overlay.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh just no Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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');
16 // AlertOverlay is special in that it is not tied to one page or overlay.
17 // Set the nesting level arbitrarily high so as to always be recognized as
18 // the top-most visible page.
19 this.nestingLevelOverride = 99;
15 } 20 }
16 21
17 cr.addSingletonGetter(AlertOverlay); 22 cr.addSingletonGetter(AlertOverlay);
18 23
19 AlertOverlay.prototype = { 24 AlertOverlay.prototype = {
20 // Inherit AlertOverlay from OptionsPage. 25 // Inherit AlertOverlay from Page.
21 __proto__: OptionsPage.prototype, 26 __proto__: Page.prototype,
22 27
23 /** 28 /**
24 * Whether the page can be shown. Used to make sure the page is only 29 * 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. 30 * shown via AlertOverlay.Show(), and not via the address bar.
26 * @private 31 * @private
27 */ 32 */
28 canShow_: false, 33 canShow_: false,
29 34
30 /** @override */ 35 /** @override */
31 initializePage: function() { 36 initializePage: function() {
32 // Call base class implementation to start preference initialization. 37 Page.prototype.initializePage.call(this);
33 OptionsPage.prototype.initializePage.call(this);
34 38
35 var self = this; 39 var self = this;
36 $('alertOverlayOk').onclick = function(event) { 40 $('alertOverlayOk').onclick = function(event) {
37 self.handleOK_(); 41 self.handleOK_();
38 }; 42 };
39 43
40 $('alertOverlayCancel').onclick = function(event) { 44 $('alertOverlayCancel').onclick = function(event) {
41 self.handleCancel_(); 45 self.handleCancel_();
42 }; 46 };
43 }, 47 },
44 48
45 /** @override */
46 get nestingLevel() {
47 // AlertOverlay is special in that it is not tied to one page or overlay.
48 // Set the nesting level arbitrarily high so as to always be recognized as
49 // the top-most visible page.
50 return 99;
51 },
52
53 /** 49 /**
54 * Handle the 'ok' button. Clear the overlay and call the ok callback if 50 * Handle the 'ok' button. Clear the overlay and call the ok callback if
55 * available. 51 * available.
56 * @private 52 * @private
57 */ 53 */
58 handleOK_: function() { 54 handleOK_: function() {
59 OptionsPage.closeOverlay(); 55 PageManager.closeOverlay();
60 if (this.okCallback != undefined) { 56 if (this.okCallback != undefined) {
61 this.okCallback.call(); 57 this.okCallback.call();
62 } 58 }
63 }, 59 },
64 60
65 /** 61 /**
66 * Handle the 'cancel' button. Clear the overlay and call the cancel 62 * Handle the 'cancel' button. Clear the overlay and call the cancel
67 * callback if available. 63 * callback if available.
68 * @private 64 * @private
69 */ 65 */
70 handleCancel_: function() { 66 handleCancel_: function() {
71 OptionsPage.closeOverlay(); 67 PageManager.closeOverlay();
72 if (this.cancelCallback != undefined) { 68 if (this.cancelCallback != undefined) {
73 this.cancelCallback.call(); 69 this.cancelCallback.call();
74 } 70 }
75 }, 71 },
76 72
77 /** 73 /**
78 * The page is getting hidden. Don't let it be shown again. 74 * The page is getting hidden. Don't let it be shown again.
79 * @override 75 * @override
80 */ 76 */
81 willHidePage: function() { 77 willHidePage: function() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 $('alertOverlayCancel').style.display = 'none'; 130 $('alertOverlayCancel').style.display = 'none';
135 } 131 }
136 132
137 var alertOverlay = AlertOverlay.getInstance(); 133 var alertOverlay = AlertOverlay.getInstance();
138 alertOverlay.okCallback = okCallback; 134 alertOverlay.okCallback = okCallback;
139 alertOverlay.cancelCallback = cancelCallback; 135 alertOverlay.cancelCallback = cancelCallback;
140 alertOverlay.canShow_ = true; 136 alertOverlay.canShow_ = true;
141 137
142 // Intentionally don't show the URL in the location bar as we don't want 138 // Intentionally don't show the URL in the location bar as we don't want
143 // people trying to navigate here by hand. 139 // people trying to navigate here by hand.
144 OptionsPage.showPageByName('alertOverlay', false); 140 PageManager.showPageByName('alertOverlay', false);
145 }; 141 };
146 142
147 // Export 143 // Export
148 return { 144 return {
149 AlertOverlay: AlertOverlay 145 AlertOverlay: AlertOverlay
150 }; 146 };
151 }); 147 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/proxy_settings.js ('k') | chrome/browser/resources/options/autofill_edit_address_overlay.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698