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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 /** | 828 /** |
829 * Updates the description of the selected display section. | 829 * Updates the description of the selected display section. |
830 * @private | 830 * @private |
831 */ | 831 */ |
832 updateSelectedDisplayDescription_: function() { | 832 updateSelectedDisplayDescription_: function() { |
833 if (this.focusedIndex_ == null || | 833 if (this.focusedIndex_ == null || |
834 this.displays_[this.focusedIndex_] == null) { | 834 this.displays_[this.focusedIndex_] == null) { |
835 $('selected-display-data-container').hidden = true; | 835 $('selected-display-data-container').hidden = true; |
836 $('display-configuration-arrow').hidden = true; | 836 $('display-configuration-arrow').hidden = true; |
837 $('display-options-set-primary').hidden = true; | 837 $('display-options-set-primary').hidden = true; |
838 $('display-options-toggle-mirroring').hidden = true; | |
839 return; | 838 return; |
840 } | 839 } |
841 | 840 |
842 $('selected-display-data-container').hidden = false; | 841 $('selected-display-data-container').hidden = false; |
843 var display = this.displays_[this.focusedIndex_]; | 842 var display = this.displays_[this.focusedIndex_]; |
844 var nameElement = $('selected-display-name'); | 843 var nameElement = $('selected-display-name'); |
845 while (nameElement.childNodes.length > 0) | 844 while (nameElement.childNodes.length > 0) |
846 nameElement.removeChild(nameElement.firstChild); | 845 nameElement.removeChild(nameElement.firstChild); |
847 nameElement.appendChild(document.createTextNode(display.name)); | 846 nameElement.appendChild(document.createTextNode(display.name)); |
848 | 847 |
(...skipping 18 matching lines...) Expand all Loading... |
867 arrow.hidden = false; | 866 arrow.hidden = false; |
868 // Adding 1 px to the position to fit the border line and the border in | 867 // Adding 1 px to the position to fit the border line and the border in |
869 // arrow precisely. | 868 // arrow precisely. |
870 arrow.style.top = $('display-configurations').offsetTop - | 869 arrow.style.top = $('display-configurations').offsetTop - |
871 arrow.offsetHeight / 2 + 1 + 'px'; | 870 arrow.offsetHeight / 2 + 1 + 'px'; |
872 arrow.style.left = display.div.offsetLeft + display.div.offsetWidth / 2 - | 871 arrow.style.left = display.div.offsetLeft + display.div.offsetWidth / 2 - |
873 arrow.offsetWidth / 2 + 'px'; | 872 arrow.offsetWidth / 2 + 'px'; |
874 | 873 |
875 $('display-options-set-primary').hidden = | 874 $('display-options-set-primary').hidden = |
876 this.displays_[this.focusedIndex_].isPrimary; | 875 this.displays_[this.focusedIndex_].isPrimary; |
877 $('display-options-toggle-mirroring').hidden = | |
878 (this.displays_.length <= 1); | |
879 }, | 876 }, |
880 | 877 |
881 /** | 878 /** |
882 * Clears the drawing area for display rectangles. | 879 * Clears the drawing area for display rectangles. |
883 * @private | 880 * @private |
884 */ | 881 */ |
885 resetDisplaysView_: function() { | 882 resetDisplaysView_: function() { |
886 var displaysViewHost = $('display-options-displays-view-host'); | 883 var displaysViewHost = $('display-options-displays-view-host'); |
887 displaysViewHost.removeChild(displaysViewHost.firstChild); | 884 displaysViewHost.removeChild(displaysViewHost.firstChild); |
888 this.displaysView_ = document.createElement('div'); | 885 this.displaysView_ = document.createElement('div'); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 | 1043 |
1047 /** | 1044 /** |
1048 * Called when the display arrangement has changed. | 1045 * Called when the display arrangement has changed. |
1049 * @param {boolean} mirroring Whether current mode is mirroring or not. | 1046 * @param {boolean} mirroring Whether current mode is mirroring or not. |
1050 * @param {Array} displays The list of the display information. | 1047 * @param {Array} displays The list of the display information. |
1051 * @param {SecondaryDisplayLayout} layout The layout strategy. | 1048 * @param {SecondaryDisplayLayout} layout The layout strategy. |
1052 * @param {number} offset The offset of the secondary display. | 1049 * @param {number} offset The offset of the secondary display. |
1053 * @private | 1050 * @private |
1054 */ | 1051 */ |
1055 onDisplayChanged_: function(mirroring, displays, layout, offset) { | 1052 onDisplayChanged_: function(mirroring, displays, layout, offset) { |
1056 if (displays.length <= 1) { | |
1057 OptionsPage.showDefaultPage(); | |
1058 return; | |
1059 } | |
1060 | |
1061 this.mirroring_ = mirroring; | 1053 this.mirroring_ = mirroring; |
1062 this.layout_ = layout; | 1054 this.layout_ = layout; |
1063 this.offset_ = offset; | 1055 this.offset_ = offset; |
1064 this.dirty_ = false; | 1056 this.dirty_ = false; |
1065 | 1057 |
1066 $('display-options-toggle-mirroring').textContent = | 1058 $('display-options-toggle-mirroring').textContent = |
1067 loadTimeData.getString( | 1059 loadTimeData.getString( |
1068 this.mirroring_ ? 'stopMirroring' : 'startMirroring'); | 1060 this.mirroring_ ? 'stopMirroring' : 'startMirroring'); |
1069 | 1061 |
1070 // Focus to the first display next to the primary one when |displays| list | 1062 // Focus to the first display next to the primary one when |displays| list |
(...skipping 24 matching lines...) Expand all Loading... |
1095 mirroring, displays, layout, offset) { | 1087 mirroring, displays, layout, offset) { |
1096 DisplayOptions.getInstance().onDisplayChanged_( | 1088 DisplayOptions.getInstance().onDisplayChanged_( |
1097 mirroring, displays, layout, offset); | 1089 mirroring, displays, layout, offset); |
1098 }; | 1090 }; |
1099 | 1091 |
1100 // Export | 1092 // Export |
1101 return { | 1093 return { |
1102 DisplayOptions: DisplayOptions | 1094 DisplayOptions: DisplayOptions |
1103 }; | 1095 }; |
1104 }); | 1096 }); |
OLD | NEW |