Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 1642323004: User Manager MD User Pods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment, rebase, and fix for browser test Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 * @const 21 * @const
22 */ 22 */
23 var MARGIN_BY_COLUMNS = [undefined, 40, 40, 40, 40, 40, 12]; 23 var MARGIN_BY_COLUMNS = [undefined, 40, 40, 40, 40, 40, 12];
24 24
25 /** 25 /**
26 * Mapping between number of columns in the desktop pod-row and margin 26 * Mapping between number of columns in the desktop pod-row and margin
27 * between user pods for such layout. 27 * between user pods for such layout.
28 * @type {Array<number>} 28 * @type {Array<number>}
29 * @const 29 * @const
30 */ 30 */
31 var DESKTOP_MARGIN_BY_COLUMNS = [undefined, 15, 15, 15, 15, 15, 15]; 31 var DESKTOP_MARGIN_BY_COLUMNS = [undefined, 32, 32, 32, 32, 32, 32];
32 32
33 /** 33 /**
34 * Maximal number of columns currently supported by pod-row. 34 * Maximal number of columns currently supported by pod-row.
35 * @type {number} 35 * @type {number}
36 * @const 36 * @const
37 */ 37 */
38 var MAX_NUMBER_OF_COLUMNS = 6; 38 var MAX_NUMBER_OF_COLUMNS = 6;
39 39
40 /** 40 /**
41 * Maximal number of rows if sign-in banner is displayed alonside. 41 * Maximal number of rows if sign-in banner is displayed alonside.
42 * @type {number} 42 * @type {number}
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 CROS_POD_WIDTH = 180;
52 var DESKTOP_POD_WIDTH = 180;
53 var MD_DESKTOP_POD_WIDTH = 160;
52 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; 54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500;
53 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; 55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610;
54 var CROS_POD_HEIGHT = 213; 56 var CROS_POD_HEIGHT = 213;
55 var DESKTOP_POD_HEIGHT = 226; 57 var DESKTOP_POD_HEIGHT = 226;
58 var MD_DESKTOP_POD_HEIGHT = 200;
56 var POD_ROW_PADDING = 10; 59 var POD_ROW_PADDING = 10;
57 var DESKTOP_ROW_PADDING = 15; 60 var DESKTOP_ROW_PADDING = 32;
58 var CUSTOM_ICON_CONTAINER_SIZE = 40; 61 var CUSTOM_ICON_CONTAINER_SIZE = 40;
59 62
60 /** 63 /**
61 * Minimal padding between user pod and virtual keyboard. 64 * Minimal padding between user pod and virtual keyboard.
62 * @type {number} 65 * @type {number}
63 * @const 66 * @const
64 */ 67 */
65 var USER_POD_KEYBOARD_MIN_PADDING = 20; 68 var USER_POD_KEYBOARD_MIN_PADDING = 20;
66 69
67 /** 70 /**
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 * @param {string} profilePath The filepath of the URL (must be verified). 1544 * @param {string} profilePath The filepath of the URL (must be verified).
1542 * @param {string} message The message to be written. 1545 * @param {string} message The message to be written.
1543 * @param {number|string=} count The number or string to replace $1 in 1546 * @param {number|string=} count The number or string to replace $1 in
1544 * |message|. Can be omitted if $1 is not present in |message|. 1547 * |message|. Can be omitted if $1 is not present in |message|.
1545 */ 1548 */
1546 updateRemoveWarningDialogSetMessage_: function(profilePath, message, 1549 updateRemoveWarningDialogSetMessage_: function(profilePath, message,
1547 count) { 1550 count) {
1548 if (profilePath !== this.user.profilePath) 1551 if (profilePath !== this.user.profilePath)
1549 return; 1552 return;
1550 // Add localized messages where $1 will be replaced with 1553 // Add localized messages where $1 will be replaced with
1551 // <span class="total-count"></span>. 1554 // <span class="total-count"></span> and $2 will be replaced with
1555 // <span class="email"></span>.
1552 var element = this.querySelector('.action-box-remove-user-warning-text'); 1556 var element = this.querySelector('.action-box-remove-user-warning-text');
1553 element.textContent = ''; 1557 element.textContent = '';
1554 1558
1555 messageParts = message.split('$1'); 1559 messageParts = message.split(/(\$[12])/);
1556 var numParts = messageParts.length; 1560 var numParts = messageParts.length;
1557 for (var j = 0; j < numParts; j++) { 1561 for (var j = 0; j < numParts; j++) {
1558 element.appendChild(document.createTextNode(messageParts[j])); 1562 if (messageParts[j] === '$1') {
1559 if (j < numParts - 1) {
1560 var elementToAdd = document.createElement('span'); 1563 var elementToAdd = document.createElement('span');
1561 elementToAdd.classList.add('total-count'); 1564 elementToAdd.classList.add('total-count');
1562 elementToAdd.textContent = count; 1565 elementToAdd.textContent = count;
1563 element.appendChild(elementToAdd); 1566 element.appendChild(elementToAdd);
1567 } else if (messageParts[j] === '$2') {
1568 var elementToAdd = document.createElement('span');
1569 elementToAdd.classList.add('email');
1570 elementToAdd.textContent = this.user.emailAddress;
1571 element.appendChild(elementToAdd);
1572 } else {
1573 element.appendChild(document.createTextNode(messageParts[j]));
1564 } 1574 }
1565 } 1575 }
1566 this.moveActionMenuUpIfNeeded_(); 1576 this.moveActionMenuUpIfNeeded_();
1567 }, 1577 },
1568 1578
1569 /** 1579 /**
1570 * Handles a click event on remove user confirmation button. 1580 * Handles a click event on remove user confirmation button.
1571 * @param {Event} e Click event. 1581 * @param {Event} e Click event.
1572 */ 1582 */
1573 handleRemoveUserConfirmationClick_: function(e) { 1583 handleRemoveUserConfirmationClick_: function(e) {
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 // the element is visible. 2315 // the element is visible.
2306 this.listeners_ = { 2316 this.listeners_ = {
2307 focus: [this.handleFocus_.bind(this), true /* useCapture */], 2317 focus: [this.handleFocus_.bind(this), true /* useCapture */],
2308 click: [this.handleClick_.bind(this), true], 2318 click: [this.handleClick_.bind(this), true],
2309 mousemove: [this.handleMouseMove_.bind(this), false], 2319 mousemove: [this.handleMouseMove_.bind(this), false],
2310 keydown: [this.handleKeyDown.bind(this), false] 2320 keydown: [this.handleKeyDown.bind(this), false]
2311 }; 2321 };
2312 2322
2313 var isDesktopUserManager = Oobe.getInstance().displayType == 2323 var isDesktopUserManager = Oobe.getInstance().displayType ==
2314 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 2324 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
2315 this.userPodHeight_ = isDesktopUserManager ? DESKTOP_POD_HEIGHT : 2325 var isNewDesktopUserManager = Oobe.getInstance().newDesktopUserManager;
2316 CROS_POD_HEIGHT; 2326 this.userPodHeight_ = isDesktopUserManager ?
2317 // Same for Chrome OS and desktop. 2327 isNewDesktopUserManager ? MD_DESKTOP_POD_HEIGHT :
2318 this.userPodWidth_ = POD_WIDTH; 2328 DESKTOP_POD_HEIGHT :
2329 CROS_POD_HEIGHT;
2330 this.userPodWidth_ = isDesktopUserManager ?
2331 isNewDesktopUserManager ? MD_DESKTOP_POD_WIDTH :
2332 DESKTOP_POD_WIDTH :
2333 CROS_POD_WIDTH;
2319 }, 2334 },
2320 2335
2321 /** 2336 /**
2322 * Returns all the pods in this pod row. 2337 * Returns all the pods in this pod row.
2323 * @type {NodeList} 2338 * @type {NodeList}
2324 */ 2339 */
2325 get pods() { 2340 get pods() {
2326 return Array.prototype.slice.call(this.children); 2341 return Array.prototype.slice.call(this.children);
2327 }, 2342 },
2328 2343
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 COLUMNS[this.pods.length] : COLUMNS[COLUMNS.length - 1]; 2801 COLUMNS[this.pods.length] : COLUMNS[COLUMNS.length - 1];
2787 var maxWidth = Oobe.getInstance().clientAreaSize.width; 2802 var maxWidth = Oobe.getInstance().clientAreaSize.width;
2788 var columns = preferredColumns; 2803 var columns = preferredColumns;
2789 while (maxWidth < this.columnsToWidth_(columns) && columns > 1) 2804 while (maxWidth < this.columnsToWidth_(columns) && columns > 1)
2790 --columns; 2805 --columns;
2791 var rows = Math.floor((this.pods.length - 1) / columns) + 1; 2806 var rows = Math.floor((this.pods.length - 1) / columns) + 1;
2792 if (getComputedStyle( 2807 if (getComputedStyle(
2793 $('signin-banner'), null).getPropertyValue('display') != 'none') { 2808 $('signin-banner'), null).getPropertyValue('display') != 'none') {
2794 rows = Math.min(rows, MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER); 2809 rows = Math.min(rows, MAX_NUMBER_OF_ROWS_UNDER_SIGNIN_BANNER);
2795 } 2810 }
2796 var maxHeigth = Oobe.getInstance().clientAreaSize.height; 2811 if (!Oobe.getInstance().newDesktopUserManager) {
2797 while (maxHeigth < this.rowsToHeight_(rows) && rows > 1) 2812 var maxHeigth = Oobe.getInstance().clientAreaSize.height;
2798 --rows; 2813 while (maxHeigth < this.rowsToHeight_(rows) && rows > 1)
2814 --rows;
2815 }
2799 // One more iteration if it's not enough cells to place all pods. 2816 // One more iteration if it's not enough cells to place all pods.
2800 while (maxWidth >= this.columnsToWidth_(columns + 1) && 2817 while (maxWidth >= this.columnsToWidth_(columns + 1) &&
2801 columns * rows < this.pods.length && 2818 columns * rows < this.pods.length &&
2802 columns < MAX_NUMBER_OF_COLUMNS) { 2819 columns < MAX_NUMBER_OF_COLUMNS) {
2803 ++columns; 2820 ++columns;
2804 } 2821 }
2805 return {columns: columns, rows: rows}; 2822 return {columns: columns, rows: rows};
2806 }, 2823 },
2807 2824
2808 /** 2825 /**
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 if (pod && pod.multiProfilesPolicyApplied) { 3341 if (pod && pod.multiProfilesPolicyApplied) {
3325 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3342 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3326 } 3343 }
3327 } 3344 }
3328 }; 3345 };
3329 3346
3330 return { 3347 return {
3331 PodRow: PodRow 3348 PodRow: PodRow
3332 }; 3349 };
3333 }); 3350 });
OLDNEW
« no previous file with comments | « ui/login/account_picker/user_pod_row.css ('k') | ui/login/account_picker/user_pod_template.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698