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