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 // The scale ratio of the display rectangle to its original size. | 9 // The scale ratio of the display rectangle to its original size. |
9 /** @const */ var VISUAL_SCALE = 1 / 10; | 10 /** @const */ var VISUAL_SCALE = 1 / 10; |
10 | 11 |
11 // The number of pixels to share the edges between displays. | 12 // The number of pixels to share the edges between displays. |
12 /** @const */ var MIN_OFFSET_OVERLAP = 5; | 13 /** @const */ var MIN_OFFSET_OVERLAP = 5; |
13 | 14 |
14 /** | 15 /** |
15 * Enumeration of secondary display layout. The value has to be same as the | 16 * Enumeration of secondary display layout. The value has to be same as the |
16 * values in ash/display/display_controller.cc. | 17 * values in ash/display/display_controller.cc. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 else | 69 else |
69 return SecondaryDisplayLayout.TOP; | 70 return SecondaryDisplayLayout.TOP; |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 /** | 74 /** |
74 * Encapsulated handling of the 'Display' page. | 75 * Encapsulated handling of the 'Display' page. |
75 * @constructor | 76 * @constructor |
76 */ | 77 */ |
77 function DisplayOptions() { | 78 function DisplayOptions() { |
78 OptionsPage.call(this, 'display', | 79 Page.call(this, 'display', |
79 loadTimeData.getString('displayOptionsPageTabTitle'), | 80 loadTimeData.getString('displayOptionsPageTabTitle'), |
80 'display-options-page'); | 81 'display-options-page'); |
81 } | 82 } |
82 | 83 |
83 cr.addSingletonGetter(DisplayOptions); | 84 cr.addSingletonGetter(DisplayOptions); |
84 | 85 |
85 DisplayOptions.prototype = { | 86 DisplayOptions.prototype = { |
86 __proto__: OptionsPage.prototype, | 87 __proto__: Page.prototype, |
87 | 88 |
88 /** | 89 /** |
89 * Whether the current output status is mirroring displays or not. | 90 * Whether the current output status is mirroring displays or not. |
90 * @private | 91 * @private |
91 */ | 92 */ |
92 mirroring_: false, | 93 mirroring_: false, |
93 | 94 |
94 /** | 95 /** |
95 * The current secondary display layout. | 96 * The current secondary display layout. |
96 * @private | 97 * @private |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 * prevent unnecessary dragging events happen. Set to null unless it's | 142 * prevent unnecessary dragging events happen. Set to null unless it's |
142 * during touch events. | 143 * during touch events. |
143 * @private | 144 * @private |
144 */ | 145 */ |
145 lastTouchLocation_: null, | 146 lastTouchLocation_: null, |
146 | 147 |
147 /** | 148 /** |
148 * Initialize the page. | 149 * Initialize the page. |
149 */ | 150 */ |
150 initializePage: function() { | 151 initializePage: function() { |
151 OptionsPage.prototype.initializePage.call(this); | 152 Page.prototype.initializePage.call(this); |
152 | 153 |
153 $('display-options-toggle-mirroring').onclick = function() { | 154 $('display-options-toggle-mirroring').onclick = function() { |
154 this.mirroring_ = !this.mirroring_; | 155 this.mirroring_ = !this.mirroring_; |
155 chrome.send('setMirroring', [this.mirroring_]); | 156 chrome.send('setMirroring', [this.mirroring_]); |
156 }.bind(this); | 157 }.bind(this); |
157 | 158 |
158 var container = $('display-options-displays-view-host'); | 159 var container = $('display-options-displays-view-host'); |
159 container.onmousemove = this.onMouseMove_.bind(this); | 160 container.onmousemove = this.onMouseMove_.bind(this); |
160 window.addEventListener('mouseup', this.endDragging_.bind(this), true); | 161 window.addEventListener('mouseup', this.endDragging_.bind(this), true); |
161 container.ontouchmove = this.onTouchMove_.bind(this); | 162 container.ontouchmove = this.onTouchMove_.bind(this); |
(...skipping 18 matching lines...) Expand all Loading... |
180 }.bind(this); | 181 }.bind(this); |
181 $('display-options-color-profile-selection').onchange = function(ev) { | 182 $('display-options-color-profile-selection').onchange = function(ev) { |
182 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, | 183 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, |
183 ev.target.value]); | 184 ev.target.value]); |
184 }.bind(this); | 185 }.bind(this); |
185 $('selected-display-start-calibrating-overscan').onclick = function() { | 186 $('selected-display-start-calibrating-overscan').onclick = function() { |
186 // Passes the target display ID. Do not specify it through URL hash, | 187 // Passes the target display ID. Do not specify it through URL hash, |
187 // we do not care back/forward. | 188 // we do not care back/forward. |
188 var displayOverscan = options.DisplayOverscan.getInstance(); | 189 var displayOverscan = options.DisplayOverscan.getInstance(); |
189 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); | 190 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); |
190 OptionsPage.navigateToPage('displayOverscan'); | 191 PageManager.showPageByName('displayOverscan'); |
191 chrome.send('coreOptionsUserMetricsAction', | 192 chrome.send('coreOptionsUserMetricsAction', |
192 ['Options_DisplaySetOverscan']); | 193 ['Options_DisplaySetOverscan']); |
193 }.bind(this); | 194 }.bind(this); |
194 | 195 |
195 chrome.send('getDisplayInfo'); | 196 chrome.send('getDisplayInfo'); |
196 }, | 197 }, |
197 | 198 |
198 /** @override */ | 199 /** @override */ |
199 didShowPage: function() { | 200 didShowPage: function() { |
200 var optionTitles = document.getElementsByClassName( | 201 var optionTitles = document.getElementsByClassName( |
201 'selected-display-option-title'); | 202 'selected-display-option-title'); |
202 var maxSize = 0; | 203 var maxSize = 0; |
203 for (var i = 0; i < optionTitles.length; i++) | 204 for (var i = 0; i < optionTitles.length; i++) |
204 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); | 205 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); |
205 for (var i = 0; i < optionTitles.length; i++) | 206 for (var i = 0; i < optionTitles.length; i++) |
206 optionTitles[i].style.width = maxSize + 'px'; | 207 optionTitles[i].style.width = maxSize + 'px'; |
207 }, | 208 }, |
208 | 209 |
209 /** @override */ | 210 /** @override */ |
210 onVisibilityChanged_: function() { | 211 onVisibilityChanged_: function() { |
211 OptionsPage.prototype.onVisibilityChanged_(this); | 212 Page.prototype.onVisibilityChanged_(this); |
212 if (this.visible) | 213 if (this.visible) |
213 chrome.send('getDisplayInfo'); | 214 chrome.send('getDisplayInfo'); |
214 }, | 215 }, |
215 | 216 |
216 /** | 217 /** |
217 * Mouse move handler for dragging display rectangle. | 218 * Mouse move handler for dragging display rectangle. |
218 * @param {Event} e The mouse move event. | 219 * @param {Event} e The mouse move event. |
219 * @private | 220 * @private |
220 */ | 221 */ |
221 onMouseMove_: function(e) { | 222 onMouseMove_: function(e) { |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 mirroring, displays, layout, offset) { | 878 mirroring, displays, layout, offset) { |
878 DisplayOptions.getInstance().onDisplayChanged_( | 879 DisplayOptions.getInstance().onDisplayChanged_( |
879 mirroring, displays, layout, offset); | 880 mirroring, displays, layout, offset); |
880 }; | 881 }; |
881 | 882 |
882 // Export | 883 // Export |
883 return { | 884 return { |
884 DisplayOptions: DisplayOptions | 885 DisplayOptions: DisplayOptions |
885 }; | 886 }; |
886 }); | 887 }); |
OLD | NEW |