OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @fileoverview User pod row implementation. | 6 * @fileoverview User pod row implementation. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('login', function() { | 9 cr.define('login', function() { |
10 /** | 10 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 * @const | 43 * @const |
44 */ | 44 */ |
45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; | 45 var MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER = 2; |
46 | 46 |
47 /** | 47 /** |
48 * Variables used for pod placement processing. Width and height should be | 48 * Variables used for pod placement processing. Width and height should be |
49 * synced with computed CSS sizes of pods. | 49 * synced with computed CSS sizes of pods. |
50 */ | 50 */ |
51 var POD_WIDTH = 180; | 51 var POD_WIDTH = 180; |
52 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; | 52 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; |
53 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; | |
53 var CROS_POD_HEIGHT = 213; | 54 var CROS_POD_HEIGHT = 213; |
54 var DESKTOP_POD_HEIGHT = 226; | 55 var DESKTOP_POD_HEIGHT = 226; |
55 var POD_ROW_PADDING = 10; | 56 var POD_ROW_PADDING = 10; |
56 var DESKTOP_ROW_PADDING = 15; | 57 var DESKTOP_ROW_PADDING = 15; |
57 | 58 |
58 /** | 59 /** |
59 * Minimal padding between user pod and virtual keyboard. | 60 * Minimal padding between user pod and virtual keyboard. |
60 * @type {number} | 61 * @type {number} |
61 * @const | 62 * @const |
62 */ | 63 */ |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 return this.classList.contains('expanded'); | 990 return this.classList.contains('expanded'); |
990 }, | 991 }, |
991 | 992 |
992 set expanded(expanded) { | 993 set expanded(expanded) { |
993 if (this.expanded == expanded) | 994 if (this.expanded == expanded) |
994 return; | 995 return; |
995 | 996 |
996 this.resetTabOrder(); | 997 this.resetTabOrder(); |
997 this.classList.toggle('expanded', expanded); | 998 this.classList.toggle('expanded', expanded); |
998 if (expanded) { | 999 if (expanded) { |
999 var isDesktopUserManager = Oobe.getInstance().displayType == | |
1000 DISPLAY_TYPE.DESKTOP_USER_MANAGER; | |
1001 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : | |
1002 POD_ROW_PADDING; | |
1003 this.usualLeft = this.left; | 1000 this.usualLeft = this.left; |
1004 this.usualTop = this.top; | 1001 this.usualTop = this.top; |
1005 if (this.left + PUBLIC_EXPANDED_BASIC_WIDTH > | 1002 this.makeSpaceForExpandedPod_(); |
1006 $('pod-row').offsetWidth - rowPadding) | |
1007 this.left = $('pod-row').offsetWidth - rowPadding - | |
1008 PUBLIC_EXPANDED_BASIC_WIDTH; | |
1009 } else { | 1003 } else { |
1010 if (typeof(this.usualLeft) != 'undefined') | 1004 if (typeof(this.usualLeft) != 'undefined') |
1011 this.left = this.usualLeft; | 1005 this.left = this.usualLeft; |
1012 if (typeof(this.usualTop) != 'undefined') | 1006 if (typeof(this.usualTop) != 'undefined') |
1013 this.top = this.usualTop; | 1007 this.top = this.usualTop; |
1014 } | 1008 } |
1015 | 1009 |
1016 var self = this; | 1010 var self = this; |
1017 this.classList.add('animating'); | 1011 this.classList.add('animating'); |
1018 this.addEventListener('webkitTransitionEnd', function f(e) { | 1012 this.addEventListener('webkitTransitionEnd', function f(e) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1054 | 1048 |
1055 var learnMore = this.querySelector('.learn-more'); | 1049 var learnMore = this.querySelector('.learn-more'); |
1056 learnMore.addEventListener('mousedown', stopEventPropagation); | 1050 learnMore.addEventListener('mousedown', stopEventPropagation); |
1057 learnMore.addEventListener('click', this.handleLearnMoreEvent); | 1051 learnMore.addEventListener('click', this.handleLearnMoreEvent); |
1058 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); | 1052 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); |
1059 | 1053 |
1060 learnMore = this.querySelector('.expanded-pane-learn-more'); | 1054 learnMore = this.querySelector('.expanded-pane-learn-more'); |
1061 learnMore.addEventListener('click', this.handleLearnMoreEvent); | 1055 learnMore.addEventListener('click', this.handleLearnMoreEvent); |
1062 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); | 1056 learnMore.addEventListener('keydown', this.handleLearnMoreEvent); |
1063 | 1057 |
1058 var languageSelect = this.querySelector('.language-select'); | |
1059 languageSelect.tabIndex = UserPodTabOrder.POD_INPUT; | |
1060 languageSelect.addEventListener('change', function() { | |
1061 chrome.send('getPublicSessionKeyboardLayouts', [ | |
1062 this.user.username, | |
1063 languageSelect.options[languageSelect.selectedIndex].value]); | |
1064 }.bind(this)); | |
1065 | |
1066 this.querySelector('.keyboard-select').tabIndex = | |
1067 UserPodTabOrder.POD_INPUT; | |
1068 | |
1069 var languageAndInput = this.querySelector('.language-and-input'); | |
1070 languageAndInput.tabIndex = UserPodTabOrder.POD_INPUT; | |
1071 languageAndInput.addEventListener('click', | |
1072 this.transitionToAdvanced_.bind(this)); | |
1073 | |
1064 this.enterButtonElement.addEventListener('click', (function(e) { | 1074 this.enterButtonElement.addEventListener('click', (function(e) { |
1065 this.enterButtonElement.disabled = true; | 1075 this.enterButtonElement.disabled = true; |
1066 chrome.send('launchPublicAccount', [this.user.username]); | 1076 chrome.send('launchPublicAccount', [this.user.username]); |
1067 }).bind(this)); | 1077 }).bind(this)); |
1068 }, | 1078 }, |
1069 | 1079 |
1070 /** @override **/ | 1080 /** @override **/ |
1081 initialize: function() { | |
1082 UserPod.prototype.initialize.call(this); | |
1083 | |
1084 var id = this.user.username + '-language'; | |
1085 this.querySelector('.language-select-label').htmlFor = id; | |
1086 var languageSelect = this.querySelector('.language-select'); | |
1087 languageSelect.setAttribute('id', id); | |
1088 var list = this.user.initialLocales; | |
1089 languageSelect.innerHTML = ''; | |
1090 var group = languageSelect; | |
1091 for (var i = 0; i < list.length; ++i) { | |
1092 var item = list[i]; | |
1093 if (item.optionGroupName) { | |
1094 group = document.createElement('optgroup'); | |
1095 group.label = item.optionGroupName; | |
1096 languageSelect.appendChild(group); | |
1097 } else { | |
1098 group.appendChild( | |
1099 new Option(item.title, item.value, item.selected, item.selected)); | |
1100 } | |
1101 } | |
1102 | |
1103 id = this.user.username + '-keyboard'; | |
1104 this.querySelector('.keyboard-select-label').htmlFor = id; | |
1105 this.querySelector('.keyboard-select').setAttribute('id', id); | |
1106 this.populateKeyboardSelect_(this.user.initialKeyboardLayouts); | |
1107 }, | |
1108 | |
1109 /** @override **/ | |
1071 update: function() { | 1110 update: function() { |
1072 UserPod.prototype.update.call(this); | 1111 UserPod.prototype.update.call(this); |
1073 this.querySelector('.expanded-pane-name').textContent = | 1112 this.querySelector('.expanded-pane-name').textContent = |
1074 this.user_.displayName; | 1113 this.user_.displayName; |
1075 this.querySelector('.info').textContent = | 1114 this.querySelector('.info').textContent = |
1076 loadTimeData.getStringF('publicAccountInfoFormat', | 1115 loadTimeData.getStringF('publicAccountInfoFormat', |
1077 this.user_.enterpriseDomain); | 1116 this.user_.enterpriseDomain); |
1078 }, | 1117 }, |
1079 | 1118 |
1080 /** @override */ | 1119 /** @override */ |
1081 focusInput: function() { | 1120 focusInput: function() { |
1082 // Move tabIndex from the whole pod to the main input. | 1121 // Move tabIndex from the whole pod to the main input. |
1083 this.tabIndex = -1; | 1122 this.tabIndex = -1; |
1084 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; | 1123 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; |
1085 this.mainInput.focus(); | 1124 this.mainInput.focus(); |
1086 }, | 1125 }, |
1087 | 1126 |
1088 /** @override */ | 1127 /** @override */ |
1089 reset: function(takeFocus) { | 1128 reset: function(takeFocus) { |
1090 if (!takeFocus) | 1129 if (!takeFocus) |
1091 this.expanded = false; | 1130 this.expanded = false; |
1092 this.enterButtonElement.disabled = false; | 1131 this.enterButtonElement.disabled = false; |
1093 UserPod.prototype.reset.call(this, takeFocus); | 1132 UserPod.prototype.reset.call(this, takeFocus); |
1094 }, | 1133 }, |
1095 | 1134 |
1096 /** @override */ | 1135 /** @override */ |
1097 activate: function(e) { | 1136 activate: function(e) { |
1098 this.expanded = true; | 1137 if (!this.expanded) { |
1099 this.focusInput(); | 1138 this.expanded = true; |
1139 this.focusInput(); | |
1140 } | |
1100 return true; | 1141 return true; |
1101 }, | 1142 }, |
1102 | 1143 |
1103 /** @override */ | 1144 /** @override */ |
1104 handleClickOnPod_: function(e) { | 1145 handleClickOnPod_: function(e) { |
1105 if (this.parentNode.disabled) | 1146 if (this.parentNode.disabled) |
1106 return; | 1147 return; |
1107 | 1148 |
1108 this.parentNode.focusPod(this); | 1149 this.parentNode.focusPod(this); |
1109 this.parentNode.setActivatedPod(this, e); | 1150 this.parentNode.setActivatedPod(this, e); |
(...skipping 21 matching lines...) Expand all Loading... | |
1131 case 32: // Space. | 1172 case 32: // Space. |
1132 break; | 1173 break; |
1133 default: | 1174 default: |
1134 return; | 1175 return; |
1135 } | 1176 } |
1136 break; | 1177 break; |
1137 } | 1178 } |
1138 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); | 1179 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); |
1139 stopEventPropagation(event); | 1180 stopEventPropagation(event); |
1140 }, | 1181 }, |
1182 | |
1183 makeSpaceForExpandedPod_: function() { | |
1184 var width = this.classList.contains('advanced') ? | |
1185 PUBLIC_EXPANDED_ADVANCED_WIDTH : PUBLIC_EXPANDED_BASIC_WIDTH; | |
1186 var isDesktopUserManager = Oobe.getInstance().displayType == | |
1187 DISPLAY_TYPE.DESKTOP_USER_MANAGER; | |
1188 var rowPadding = isDesktopUserManager ? DESKTOP_ROW_PADDING : | |
1189 POD_ROW_PADDING; | |
1190 if (this.left + width > $('pod-row').offsetWidth - rowPadding) | |
1191 this.left = $('pod-row').offsetWidth - rowPadding - width; | |
dzhioev (left Google)
2014/07/21 14:57:48
I can't find where you change 'left' back, when po
dzhioev (left Google)
2014/07/21 14:57:48
If we have a single public pod on screen, it is ex
bartfab (slow)
2014/07/21 16:50:04
I did not change the logic that makes space for ex
bartfab (slow)
2014/07/21 16:50:04
I did not change the logic that preserves the pod'
| |
1192 }, | |
1193 | |
1194 /** | |
1195 * Transition the expanded pod from the basic to the advanced view. | |
1196 */ | |
1197 transitionToAdvanced_: function() { | |
1198 var pod = this; | |
1199 var languageAndInputSection = | |
1200 this.querySelector('.language-and-input-section'); | |
1201 this.classList.add('transitioning-to-advanced'); | |
1202 setTimeout(function() { | |
1203 pod.classList.add('advanced'); | |
1204 pod.makeSpaceForExpandedPod_(); | |
1205 languageAndInputSection.addEventListener('webkitTransitionEnd', | |
dzhioev (left Google)
2014/07/21 14:57:48
Probably you want to add 'ensureTransitionEndEvent
bartfab (slow)
2014/07/21 16:50:04
Ugh. Is that a blink bug or by design?
Either way
Nikita (slow)
2014/07/21 17:08:50
This is by design. https://developer.mozilla.org/e
| |
1206 function observer() { | |
1207 languageAndInputSection.removeEventListener('webkitTransitionEnd', | |
1208 observer); | |
1209 pod.classList.remove('transitioning-to-advanced'); | |
1210 pod.querySelector('.language-select').focus(); | |
1211 }); | |
1212 }, 0); | |
1213 }, | |
1214 | |
1215 /** | |
1216 * Populates the keyboard layout "select" element with a list of layouts. | |
1217 * @param {!Object} list List of available keyboard layouts | |
1218 */ | |
1219 populateKeyboardSelect_: function(list) { | |
1220 var keyboardSelect = this.querySelector('.keyboard-select'); | |
1221 keyboardSelect.innerHTML = ''; | |
1222 for (var i = 0; i < list.length; ++i) { | |
1223 var item = list[i]; | |
1224 keyboardSelect.appendChild( | |
1225 new Option(item.title, item.value, item.selected, item.selected)); | |
1226 } | |
1227 } | |
1141 }; | 1228 }; |
1142 | 1229 |
1143 /** | 1230 /** |
1144 * Creates a user pod to be used only in desktop chrome. | 1231 * Creates a user pod to be used only in desktop chrome. |
1145 * @constructor | 1232 * @constructor |
1146 * @extends {UserPod} | 1233 * @extends {UserPod} |
1147 */ | 1234 */ |
1148 var DesktopUserPod = cr.ui.define(function() { | 1235 var DesktopUserPod = cr.ui.define(function() { |
1149 // Don't just instantiate a UserPod(), as this will call decorate() on the | 1236 // Don't just instantiate a UserPod(), as this will call decorate() on the |
1150 // parent object, and add duplicate event listeners. | 1237 // parent object, and add duplicate event listeners. |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1726 /** @const */ var BUBBLE_OFFSET = 20; | 1813 /** @const */ var BUBBLE_OFFSET = 20; |
1727 /** @const */ var BUBBLE_PADDING = 8; | 1814 /** @const */ var BUBBLE_PADDING = 8; |
1728 $('bubble').showContentForElement(attachElement, | 1815 $('bubble').showContentForElement(attachElement, |
1729 cr.ui.Bubble.Attachment.RIGHT, | 1816 cr.ui.Bubble.Attachment.RIGHT, |
1730 bubbleContent, | 1817 bubbleContent, |
1731 BUBBLE_OFFSET, | 1818 BUBBLE_OFFSET, |
1732 BUBBLE_PADDING); | 1819 BUBBLE_PADDING); |
1733 }, | 1820 }, |
1734 | 1821 |
1735 /** | 1822 /** |
1823 * Updates the list of available keyboard layouts for a public session pod. | |
1824 * @param {string} userID The user ID of the public session | |
1825 * @param {!Object} list List of available keyboard layouts | |
1826 */ | |
1827 setPublicSessionKeyboardLayouts: function(userID, list) { | |
1828 var pod = this.getPodWithUsername_(userID); | |
1829 if (pod != null) | |
1830 pod.populateKeyboardSelect_(list); | |
1831 }, | |
1832 | |
1833 /** | |
1736 * Called when window was resized. | 1834 * Called when window was resized. |
1737 */ | 1835 */ |
1738 onWindowResize: function() { | 1836 onWindowResize: function() { |
1739 var layout = this.calculateLayout_(); | 1837 var layout = this.calculateLayout_(); |
1740 if (layout.columns != this.columns || layout.rows != this.rows) | 1838 if (layout.columns != this.columns || layout.rows != this.rows) |
1741 this.placePods_(); | 1839 this.placePods_(); |
1742 | 1840 |
1743 if (Oobe.getInstance().virtualKeyboardShown) | 1841 if (Oobe.getInstance().virtualKeyboardShown) |
1744 this.scrollFocusedPodIntoView(); | 1842 this.scrollFocusedPodIntoView(); |
1745 }, | 1843 }, |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2293 if (this.podsWithPendingImages_.length == 0) { | 2391 if (this.podsWithPendingImages_.length == 0) { |
2294 this.classList.remove('images-loading'); | 2392 this.classList.remove('images-loading'); |
2295 } | 2393 } |
2296 } | 2394 } |
2297 }; | 2395 }; |
2298 | 2396 |
2299 return { | 2397 return { |
2300 PodRow: PodRow | 2398 PodRow: PodRow |
2301 }; | 2399 }; |
2302 }); | 2400 }); |
OLD | NEW |