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

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

Issue 292233002: Disable VK overscroll for login/out-of-box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments 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
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 29 matching lines...) Expand all
40 * Variables used for pod placement processing. Width and height should be 40 * Variables used for pod placement processing. Width and height should be
41 * synced with computed CSS sizes of pods. 41 * synced with computed CSS sizes of pods.
42 */ 42 */
43 var POD_WIDTH = 180; 43 var POD_WIDTH = 180;
44 var PUBLIC_EXPANDED_WIDTH = 420; 44 var PUBLIC_EXPANDED_WIDTH = 420;
45 var CROS_POD_HEIGHT = 213; 45 var CROS_POD_HEIGHT = 213;
46 var DESKTOP_POD_HEIGHT = 216; 46 var DESKTOP_POD_HEIGHT = 216;
47 var POD_ROW_PADDING = 10; 47 var POD_ROW_PADDING = 10;
48 48
49 /** 49 /**
50 * Constants that define 'scrolling stops' when user pod rows are scrolled
51 * into view with virtual keyboard shown. First index is total number of rows,
52 * second index is focused pod row. See scrollFocusedPodIntoView().
53 * @type Array.<Array.<number>>
54 * @const
55 */
56 var USER_POD_ROW_SCROLL_STOPS = [[0.5], [0.25, 0.75], [0, 0.5, 1]];
dzhioev (left Google) 2014/05/21 17:30:32 We can have more than 3 rows of pods. What happens
Nikita (slow) 2014/05/22 15:11:50 Added dynamic calculation.
57
58 /**
50 * Whether to preselect the first pod automatically on login screen. 59 * Whether to preselect the first pod automatically on login screen.
51 * @type {boolean} 60 * @type {boolean}
52 * @const 61 * @const
53 */ 62 */
54 var PRESELECT_FIRST_POD = true; 63 var PRESELECT_FIRST_POD = true;
55 64
56 /** 65 /**
57 * Maximum time for which the pod row remains hidden until all user images 66 * Maximum time for which the pod row remains hidden until all user images
58 * have been loaded. 67 * have been loaded.
59 * @type {number} 68 * @type {number}
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 /** 158 /**
150 * Unique salt added to user image URLs to prevent caching. Dictionary with 159 * Unique salt added to user image URLs to prevent caching. Dictionary with
151 * user names as keys. 160 * user names as keys.
152 * @type {Object} 161 * @type {Object}
153 */ 162 */
154 UserPod.userImageSalt_ = {}; 163 UserPod.userImageSalt_ = {};
155 164
156 UserPod.prototype = { 165 UserPod.prototype = {
157 __proto__: HTMLDivElement.prototype, 166 __proto__: HTMLDivElement.prototype,
158 167
168 // Column at which user pod is located.
169 column_: -1,
170
171 // Row at which user pod is located.
172 row_: -1,
173
159 /** @override */ 174 /** @override */
160 decorate: function() { 175 decorate: function() {
161 this.tabIndex = UserPodTabOrder.POD_INPUT; 176 this.tabIndex = UserPodTabOrder.POD_INPUT;
162 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX; 177 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.ACTION_BOX;
163 178
164 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); 179 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
165 this.addEventListener('click', this.handleClickOnPod_.bind(this)); 180 this.addEventListener('click', this.handleClickOnPod_.bind(this));
166 181
167 this.signinButtonElement.addEventListener('click', 182 this.signinButtonElement.addEventListener('click',
168 this.activate.bind(this)); 183 this.activate.bind(this));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 }, 274 },
260 275
261 /** 276 /**
262 * Height number of pixels. 277 * Height number of pixels.
263 */ 278 */
264 get height() { 279 get height() {
265 return this.offsetHeight; 280 return this.offsetHeight;
266 }, 281 },
267 282
268 /** 283 /**
284 * User pod column.
285 * @type {?number}
286 */
287 set column(column) {
288 this.column_ = column;
289 },
290 get columns() {
291 return this.column_;
292 },
293
294 /**
295 * User pod row.
296 * @type {?number}
297 */
298 set row(row) {
299 this.row_ = row;
300 },
301 get row() {
302 return this.row_;
303 },
304
305 /**
269 * Gets signed in indicator element. 306 * Gets signed in indicator element.
270 * @type {!HTMLDivElement} 307 * @type {!HTMLDivElement}
271 */ 308 */
272 get signedInIndicatorElement() { 309 get signedInIndicatorElement() {
273 return this.querySelector('.signed-in-indicator'); 310 return this.querySelector('.signed-in-indicator');
274 }, 311 },
275 312
276 /** 313 /**
277 * Gets image element. 314 * Gets image element.
278 * @type {!HTMLImageElement} 315 * @type {!HTMLImageElement}
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1404
1368 var isDesktopUserManager = Oobe.getInstance().displayType == 1405 var isDesktopUserManager = Oobe.getInstance().displayType ==
1369 DISPLAY_TYPE.DESKTOP_USER_MANAGER; 1406 DISPLAY_TYPE.DESKTOP_USER_MANAGER;
1370 this.userPodHeight_ = isDesktopUserManager ? DESKTOP_POD_HEIGHT : 1407 this.userPodHeight_ = isDesktopUserManager ? DESKTOP_POD_HEIGHT :
1371 CROS_POD_HEIGHT; 1408 CROS_POD_HEIGHT;
1372 // Same for Chrome OS and desktop. 1409 // Same for Chrome OS and desktop.
1373 this.userPodWidth_ = POD_WIDTH; 1410 this.userPodWidth_ = POD_WIDTH;
1374 }, 1411 },
1375 1412
1376 /** 1413 /**
1414 * Returns focused user pod.
1415 * @type {Object}
1416 */
1417 get focusedPod() {
dzhioev (left Google) 2014/05/21 17:30:32 Why did you add this getter? As I can see, you onl
Nikita (slow) 2014/05/22 15:11:50 Right, not needed in latest impl, removed.
1418 return this.focusedPod_;
1419 },
1420
1421 /**
1377 * Returns all the pods in this pod row. 1422 * Returns all the pods in this pod row.
1378 * @type {NodeList} 1423 * @type {NodeList}
1379 */ 1424 */
1380 get pods() { 1425 get pods() {
1381 return Array.prototype.slice.call(this.children); 1426 return Array.prototype.slice.call(this.children);
1382 }, 1427 },
1383 1428
1384 /** 1429 /**
1385 * Return true if user pod row has only single user pod in it. 1430 * Return true if user pod row has only single user pod in it.
1386 * @type {boolean} 1431 * @type {boolean}
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 * @param {boolean} animated Whether to use init animation. 1594 * @param {boolean} animated Whether to use init animation.
1550 */ 1595 */
1551 loadPods: function(users, animated) { 1596 loadPods: function(users, animated) {
1552 this.users_ = users; 1597 this.users_ = users;
1553 this.userAddIsAnimated_ = animated; 1598 this.userAddIsAnimated_ = animated;
1554 1599
1555 this.rebuildPods(); 1600 this.rebuildPods();
1556 }, 1601 },
1557 1602
1558 /** 1603 /**
1604 * Scrolls focused user pod into view.
1605 */
1606 scrollFocusedPodIntoView: function() {
1607 if (!this.focusedPod ||
1608 this.focusedPod.column < 0 || this.focusedPod.row < 0) {
1609 return;
1610 }
1611
1612 $('scroll-container').scrollTop = $('scroll-container').offsetHeight *
1613 USER_POD_ROW_SCROLL_STOPS[this.rows - 1][this.focusedPod.row];
1614 },
1615
1616 /**
1559 * Rebuilds pod row using users_ and apps_ that were previously set or 1617 * Rebuilds pod row using users_ and apps_ that were previously set or
1560 * updated. 1618 * updated.
1561 */ 1619 */
1562 rebuildPods: function() { 1620 rebuildPods: function() {
1563 var emptyPodRow = this.pods.length == 0; 1621 var emptyPodRow = this.pods.length == 0;
1564 1622
1565 // Clear existing pods. 1623 // Clear existing pods.
1566 this.innerHTML = ''; 1624 this.innerHTML = '';
1567 this.focusedPod_ = undefined; 1625 this.focusedPod_ = undefined;
1568 this.activatedPod_ = undefined; 1626 this.activatedPod_ = undefined;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 BUBBLE_PADDING); 1777 BUBBLE_PADDING);
1720 }, 1778 },
1721 1779
1722 /** 1780 /**
1723 * Called when window was resized. 1781 * Called when window was resized.
1724 */ 1782 */
1725 onWindowResize: function() { 1783 onWindowResize: function() {
1726 var layout = this.calculateLayout_(); 1784 var layout = this.calculateLayout_();
1727 if (layout.columns != this.columns || layout.rows != this.rows) 1785 if (layout.columns != this.columns || layout.rows != this.rows)
1728 this.placePods_(); 1786 this.placePods_();
1787
1788 if (Oobe.getInstance().virtualKeyboardShown)
1789 this.scrollFocusedPodIntoView();
dzhioev (left Google) 2014/05/21 17:30:32 Did you try to make the same in |focusPod|, where
Nikita (slow) 2014/05/22 15:11:50 Since virtual keyboard shows up after some delay f
1729 }, 1790 },
1730 1791
1731 /** 1792 /**
1732 * Returns width of podrow having |columns| number of columns. 1793 * Returns width of podrow having |columns| number of columns.
1733 * @private 1794 * @private
1734 */ 1795 */
1735 columnsToWidth_: function(columns) { 1796 columnsToWidth_: function(columns) {
1736 var margin = MARGIN_BY_COLUMNS[columns]; 1797 var margin = MARGIN_BY_COLUMNS[columns];
1737 return 2 * POD_ROW_PADDING + columns * 1798 return 2 * POD_ROW_PADDING + columns *
1738 this.userPodWidth_ + (columns - 1) * margin; 1799 this.userPodWidth_ + (columns - 1) * margin;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 } 1858 }
1798 if (pod.offsetWidth != width) { 1859 if (pod.offsetWidth != width) {
1799 console.error('Pod offsetWidth (' + pod.offsetWidth + 1860 console.error('Pod offsetWidth (' + pod.offsetWidth +
1800 ') and POD_WIDTH (' + width + ') are not equal.'); 1861 ') and POD_WIDTH (' + width + ') are not equal.');
1801 } 1862 }
1802 if (index >= maxPodsNumber) { 1863 if (index >= maxPodsNumber) {
1803 pod.hidden = true; 1864 pod.hidden = true;
1804 return; 1865 return;
1805 } 1866 }
1806 pod.hidden = false; 1867 pod.hidden = false;
1807 var column = index % columns; 1868 var column = pod.column = index % columns;
1808 var row = Math.floor(index / columns); 1869 var row = pod.row = Math.floor(index / columns);
1809 pod.left = POD_ROW_PADDING + column * (width + margin); 1870 pod.left = POD_ROW_PADDING + column * (width + margin);
1810 pod.top = POD_ROW_PADDING + row * height; 1871 pod.top = POD_ROW_PADDING + row * height;
1811 }); 1872 });
1812 Oobe.getInstance().updateScreenSize(this.parentNode); 1873 Oobe.getInstance().updateScreenSize(this.parentNode);
1813 }, 1874 },
1814 1875
1815 /** 1876 /**
1816 * Number of columns. 1877 * Number of columns.
1817 * @type {?number} 1878 * @type {?number}
1818 */ 1879 */
1819 set columns(columns) { 1880 set columns(columns) {
1820 // Cannot use 'columns' here. 1881 // Cannot use 'columns' here.
1821 this.setAttribute('ncolumns', columns); 1882 this.setAttribute('ncolumns', columns);
1822 }, 1883 },
1823 get columns() { 1884 get columns() {
1824 return this.getAttribute('ncolumns'); 1885 return parseInt(this.getAttribute('ncolumns'));
1825 }, 1886 },
1826 1887
1827 /** 1888 /**
1828 * Number of rows. 1889 * Number of rows.
1829 * @type {?number} 1890 * @type {?number}
1830 */ 1891 */
1831 set rows(rows) { 1892 set rows(rows) {
1832 // Cannot use 'rows' here. 1893 // Cannot use 'rows' here.
1833 this.setAttribute('nrows', rows); 1894 this.setAttribute('nrows', rows);
1834 }, 1895 },
1835 get rows() { 1896 get rows() {
1836 return this.getAttribute('nrows'); 1897 return parseInt(this.getAttribute('nrows'));
1837 }, 1898 },
1838 1899
1839 /** 1900 /**
1840 * Whether the pod is currently focused. 1901 * Whether the pod is currently focused.
1841 * @param {UserPod} pod Pod to check for focus. 1902 * @param {UserPod} pod Pod to check for focus.
1842 * @return {boolean} Pod focus status. 1903 * @return {boolean} Pod focus status.
1843 */ 1904 */
1844 isFocused: function(pod) { 1905 isFocused: function(pod) {
1845 return this.focusedPod_ == pod; 1906 return this.focusedPod_ == pod;
1846 }, 1907 },
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 if (this.podsWithPendingImages_.length == 0) { 2291 if (this.podsWithPendingImages_.length == 0) {
2231 this.classList.remove('images-loading'); 2292 this.classList.remove('images-loading');
2232 } 2293 }
2233 } 2294 }
2234 }; 2295 };
2235 2296
2236 return { 2297 return {
2237 PodRow: PodRow 2298 PodRow: PodRow
2238 }; 2299 };
2239 }); 2300 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698