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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 /** | 140 /** |
140 * The location where the last touch event happened. This is used to | 141 * The location where the last touch event happened. This is used to |
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 /** @override */ | 148 /** @override */ |
148 initializePage: function() { | 149 initializePage: function() { |
149 OptionsPage.prototype.initializePage.call(this); | 150 Page.prototype.initializePage.call(this); |
150 | 151 |
151 $('display-options-toggle-mirroring').onclick = function() { | 152 $('display-options-toggle-mirroring').onclick = function() { |
152 this.mirroring_ = !this.mirroring_; | 153 this.mirroring_ = !this.mirroring_; |
153 chrome.send('setMirroring', [this.mirroring_]); | 154 chrome.send('setMirroring', [this.mirroring_]); |
154 }.bind(this); | 155 }.bind(this); |
155 | 156 |
156 var container = $('display-options-displays-view-host'); | 157 var container = $('display-options-displays-view-host'); |
157 container.onmousemove = this.onMouseMove_.bind(this); | 158 container.onmousemove = this.onMouseMove_.bind(this); |
158 window.addEventListener('mouseup', this.endDragging_.bind(this), true); | 159 window.addEventListener('mouseup', this.endDragging_.bind(this), true); |
159 container.ontouchmove = this.onTouchMove_.bind(this); | 160 container.ontouchmove = this.onTouchMove_.bind(this); |
(...skipping 18 matching lines...) Expand all Loading... |
178 }.bind(this); | 179 }.bind(this); |
179 $('display-options-color-profile-selection').onchange = function(ev) { | 180 $('display-options-color-profile-selection').onchange = function(ev) { |
180 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, | 181 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, |
181 ev.target.value]); | 182 ev.target.value]); |
182 }.bind(this); | 183 }.bind(this); |
183 $('selected-display-start-calibrating-overscan').onclick = function() { | 184 $('selected-display-start-calibrating-overscan').onclick = function() { |
184 // Passes the target display ID. Do not specify it through URL hash, | 185 // Passes the target display ID. Do not specify it through URL hash, |
185 // we do not care back/forward. | 186 // we do not care back/forward. |
186 var displayOverscan = options.DisplayOverscan.getInstance(); | 187 var displayOverscan = options.DisplayOverscan.getInstance(); |
187 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); | 188 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); |
188 OptionsPage.navigateToPage('displayOverscan'); | 189 PageManager.showPageByName('displayOverscan'); |
189 chrome.send('coreOptionsUserMetricsAction', | 190 chrome.send('coreOptionsUserMetricsAction', |
190 ['Options_DisplaySetOverscan']); | 191 ['Options_DisplaySetOverscan']); |
191 }.bind(this); | 192 }.bind(this); |
192 | 193 |
193 chrome.send('getDisplayInfo'); | 194 chrome.send('getDisplayInfo'); |
194 }, | 195 }, |
195 | 196 |
196 /** @override */ | 197 /** @override */ |
197 didShowPage: function() { | 198 didShowPage: function() { |
198 var optionTitles = document.getElementsByClassName( | 199 var optionTitles = document.getElementsByClassName( |
199 'selected-display-option-title'); | 200 'selected-display-option-title'); |
200 var maxSize = 0; | 201 var maxSize = 0; |
201 for (var i = 0; i < optionTitles.length; i++) | 202 for (var i = 0; i < optionTitles.length; i++) |
202 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); | 203 maxSize = Math.max(maxSize, optionTitles[i].clientWidth); |
203 for (var i = 0; i < optionTitles.length; i++) | 204 for (var i = 0; i < optionTitles.length; i++) |
204 optionTitles[i].style.width = maxSize + 'px'; | 205 optionTitles[i].style.width = maxSize + 'px'; |
205 }, | 206 }, |
206 | 207 |
207 /** @override */ | 208 /** @override */ |
208 onVisibilityChanged_: function() { | 209 onVisibilityChanged_: function() { |
209 OptionsPage.prototype.onVisibilityChanged_(this); | 210 Page.prototype.onVisibilityChanged_(this); |
210 if (this.visible) | 211 if (this.visible) |
211 chrome.send('getDisplayInfo'); | 212 chrome.send('getDisplayInfo'); |
212 }, | 213 }, |
213 | 214 |
214 /** | 215 /** |
215 * Mouse move handler for dragging display rectangle. | 216 * Mouse move handler for dragging display rectangle. |
216 * @param {Event} e The mouse move event. | 217 * @param {Event} e The mouse move event. |
217 * @private | 218 * @private |
218 */ | 219 */ |
219 onMouseMove_: function(e) { | 220 onMouseMove_: function(e) { |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 mirroring, displays, layout, offset) { | 876 mirroring, displays, layout, offset) { |
876 DisplayOptions.getInstance().onDisplayChanged_( | 877 DisplayOptions.getInstance().onDisplayChanged_( |
877 mirroring, displays, layout, offset); | 878 mirroring, displays, layout, offset); |
878 }; | 879 }; |
879 | 880 |
880 // Export | 881 // Export |
881 return { | 882 return { |
882 DisplayOptions: DisplayOptions | 883 DisplayOptions: DisplayOptions |
883 }; | 884 }; |
884 }); | 885 }); |
OLD | NEW |