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

Side by Side Diff: chrome/browser/resources/options/chromeos/display_overscan.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 * Encapsulated handling of the 'DisplayOverscan' page. 10 * Encapsulated handling of the 'DisplayOverscan' page.
10 * @constructor 11 * @constructor
11 */ 12 */
12 function DisplayOverscan() { 13 function DisplayOverscan() {
13 OptionsPage.call(this, 'displayOverscan', 14 Page.call(this, 'displayOverscan',
14 loadTimeData.getString('displayOverscanPageTabTitle'), 15 loadTimeData.getString('displayOverscanPageTabTitle'),
15 'display-overscan-page'); 16 'display-overscan-page');
16 } 17 }
17 18
18 cr.addSingletonGetter(DisplayOverscan); 19 cr.addSingletonGetter(DisplayOverscan);
19 20
20 DisplayOverscan.prototype = { 21 DisplayOverscan.prototype = {
21 __proto__: OptionsPage.prototype, 22 __proto__: Page.prototype,
22 23
23 /** 24 /**
24 * The ID of the target display. 25 * The ID of the target display.
25 * @private 26 * @private
26 */ 27 */
27 id_: null, 28 id_: null,
28 29
29 /** 30 /**
30 * The keyboard event handler function. 31 * The keyboard event handler function.
31 * @private 32 * @private
32 */ 33 */
33 keyHandler_: null, 34 keyHandler_: null,
34 35
35 /** @override */ 36 /** @override */
36 initializePage: function() { 37 initializePage: function() {
37 OptionsPage.prototype.initializePage.call(this); 38 Page.prototype.initializePage.call(this);
38 39
39 this.keyHandler_ = this.handleKeyevent_.bind(this); 40 this.keyHandler_ = this.handleKeyevent_.bind(this);
40 $('display-overscan-operation-reset').onclick = function() { 41 $('display-overscan-operation-reset').onclick = function() {
41 chrome.send('reset'); 42 chrome.send('reset');
42 }; 43 };
43 $('display-overscan-operation-ok').onclick = function() { 44 $('display-overscan-operation-ok').onclick = function() {
44 chrome.send('commit'); 45 chrome.send('commit');
45 OptionsPage.closeOverlay(); 46 PageManager.closeOverlay();
46 }; 47 };
47 $('display-overscan-operation-cancel').onclick = function() { 48 $('display-overscan-operation-cancel').onclick = function() {
48 OptionsPage.cancelOverlay(); 49 PageManager.cancelOverlay();
49 }; 50 };
50 }, 51 },
51 52
52 /** @override */ 53 /** @override */
53 handleCancel: function() { 54 handleCancel: function() {
54 // signals the cancel event. 55 // signals the cancel event.
55 chrome.send('cancel'); 56 chrome.send('cancel');
56 OptionsPage.closeOverlay(); 57 PageManager.closeOverlay();
57 }, 58 },
58 59
59 /** @override */ 60 /** @override */
60 didShowPage: function() { 61 didShowPage: function() {
61 if (this.id_ == null) { 62 if (this.id_ == null) {
62 OptionsPage.cancelOverlay(); 63 PageManager.cancelOverlay();
63 return; 64 return;
64 } 65 }
65 66
66 window.addEventListener('keydown', this.keyHandler_); 67 window.addEventListener('keydown', this.keyHandler_);
67 // Sets up the size of the overscan dialog based on DisplayOptions dialog. 68 // Sets up the size of the overscan dialog based on DisplayOptions dialog.
68 var displayOptionsPage = $('display-options-page'); 69 var displayOptionsPage = $('display-options-page');
69 var displayOverscanPage = $('display-overscan-page'); 70 var displayOverscanPage = $('display-overscan-page');
70 displayOverscanPage.style.width = 71 displayOverscanPage.style.width =
71 displayOptionsPage.offsetWidth - 20 + 'px'; 72 displayOptionsPage.offsetWidth - 20 + 'px';
72 displayOverscanPage.style.minWidth = displayOverscanPage.style.width; 73 displayOverscanPage.style.minWidth = displayOverscanPage.style.width;
(...skipping 15 matching lines...) Expand all
88 didClosePage: function() { 89 didClosePage: function() {
89 window.removeEventListener('keydown', this.keyHandler_); 90 window.removeEventListener('keydown', this.keyHandler_);
90 }, 91 },
91 92
92 /** 93 /**
93 * Called when the overscan calibration is canceled at the system level, 94 * Called when the overscan calibration is canceled at the system level,
94 * such like the display is disconnected. 95 * such like the display is disconnected.
95 * @private 96 * @private
96 */ 97 */
97 onOverscanCanceled_: function() { 98 onOverscanCanceled_: function() {
98 if (OptionsPage.getTopmostVisiblePage() == this) 99 if (PageManager.getTopmostVisiblePage() == this)
99 OptionsPage.cancelOverlay(); 100 PageManager.cancelOverlay();
100 }, 101 },
101 102
102 /** 103 /**
103 * Sets the target display id. This method has to be called before 104 * Sets the target display id. This method has to be called before
104 * navigating to this page. 105 * navigating to this page.
105 * @param {string} id The target display id. 106 * @param {string} id The target display id.
106 */ 107 */
107 setDisplayId: function(id) { 108 setDisplayId: function(id) {
108 this.id_ = id; 109 this.id_ = id;
109 }, 110 },
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 DisplayOverscan.onOverscanCanceled = function() { 151 DisplayOverscan.onOverscanCanceled = function() {
151 DisplayOverscan.getInstance().onOverscanCanceled_(); 152 DisplayOverscan.getInstance().onOverscanCanceled_();
152 }; 153 };
153 154
154 // Export 155 // Export
155 return { 156 return {
156 DisplayOverscan: DisplayOverscan 157 DisplayOverscan: DisplayOverscan
157 }; 158 };
158 }); 159 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698