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

Side by Side Diff: chrome/browser/resources/login/user_pod_row.js

Issue 283363006: You should be able to deselect the only user pod in the desktop user manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix leftover rename. reading bot errors helps >.< Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/kiosk_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1375
1376 /** 1376 /**
1377 * Returns all the pods in this pod row. 1377 * Returns all the pods in this pod row.
1378 * @type {NodeList} 1378 * @type {NodeList}
1379 */ 1379 */
1380 get pods() { 1380 get pods() {
1381 return Array.prototype.slice.call(this.children); 1381 return Array.prototype.slice.call(this.children);
1382 }, 1382 },
1383 1383
1384 /** 1384 /**
1385 * Return true if user pod row has only single user pod in it. 1385 * Return true if user pod row has only single user pod in it, which should
1386 * always be focused.
1386 * @type {boolean} 1387 * @type {boolean}
1387 */ 1388 */
1388 get isSinglePod() { 1389 get alwaysFocusSinglePod() {
1389 return this.children.length == 1; 1390 var isDesktopUserManager = Oobe.getInstance().displayType ==
1391 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
1392
1393 return isDesktopUserManager ? false : this.children.length == 1;
1390 }, 1394 },
1391 1395
1392 /** 1396 /**
1393 * Returns pod with the given app id. 1397 * Returns pod with the given app id.
1394 * @param {!string} app_id Application id to be matched. 1398 * @param {!string} app_id Application id to be matched.
1395 * @return {Object} Pod with the given app id. null if pod hasn't been 1399 * @return {Object} Pod with the given app id. null if pod hasn't been
1396 * found. 1400 * found.
1397 */ 1401 */
1398 getPodWithAppId_: function(app_id) { 1402 getPodWithAppId_: function(app_id) {
1399 for (var i = 0, pod; pod = this.pods[i]; ++i) { 1403 for (var i = 0, pod; pod = this.pods[i]; ++i) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 // Desktop: recalculate pods layout right away. 1603 // Desktop: recalculate pods layout right away.
1600 if (isDesktopUserManager || isCrosAccountPicker) { 1604 if (isDesktopUserManager || isCrosAccountPicker) {
1601 this.placePods_(); 1605 this.placePods_();
1602 1606
1603 // Without timeout changes in pods positions will be animated even 1607 // Without timeout changes in pods positions will be animated even
1604 // though it happened when 'flying-pods' class was disabled. 1608 // though it happened when 'flying-pods' class was disabled.
1605 setTimeout(function() { 1609 setTimeout(function() {
1606 Oobe.getInstance().toggleClass('flying-pods', true); 1610 Oobe.getInstance().toggleClass('flying-pods', true);
1607 }, 0); 1611 }, 0);
1608 1612
1609 this.focusPod(this.preselectedPod); 1613 // On desktop, don't pre-select a pod if it's the only one.
1614 if (isDesktopUserManager && this.pods.length == 1)
1615 this.focusPod();
1616 else
1617 this.focusPod(this.preselectedPod);
1610 } else { 1618 } else {
1611 this.podPlacementPostponed_ = true; 1619 this.podPlacementPostponed_ = true;
1612 1620
1613 // Update [Cancel] button state. 1621 // Update [Cancel] button state.
1614 if ($('login-header-bar').signinUIState == 1622 if ($('login-header-bar').signinUIState ==
1615 SIGNIN_UI_STATE.GAIA_SIGNIN && 1623 SIGNIN_UI_STATE.GAIA_SIGNIN &&
1616 emptyPodRow && 1624 emptyPodRow &&
1617 this.pods.length > 0) { 1625 this.pods.length > 0) {
1618 login.GaiaSigninScreen.updateCancelButtonState(); 1626 login.GaiaSigninScreen.updateCancelButtonState();
1619 } 1627 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1874 }
1867 1875
1868 // Make sure there's only one focusPod operation happening at a time. 1876 // Make sure there's only one focusPod operation happening at a time.
1869 if (this.insideFocusPod_) { 1877 if (this.insideFocusPod_) {
1870 this.keyboardActivated_ = false; 1878 this.keyboardActivated_ = false;
1871 return; 1879 return;
1872 } 1880 }
1873 this.insideFocusPod_ = true; 1881 this.insideFocusPod_ = true;
1874 1882
1875 for (var i = 0, pod; pod = this.pods[i]; ++i) { 1883 for (var i = 0, pod; pod = this.pods[i]; ++i) {
1876 if (!this.isSinglePod) { 1884 if (!this.alwaysFocusSinglePod) {
1877 pod.isActionBoxMenuActive = false; 1885 pod.isActionBoxMenuActive = false;
1878 } 1886 }
1879 if (pod != podToFocus) { 1887 if (pod != podToFocus) {
1880 pod.isActionBoxMenuHovered = false; 1888 pod.isActionBoxMenuHovered = false;
1881 pod.classList.remove('focused'); 1889 pod.classList.remove('focused');
1882 pod.classList.remove('faded'); 1890 pod.classList.remove('faded');
1883 pod.reset(false); 1891 pod.reset(false);
1884 } 1892 }
1885 } 1893 }
1886 1894
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 // Clear all menus if the click is outside pod menu and its 2033 // Clear all menus if the click is outside pod menu and its
2026 // button area. 2034 // button area.
2027 if (!findAncestorByClass(e.target, 'action-box-menu') && 2035 if (!findAncestorByClass(e.target, 'action-box-menu') &&
2028 !findAncestorByClass(e.target, 'action-box-area')) { 2036 !findAncestorByClass(e.target, 'action-box-area')) {
2029 for (var i = 0, pod; pod = this.pods[i]; ++i) 2037 for (var i = 0, pod; pod = this.pods[i]; ++i)
2030 pod.isActionBoxMenuActive = false; 2038 pod.isActionBoxMenuActive = false;
2031 } 2039 }
2032 2040
2033 // Clears focus if not clicked on a pod and if there's more than one pod. 2041 // Clears focus if not clicked on a pod and if there's more than one pod.
2034 var pod = findAncestorByClass(e.target, 'pod'); 2042 var pod = findAncestorByClass(e.target, 'pod');
2035 if ((!pod || pod.parentNode != this) && !this.isSinglePod) { 2043 if ((!pod || pod.parentNode != this) && !this.alwaysFocusSinglePod) {
2036 this.focusPod(); 2044 this.focusPod();
2037 } 2045 }
2038 2046
2039 if (pod) 2047 if (pod)
2040 pod.isActionBoxMenuHovered = true; 2048 pod.isActionBoxMenuHovered = true;
2041 2049
2042 // Return focus back to single pod. 2050 // Return focus back to single pod.
2043 if (this.isSinglePod) { 2051 if (this.alwaysFocusSinglePod) {
2044 this.focusPod(this.focusedPod_, true /* force */); 2052 this.focusPod(this.focusedPod_, true /* force */);
2045 if (!pod) 2053 if (!pod)
2046 this.focusedPod_.isActionBoxMenuHovered = false; 2054 this.focusedPod_.isActionBoxMenuHovered = false;
2047 } 2055 }
2048 }, 2056 },
2049 2057
2050 /** 2058 /**
2051 * Handler of mouse move event. 2059 * Handler of mouse move event.
2052 * @param {Event} e Click Event object. 2060 * @param {Event} e Click Event object.
2053 * @private 2061 * @private
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 e.target.focus(); 2110 e.target.focus();
2103 } 2111 }
2104 return; 2112 return;
2105 } 2113 }
2106 2114
2107 // Clears pod focus when we reach here. It means new focus is neither 2115 // Clears pod focus when we reach here. It means new focus is neither
2108 // on a pod nor on a button/input for a pod. 2116 // on a pod nor on a button/input for a pod.
2109 // Do not "defocus" user pod when it is a single pod. 2117 // Do not "defocus" user pod when it is a single pod.
2110 // That means that 'focused' class will not be removed and 2118 // That means that 'focused' class will not be removed and
2111 // input field/button will always be visible. 2119 // input field/button will always be visible.
2112 if (!this.isSinglePod) 2120 if (!this.alwaysFocusSinglePod)
2113 this.focusPod(); 2121 this.focusPod();
2114 }, 2122 },
2115 2123
2116 /** 2124 /**
2117 * Handler of keydown event. 2125 * Handler of keydown event.
2118 * @param {Event} e KeyDown Event object. 2126 * @param {Event} e KeyDown Event object.
2119 */ 2127 */
2120 handleKeyDown: function(e) { 2128 handleKeyDown: function(e) {
2121 if (this.disabled) 2129 if (this.disabled)
2122 return; 2130 return;
(...skipping 27 matching lines...) Expand all
2150 if (e.target == this.focusedPod_.passwordElement || 2158 if (e.target == this.focusedPod_.passwordElement ||
2151 (targetTag != 'INPUT' && 2159 (targetTag != 'INPUT' &&
2152 targetTag != 'BUTTON' && 2160 targetTag != 'BUTTON' &&
2153 targetTag != 'A')) { 2161 targetTag != 'A')) {
2154 this.setActivatedPod(this.focusedPod_, e); 2162 this.setActivatedPod(this.focusedPod_, e);
2155 e.stopPropagation(); 2163 e.stopPropagation();
2156 } 2164 }
2157 } 2165 }
2158 break; 2166 break;
2159 case 'U+001B': // Esc 2167 case 'U+001B': // Esc
2160 if (!this.isSinglePod) 2168 if (!this.alwaysFocusSinglePod)
2161 this.focusPod(); 2169 this.focusPod();
2162 break; 2170 break;
2163 } 2171 }
2164 }, 2172 },
2165 2173
2166 /** 2174 /**
2167 * Called right after the pod row is shown. 2175 * Called right after the pod row is shown.
2168 */ 2176 */
2169 handleAfterShow: function() { 2177 handleAfterShow: function() {
2170 // Without timeout changes in pods positions will be animated even though 2178 // Without timeout changes in pods positions will be animated even though
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 if (this.podsWithPendingImages_.length == 0) { 2238 if (this.podsWithPendingImages_.length == 0) {
2231 this.classList.remove('images-loading'); 2239 this.classList.remove('images-loading');
2232 } 2240 }
2233 } 2241 }
2234 }; 2242 };
2235 2243
2236 return { 2244 return {
2237 PodRow: PodRow 2245 PodRow: PodRow
2238 }; 2246 };
2239 }); 2247 });
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/kiosk_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698