| 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 Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 8 |
| 9 // The scale ratio of the display rectangle to its original size. | 9 // The scale ratio of the display rectangle to its original size. |
| 10 /** @const */ var VISUAL_SCALE = 1 / 10; | 10 /** @const */ var VISUAL_SCALE = 1 / 10; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 * prevent unnecessary dragging events happen. Set to null unless it's | 142 * prevent unnecessary dragging events happen. Set to null unless it's |
| 143 * during touch events. | 143 * during touch events. |
| 144 * @private | 144 * @private |
| 145 */ | 145 */ |
| 146 lastTouchLocation_: null, | 146 lastTouchLocation_: null, |
| 147 | 147 |
| 148 /** @override */ | 148 /** @override */ |
| 149 initializePage: function() { | 149 initializePage: function() { |
| 150 Page.prototype.initializePage.call(this); | 150 Page.prototype.initializePage.call(this); |
| 151 | 151 |
| 152 $('display-options-toggle-mirroring').onclick = function() { | 152 $('display-options-toggle-mirroring').onclick = (function() { |
| 153 this.mirroring_ = !this.mirroring_; | 153 this.mirroring_ = !this.mirroring_; |
| 154 chrome.send('setMirroring', [this.mirroring_]); | 154 chrome.send('setMirroring', [this.mirroring_]); |
| 155 }.bind(this); | 155 }).bind(this); |
| 156 | 156 |
| 157 var container = $('display-options-displays-view-host'); | 157 var container = $('display-options-displays-view-host'); |
| 158 container.onmousemove = this.onMouseMove_.bind(this); | 158 container.onmousemove = this.onMouseMove_.bind(this); |
| 159 window.addEventListener('mouseup', this.endDragging_.bind(this), true); | 159 window.addEventListener('mouseup', this.endDragging_.bind(this), true); |
| 160 container.ontouchmove = this.onTouchMove_.bind(this); | 160 container.ontouchmove = this.onTouchMove_.bind(this); |
| 161 container.ontouchend = this.endDragging_.bind(this); | 161 container.ontouchend = this.endDragging_.bind(this); |
| 162 | 162 |
| 163 $('display-options-set-primary').onclick = function() { | 163 $('display-options-set-primary').onclick = (function() { |
| 164 chrome.send('setPrimary', [this.displays_[this.focusedIndex_].id]); | 164 chrome.send('setPrimary', [this.displays_[this.focusedIndex_].id]); |
| 165 }.bind(this); | 165 }).bind(this); |
| 166 $('display-options-resolution-selection').onchange = function(ev) { | 166 $('display-options-resolution-selection').onchange = (function(ev) { |
| 167 var display = this.displays_[this.focusedIndex_]; | 167 var display = this.displays_[this.focusedIndex_]; |
| 168 var resolution = display.resolutions[ev.target.value]; | 168 var resolution = display.resolutions[ev.target.value]; |
| 169 if (resolution.scale) { | 169 chrome.send('setDisplayMode', [display.id, resolution]); |
| 170 chrome.send('setUIScale', [display.id, resolution.scale]); | 170 }).bind(this); |
| 171 } else { | 171 $('display-options-orientation-selection').onchange = (function(ev) { |
| 172 chrome.send('setResolution', | |
| 173 [display.id, resolution.width, resolution.height]); | |
| 174 } | |
| 175 }.bind(this); | |
| 176 $('display-options-orientation-selection').onchange = function(ev) { | |
| 177 chrome.send('setOrientation', [this.displays_[this.focusedIndex_].id, | 172 chrome.send('setOrientation', [this.displays_[this.focusedIndex_].id, |
| 178 ev.target.value]); | 173 ev.target.value]); |
| 179 }.bind(this); | 174 }).bind(this); |
| 180 $('display-options-color-profile-selection').onchange = function(ev) { | 175 $('display-options-color-profile-selection').onchange = (function(ev) { |
| 181 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, | 176 chrome.send('setColorProfile', [this.displays_[this.focusedIndex_].id, |
| 182 ev.target.value]); | 177 ev.target.value]); |
| 183 }.bind(this); | 178 }).bind(this); |
| 184 $('selected-display-start-calibrating-overscan').onclick = function() { | 179 $('selected-display-start-calibrating-overscan').onclick = (function() { |
| 185 // Passes the target display ID. Do not specify it through URL hash, | 180 // Passes the target display ID. Do not specify it through URL hash, |
| 186 // we do not care back/forward. | 181 // we do not care back/forward. |
| 187 var displayOverscan = options.DisplayOverscan.getInstance(); | 182 var displayOverscan = options.DisplayOverscan.getInstance(); |
| 188 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); | 183 displayOverscan.setDisplayId(this.displays_[this.focusedIndex_].id); |
| 189 PageManager.showPageByName('displayOverscan'); | 184 PageManager.showPageByName('displayOverscan'); |
| 190 chrome.send('coreOptionsUserMetricsAction', | 185 chrome.send('coreOptionsUserMetricsAction', |
| 191 ['Options_DisplaySetOverscan']); | 186 ['Options_DisplaySetOverscan']); |
| 192 }.bind(this); | 187 }).bind(this); |
| 193 | 188 |
| 194 chrome.send('getDisplayInfo'); | 189 chrome.send('getDisplayInfo'); |
| 195 }, | 190 }, |
| 196 | 191 |
| 197 /** @override */ | 192 /** @override */ |
| 198 didShowPage: function() { | 193 didShowPage: function() { |
| 199 var optionTitles = document.getElementsByClassName( | 194 var optionTitles = document.getElementsByClassName( |
| 200 'selected-display-option-title'); | 195 'selected-display-option-title'); |
| 201 var maxSize = 0; | 196 var maxSize = 0; |
| 202 for (var i = 0; i < optionTitles.length; i++) | 197 for (var i = 0; i < optionTitles.length; i++) |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 607 |
| 613 var resolution = $('display-options-resolution-selection'); | 608 var resolution = $('display-options-resolution-selection'); |
| 614 if (display.resolutions.length <= 1) { | 609 if (display.resolutions.length <= 1) { |
| 615 var option = document.createElement('option'); | 610 var option = document.createElement('option'); |
| 616 option.value = 'default'; | 611 option.value = 'default'; |
| 617 option.textContent = display.width + 'x' + display.height; | 612 option.textContent = display.width + 'x' + display.height; |
| 618 option.selected = true; | 613 option.selected = true; |
| 619 resolution.appendChild(option); | 614 resolution.appendChild(option); |
| 620 resolution.disabled = true; | 615 resolution.disabled = true; |
| 621 } else { | 616 } else { |
| 617 var previousOption; |
| 622 for (var i = 0; i < display.resolutions.length; i++) { | 618 for (var i = 0; i < display.resolutions.length; i++) { |
| 623 var option = document.createElement('option'); | 619 var option = document.createElement('option'); |
| 624 option.value = i; | 620 option.value = i; |
| 625 option.textContent = display.resolutions[i].width + 'x' + | 621 option.textContent = display.resolutions[i].width + 'x' + |
| 626 display.resolutions[i].height; | 622 display.resolutions[i].height; |
| 627 if (display.resolutions[i].isBest) { | 623 if (display.resolutions[i].isBest) { |
| 628 option.textContent += ' ' + | 624 option.textContent += ' ' + |
| 629 loadTimeData.getString('annotateBest'); | 625 loadTimeData.getString('annotateBest'); |
| 630 } | 626 } |
| 627 if (display.resolutions[i].deviceScaleFactor && previousOption && |
| 628 previousOption.textContent == option.textContent) { |
| 629 option.textContent += |
| 630 ' (' + display.resolutions[i].deviceScaleFactor + 'x)'; |
| 631 } |
| 631 option.selected = display.resolutions[i].selected; | 632 option.selected = display.resolutions[i].selected; |
| 632 resolution.appendChild(option); | 633 resolution.appendChild(option); |
| 634 previousOption = option; |
| 633 } | 635 } |
| 634 resolution.disabled = (display.resolutions.length <= 1); | 636 resolution.disabled = (display.resolutions.length <= 1); |
| 635 } | 637 } |
| 636 | 638 |
| 637 if (display.availableColorProfiles.length <= 1) { | 639 if (display.availableColorProfiles.length <= 1) { |
| 638 $('selected-display-color-profile-row').hidden = true; | 640 $('selected-display-color-profile-row').hidden = true; |
| 639 } else { | 641 } else { |
| 640 $('selected-display-color-profile-row').hidden = false; | 642 $('selected-display-color-profile-row').hidden = false; |
| 641 var profiles = $('display-options-color-profile-selection'); | 643 var profiles = $('display-options-color-profile-selection'); |
| 642 profiles.innerHTML = ''; | 644 profiles.innerHTML = ''; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 mirroring, displays, layout, offset) { | 878 mirroring, displays, layout, offset) { |
| 877 DisplayOptions.getInstance().onDisplayChanged_( | 879 DisplayOptions.getInstance().onDisplayChanged_( |
| 878 mirroring, displays, layout, offset); | 880 mirroring, displays, layout, offset); |
| 879 }; | 881 }; |
| 880 | 882 |
| 881 // Export | 883 // Export |
| 882 return { | 884 return { |
| 883 DisplayOptions: DisplayOptions | 885 DisplayOptions: DisplayOptions |
| 884 }; | 886 }; |
| 885 }); | 887 }); |
| OLD | NEW |