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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
946 }, | 946 }, |
947 | 947 |
948 /** | 948 /** |
949 * Gets action box menu, remove user command item div. | 949 * Gets action box menu, remove user command item div. |
950 * @type {!HTMLInputElement} | 950 * @type {!HTMLInputElement} |
951 */ | 951 */ |
952 get actionBoxMenuRemoveElement() { | 952 get actionBoxMenuRemoveElement() { |
953 return this.querySelector('.action-box-menu-remove'); | 953 return this.querySelector('.action-box-menu-remove'); |
954 }, | 954 }, |
955 | 955 |
956 /** | 956 // /** |
957 * Gets action box menu, remove user warning text div. | 957 // * Gets action box menu, remove user warning text div. |
msramek
2015/07/29 13:55:01
Please remove the unused code.
lwchkg
2015/07/29 14:46:05
Oh it is embarrassing...
| |
958 * @type {!HTMLInputElement} | 958 // * @type {!HTMLInputElement} |
959 */ | 959 // */ |
960 get actionBoxRemoveUserWarningTextElement() { | 960 // get actionBoxRemoveUserWarningTextElement() { |
961 return this.querySelector('.action-box-remove-user-warning-text'); | 961 // return this.querySelector('.action-box-remove-user-warning-text'); |
962 }, | 962 // }, |
963 | 963 |
964 /** | 964 /** |
965 * Gets action box menu, remove legacy supervised user warning text div. | 965 * Gets action box menu, remove legacy supervised user warning text div. |
966 * @type {!HTMLInputElement} | 966 * @type {!HTMLInputElement} |
967 */ | 967 */ |
968 get actionBoxRemoveLegacySupervisedUserWarningTextElement() { | 968 get actionBoxRemoveLegacySupervisedUserWarningTextElement() { |
969 return this.querySelector( | 969 return this.querySelector( |
970 '.action-box-remove-legacy-supervised-user-warning-text'); | 970 '.action-box-remove-legacy-supervised-user-warning-text'); |
971 }, | 971 }, |
972 | 972 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 // Move up the menu if it overlaps shelf. | 1418 // Move up the menu if it overlaps shelf. |
1419 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( | 1419 var maxHeight = cr.ui.LoginUITools.getMaxHeightBeforeShelfOverlapping( |
1420 this.actionBoxMenu); | 1420 this.actionBoxMenu); |
1421 var actualHeight = parseInt( | 1421 var actualHeight = parseInt( |
1422 window.getComputedStyle(this.actionBoxMenu).height); | 1422 window.getComputedStyle(this.actionBoxMenu).height); |
1423 if (maxHeight < actualHeight) { | 1423 if (maxHeight < actualHeight) { |
1424 this.actionBoxMenu.classList.add('menu-moved-up'); | 1424 this.actionBoxMenu.classList.add('menu-moved-up'); |
1425 this.actionBoxAreaElement.classList.add('menu-moved-up'); | 1425 this.actionBoxAreaElement.classList.add('menu-moved-up'); |
1426 } | 1426 } |
1427 chrome.send('logRemoveUserWarningShown'); | 1427 chrome.send('logRemoveUserWarningShown'); |
1428 | |
1429 // Show extra statistics information for desktop users | |
1430 if (this.user.isDesktopUser) { | |
1431 // set a global handler for the callback | |
1432 window.updateRemoveWarningDialog = | |
1433 this.updateRemoveWarningDialog_.bind(this); | |
1434 chrome.send('removeUserWarningLoadStats', [this.user.profilePath]); | |
1435 } | |
1428 }, | 1436 }, |
1429 | 1437 |
1430 /** | 1438 /** |
1439 * Refresh the statistics in the remove user warning dialog. | |
1440 * @param {string} profilePath the filepath of the URL (must be verified) | |
1441 * @param {Object} profileStats Statistics associated with profileURL. | |
1442 */ | |
1443 updateRemoveWarningDialog_: function(profilePath, profileStats) { | |
1444 if (profilePath === this.user.profilePath) { | |
1445 // Converting profileStats into id attribute by an object. | |
1446 var stats_id_map = { | |
1447 'BrowsingHistory': 'action-box-remove-user-warning-history', | |
1448 'Passwords': 'action-box-remove-user-warning-passwords', | |
1449 'Bookmarks': 'action-box-remove-user-warning-bookmarks', | |
1450 'Settings': 'action-box-remove-user-warning-settings', | |
1451 } | |
1452 // Load individual statistics | |
1453 var num_stats_loaded = 0; | |
1454 var total_count = 0; | |
1455 for (var key in profileStats) { | |
1456 if (stats_id_map.hasOwnProperty(key)) { | |
1457 this.querySelector("." + stats_id_map[key]).textContent | |
1458 = profileStats[key]; | |
1459 num_stats_loaded++; | |
1460 total_count += profileStats[key]; | |
1461 } | |
1462 } | |
1463 // Write total number if all statistics are loaded. | |
1464 if (num_stats_loaded === Object.keys(stats_id_map).length) { | |
1465 elements = this.getElementsByClassName('total-count'); | |
1466 for (var i = 0; i < elements.length; i++) { | |
1467 elements[i].textContent = total_count; | |
1468 } | |
1469 } | |
1470 } | |
1471 }, | |
1472 | |
1473 /** | |
1431 * Handles a click event on remove user confirmation button. | 1474 * Handles a click event on remove user confirmation button. |
1432 * @param {Event} e Click event. | 1475 * @param {Event} e Click event. |
1433 */ | 1476 */ |
1434 handleRemoveUserConfirmationClick_: function(e) { | 1477 handleRemoveUserConfirmationClick_: function(e) { |
1435 if (this.isActionBoxMenuActive) { | 1478 if (this.isActionBoxMenuActive) { |
1436 this.isActionBoxMenuActive = false; | 1479 this.isActionBoxMenuActive = false; |
1437 this.removeUser(this.user); | 1480 this.removeUser(this.user); |
1438 e.stopPropagation(); | 1481 e.stopPropagation(); |
1439 } | 1482 } |
1440 }, | 1483 }, |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1939 | 1982 |
1940 /** @override */ | 1983 /** @override */ |
1941 update: function() { | 1984 update: function() { |
1942 this.imageElement.src = this.user.userImage; | 1985 this.imageElement.src = this.user.userImage; |
1943 this.nameElement.textContent = this.user.displayName; | 1986 this.nameElement.textContent = this.user.displayName; |
1944 this.reauthNameHintElement.textContent = this.user.displayName; | 1987 this.reauthNameHintElement.textContent = this.user.displayName; |
1945 | 1988 |
1946 var isLockedUser = this.user.needsSignin; | 1989 var isLockedUser = this.user.needsSignin; |
1947 var isLegacySupervisedUser = this.user.legacySupervisedUser; | 1990 var isLegacySupervisedUser = this.user.legacySupervisedUser; |
1948 var isChildUser = this.user.childUser; | 1991 var isChildUser = this.user.childUser; |
1992 var isSynced = this.user.emailAddress !== ""; | |
1949 this.classList.toggle('locked', isLockedUser); | 1993 this.classList.toggle('locked', isLockedUser); |
1950 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); | 1994 this.classList.toggle('legacy-supervised', isLegacySupervisedUser); |
1951 this.classList.toggle('child', isChildUser); | 1995 this.classList.toggle('child', isChildUser); |
1952 | 1996 |
1953 if (this.isAuthTypeUserClick) | 1997 if (this.isAuthTypeUserClick) |
1954 this.passwordLabelElement.textContent = this.authValue; | 1998 this.passwordLabelElement.textContent = this.authValue; |
1955 | 1999 |
1956 this.actionBoxRemoveUserWarningTextElement.hidden = | 2000 this.querySelector('.action-box-remove-user-warning-text-nonsync') |
msramek
2015/07/29 13:55:01
These classes seem to refer to a particular elemen
lwchkg
2015/07/29 14:46:05
All tags in this file should NOT have IDs because
msramek
2015/07/29 18:10:25
If that's the case, then your selectors will alway
| |
1957 isLegacySupervisedUser; | 2001 .hidden = isLegacySupervisedUser || isSynced; |
2002 this.querySelector('.action-box-remove-user-warning-table-nonsync') | |
2003 .hidden = isLegacySupervisedUser || isSynced; | |
2004 this.querySelector('.action-box-remove-user-warning-text-sync') | |
2005 .hidden = isLegacySupervisedUser || !isSynced; | |
2006 this.querySelector('.action-box-remove-user-warning-text-sync2') | |
2007 .hidden = isLegacySupervisedUser || !isSynced; | |
2008 this.querySelector('.action-box-remove-user-warning-text-nostats') | |
2009 .hidden = true;//isLegacySupervisedUser; | |
1958 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = | 2010 this.actionBoxRemoveLegacySupervisedUserWarningTextElement.hidden = |
1959 !isLegacySupervisedUser; | 2011 !isLegacySupervisedUser; |
1960 | 2012 |
2013 // Convert HTML textContent into HTML. Done only once. | |
2014 var tag = | |
2015 this.querySelector('.action-box-remove-user-warning-text-nonsync'); | |
2016 if (!tag.childElementCount) { | |
2017 this.querySelector('.action-box-remove-user-warning-text-nonsync') | |
2018 .innerHTML = loadTimeData.getString( | |
2019 'removeUserWarningTextNonSync'); | |
2020 this.querySelector('.action-box-remove-user-warning-text-sync') | |
2021 .innerHTML = loadTimeData.getString( | |
2022 'removeUserWarningTextSync'); | |
2023 this.querySelector('.action-box-remove-user-warning-text-sync2') | |
2024 .innerHTML = loadTimeData.getString( | |
2025 'removeUserWarningTextSync2'); | |
2026 } | |
2027 | |
1961 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 2028 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
1962 'passwordFieldAccessibleName', this.user_.emailAddress)); | 2029 'passwordFieldAccessibleName', this.user_.emailAddress)); |
1963 | 2030 |
1964 UserPod.prototype.updateActionBoxArea.call(this); | 2031 UserPod.prototype.updateActionBoxArea.call(this); |
1965 }, | 2032 }, |
1966 | 2033 |
1967 /** @override */ | 2034 /** @override */ |
1968 focusInput: function() { | 2035 focusInput: function() { |
1969 // Move tabIndex from the whole pod to the main input. | 2036 // Move tabIndex from the whole pod to the main input. |
1970 this.tabIndex = -1; | 2037 this.tabIndex = -1; |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3163 if (pod && pod.multiProfilesPolicyApplied) { | 3230 if (pod && pod.multiProfilesPolicyApplied) { |
3164 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3231 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3165 } | 3232 } |
3166 } | 3233 } |
3167 }; | 3234 }; |
3168 | 3235 |
3169 return { | 3236 return { |
3170 PodRow: PodRow | 3237 PodRow: PodRow |
3171 }; | 3238 }; |
3172 }); | 3239 }); |
OLD | NEW |