| 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 /** | 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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 // Activated pod, i.e. the pod of current login attempt. | 1169 // Activated pod, i.e. the pod of current login attempt. |
| 1170 activatedPod_: undefined, | 1170 activatedPod_: undefined, |
| 1171 | 1171 |
| 1172 // Pod that was most recently focused, if any. | 1172 // Pod that was most recently focused, if any. |
| 1173 lastFocusedPod_: undefined, | 1173 lastFocusedPod_: undefined, |
| 1174 | 1174 |
| 1175 // Pods whose initial images haven't been loaded yet. | 1175 // Pods whose initial images haven't been loaded yet. |
| 1176 podsWithPendingImages_: [], | 1176 podsWithPendingImages_: [], |
| 1177 | 1177 |
| 1178 // Whether pod creation is animated. | 1178 // Whether pod creation is animated. |
| 1179 user_add_is_animated_: false, | 1179 userAddIsAnimated_: false, |
| 1180 |
| 1181 // Whether pod placement has been postponed. |
| 1182 podPlacementPostponed_: false, |
| 1180 | 1183 |
| 1181 // Array of apps that are shown in addition to other user pods. | 1184 // Array of apps that are shown in addition to other user pods. |
| 1182 apps_: [], | 1185 apps_: [], |
| 1183 | 1186 |
| 1184 // Array of users that are shown (public/supervised/regular). | 1187 // Array of users that are shown (public/supervised/regular). |
| 1185 users_: [], | 1188 users_: [], |
| 1186 | 1189 |
| 1187 /** @override */ | 1190 /** @override */ |
| 1188 decorate: function() { | 1191 decorate: function() { |
| 1189 // Event listeners that are installed for the time period during which | 1192 // Event listeners that are installed for the time period during which |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 } | 1368 } |
| 1366 }, | 1369 }, |
| 1367 | 1370 |
| 1368 /** | 1371 /** |
| 1369 * Populates pod row with given existing users and start init animation. | 1372 * Populates pod row with given existing users and start init animation. |
| 1370 * @param {array} users Array of existing user emails. | 1373 * @param {array} users Array of existing user emails. |
| 1371 * @param {boolean} animated Whether to use init animation. | 1374 * @param {boolean} animated Whether to use init animation. |
| 1372 */ | 1375 */ |
| 1373 loadPods: function(users, animated) { | 1376 loadPods: function(users, animated) { |
| 1374 this.users_ = users; | 1377 this.users_ = users; |
| 1375 this.user_add_is_animated_ = animated; | 1378 this.userAddIsAnimated_ = animated; |
| 1376 | 1379 |
| 1377 this.rebuildPods(); | 1380 this.rebuildPods(); |
| 1378 }, | 1381 }, |
| 1379 | 1382 |
| 1380 /** | 1383 /** |
| 1381 * Rebuilds pod row using users_ and apps_ that were previously set or | 1384 * Rebuilds pod row using users_ and apps_ that were previously set or |
| 1382 * updated. | 1385 * updated. |
| 1383 */ | 1386 */ |
| 1384 rebuildPods: function() { | 1387 rebuildPods: function() { |
| 1388 var emptyPodRow = this.pods.length == 0; |
| 1389 |
| 1385 // Clear existing pods. | 1390 // Clear existing pods. |
| 1386 this.innerHTML = ''; | 1391 this.innerHTML = ''; |
| 1387 this.focusedPod_ = undefined; | 1392 this.focusedPod_ = undefined; |
| 1388 this.activatedPod_ = undefined; | 1393 this.activatedPod_ = undefined; |
| 1389 this.lastFocusedPod_ = undefined; | 1394 this.lastFocusedPod_ = undefined; |
| 1390 | 1395 |
| 1391 // Switch off animation | 1396 // Switch off animation |
| 1392 Oobe.getInstance().toggleClass('flying-pods', false); | 1397 Oobe.getInstance().toggleClass('flying-pods', false); |
| 1393 | 1398 |
| 1394 // Populate the pod row. | 1399 // Populate the pod row. |
| 1395 for (var i = 0; i < this.users_.length; ++i) | 1400 for (var i = 0; i < this.users_.length; ++i) |
| 1396 this.addUserPod(this.users_[i], this.user_add_is_animated_); | 1401 this.addUserPod(this.users_[i], this.userAddIsAnimated_); |
| 1397 | 1402 |
| 1398 for (var i = 0, pod; pod = this.pods[i]; ++i) | 1403 for (var i = 0, pod; pod = this.pods[i]; ++i) |
| 1399 this.podsWithPendingImages_.push(pod); | 1404 this.podsWithPendingImages_.push(pod); |
| 1400 | 1405 |
| 1401 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting. | 1406 // TODO(nkostylev): Edge case handling when kiosk apps are not fitting. |
| 1402 for (var i = 0; i < this.apps_.length; ++i) | 1407 for (var i = 0; i < this.apps_.length; ++i) |
| 1403 this.addUserPod(this.apps_[i], this.user_add_is_animated_); | 1408 this.addUserPod(this.apps_[i], this.userAddIsAnimated_); |
| 1404 | 1409 |
| 1405 // Make sure we eventually show the pod row, even if some image is stuck. | 1410 // Make sure we eventually show the pod row, even if some image is stuck. |
| 1406 setTimeout(function() { | 1411 setTimeout(function() { |
| 1407 $('pod-row').classList.remove('images-loading'); | 1412 $('pod-row').classList.remove('images-loading'); |
| 1408 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); | 1413 }, POD_ROW_IMAGES_LOAD_TIMEOUT_MS); |
| 1409 | 1414 |
| 1410 this.placePods_(); | 1415 if ($('login-header-bar').signinUIState == |
| 1416 SIGNIN_UI_STATE.ACCOUNT_PICKER) { |
| 1417 this.placePods_(); |
| 1411 | 1418 |
| 1412 // Without timeout changes in pods positions will be animated even though | 1419 // Without timeout changes in pods positions will be animated even |
| 1413 // it happened when 'flying-pods' class was disabled. | 1420 // though it happened when 'flying-pods' class was disabled. |
| 1414 setTimeout(function() { | 1421 setTimeout(function() { |
| 1415 Oobe.getInstance().toggleClass('flying-pods', true); | 1422 Oobe.getInstance().toggleClass('flying-pods', true); |
| 1416 }, 0); | 1423 }, 0); |
| 1417 | 1424 |
| 1418 this.focusPod(this.preselectedPod); | 1425 this.focusPod(this.preselectedPod); |
| 1426 } else { |
| 1427 this.podPlacementPostponed_ = true; |
| 1428 |
| 1429 // Update [Cancel] button state. |
| 1430 if ($('login-header-bar').signinUIState == |
| 1431 SIGNIN_UI_STATE.GAIA_SIGNIN && |
| 1432 emptyPodRow && |
| 1433 this.pods.length > 0) { |
| 1434 login.GaiaSigninScreen.updateCancelButtonState(); |
| 1435 } |
| 1436 } |
| 1419 }, | 1437 }, |
| 1420 | 1438 |
| 1421 /** | 1439 /** |
| 1422 * Adds given apps to the pod row. | 1440 * Adds given apps to the pod row. |
| 1423 * @param {array} apps Array of apps. | 1441 * @param {array} apps Array of apps. |
| 1424 */ | 1442 */ |
| 1425 setApps: function(apps) { | 1443 setApps: function(apps) { |
| 1426 this.apps_ = apps; | 1444 this.apps_ = apps; |
| 1427 this.rebuildPods(); | 1445 this.rebuildPods(); |
| 1428 chrome.send('kioskAppsLoaded'); | 1446 chrome.send('kioskAppsLoaded'); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 /** | 1949 /** |
| 1932 * Called right before the pod row is shown. | 1950 * Called right before the pod row is shown. |
| 1933 */ | 1951 */ |
| 1934 handleBeforeShow: function() { | 1952 handleBeforeShow: function() { |
| 1935 Oobe.getInstance().toggleClass('flying-pods', false); | 1953 Oobe.getInstance().toggleClass('flying-pods', false); |
| 1936 for (var event in this.listeners_) { | 1954 for (var event in this.listeners_) { |
| 1937 this.ownerDocument.addEventListener( | 1955 this.ownerDocument.addEventListener( |
| 1938 event, this.listeners_[event][0], this.listeners_[event][1]); | 1956 event, this.listeners_[event][0], this.listeners_[event][1]); |
| 1939 } | 1957 } |
| 1940 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; | 1958 $('login-header-bar').buttonsTabIndex = UserPodTabOrder.HEADER_BAR; |
| 1959 |
| 1960 if (this.podPlacementPostponed_) { |
| 1961 this.podPlacementPostponed_ = false; |
| 1962 this.placePods_(); |
| 1963 this.focusPod(this.preselectedPod); |
| 1964 } |
| 1941 }, | 1965 }, |
| 1942 | 1966 |
| 1943 /** | 1967 /** |
| 1944 * Called when the element is hidden. | 1968 * Called when the element is hidden. |
| 1945 */ | 1969 */ |
| 1946 handleHide: function() { | 1970 handleHide: function() { |
| 1947 for (var event in this.listeners_) { | 1971 for (var event in this.listeners_) { |
| 1948 this.ownerDocument.removeEventListener( | 1972 this.ownerDocument.removeEventListener( |
| 1949 event, this.listeners_[event][0], this.listeners_[event][1]); | 1973 event, this.listeners_[event][0], this.listeners_[event][1]); |
| 1950 } | 1974 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1964 if (this.podsWithPendingImages_.length == 0) { | 1988 if (this.podsWithPendingImages_.length == 0) { |
| 1965 this.classList.remove('images-loading'); | 1989 this.classList.remove('images-loading'); |
| 1966 } | 1990 } |
| 1967 } | 1991 } |
| 1968 }; | 1992 }; |
| 1969 | 1993 |
| 1970 return { | 1994 return { |
| 1971 PodRow: PodRow | 1995 PodRow: PodRow |
| 1972 }; | 1996 }; |
| 1973 }); | 1997 }); |
| OLD | NEW |