| 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * Getter for the icon element's div. | 299 * Getter for the icon element's div. |
| 300 * @return {HTMLDivElement} | 300 * @return {HTMLDivElement} |
| 301 */ | 301 */ |
| 302 get iconElement() { | 302 get iconElement() { |
| 303 return this.querySelector('.custom-icon'); | 303 return this.querySelector('.custom-icon'); |
| 304 }, | 304 }, |
| 305 | 305 |
| 306 /** | 306 /** |
| 307 * Set the icon's background image as image set with different | |
| 308 * representations for available screen scale factors. | |
| 309 * @param {!{scale1x: string, scale2x: string}} icon The icon | |
| 310 * representations. | |
| 311 */ | |
| 312 setIconAsImageSet: function(icon) { | |
| 313 this.iconElement.style.backgroundImage = | |
| 314 '-webkit-image-set(' + | |
| 315 'url(' + icon.scale1x + ') 1x,' + | |
| 316 'url(' + icon.scale2x + ') 2x)'; | |
| 317 }, | |
| 318 | |
| 319 /** | |
| 320 * Sets the icon background image to a chrome://theme URL. | 307 * Sets the icon background image to a chrome://theme URL. |
| 321 * @param {!string} iconUrl The icon's background image URL. | 308 * @param {!string} iconUrl The icon's background image URL. |
| 322 */ | 309 */ |
| 323 setIconAsResourceUrl: function(iconUrl) { | 310 setIconAsResourceUrl: function(iconUrl) { |
| 324 this.iconElement.style.backgroundImage = | 311 this.iconElement.style.backgroundImage = |
| 325 '-webkit-image-set(' + | 312 '-webkit-image-set(' + |
| 326 'url(' + iconUrl + '@1x) 1x,' + | 313 'url(' + iconUrl + '@1x) 1x,' + |
| 327 'url(' + iconUrl + '@2x) 2x)'; | 314 'url(' + iconUrl + '@2x) 2x)'; |
| 328 }, | 315 }, |
| 329 | 316 |
| (...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2303 * The icon parameters. | 2290 * The icon parameters. |
| 2304 */ | 2291 */ |
| 2305 showUserPodCustomIcon: function(username, icon) { | 2292 showUserPodCustomIcon: function(username, icon) { |
| 2306 var pod = this.getPodWithUsername_(username); | 2293 var pod = this.getPodWithUsername_(username); |
| 2307 if (pod == null) { | 2294 if (pod == null) { |
| 2308 console.error('Unable to show user pod button for ' + username + | 2295 console.error('Unable to show user pod button for ' + username + |
| 2309 ': user pod not found.'); | 2296 ': user pod not found.'); |
| 2310 return; | 2297 return; |
| 2311 } | 2298 } |
| 2312 | 2299 |
| 2313 if (icon.resourceUrl) { | 2300 if (!icon.resourceUrl) |
| 2314 pod.customIconElement.setIconAsResourceUrl(icon.resourceUrl); | |
| 2315 } else if (icon.data) { | |
| 2316 pod.customIconElement.setIconAsImageSet(icon.data); | |
| 2317 } else { | |
| 2318 return; | 2301 return; |
| 2319 } | |
| 2320 | 2302 |
| 2303 pod.customIconElement.setIconAsResourceUrl(icon.resourceUrl); |
| 2321 pod.customIconElement.setSize(icon.size || {width: 0, height: 0}); | 2304 pod.customIconElement.setSize(icon.size || {width: 0, height: 0}); |
| 2322 pod.customIconElement.setAnimation(icon.animation || null); | 2305 pod.customIconElement.setAnimation(icon.animation || null); |
| 2323 pod.customIconElement.setOpacity(icon.opacity || 100); | 2306 pod.customIconElement.setOpacity(icon.opacity || 100); |
| 2324 if (icon.hardlockOnClick) { | 2307 if (icon.hardlockOnClick) { |
| 2325 pod.customIconElement.setInteractive( | 2308 pod.customIconElement.setInteractive( |
| 2326 this.hardlockUserPod_.bind(this, username)); | 2309 this.hardlockUserPod_.bind(this, username)); |
| 2327 } else { | 2310 } else { |
| 2328 pod.customIconElement.setInteractive(null); | 2311 pod.customIconElement.setInteractive(null); |
| 2329 } | 2312 } |
| 2330 pod.customIconElement.show(); | 2313 pod.customIconElement.show(); |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3002 if (pod && pod.multiProfilesPolicyApplied) { | 2985 if (pod && pod.multiProfilesPolicyApplied) { |
| 3003 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 2986 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3004 } | 2987 } |
| 3005 } | 2988 } |
| 3006 }; | 2989 }; |
| 3007 | 2990 |
| 3008 return { | 2991 return { |
| 3009 PodRow: PodRow | 2992 PodRow: PodRow |
| 3010 }; | 2993 }; |
| 3011 }); | 2994 }); |
| OLD | NEW |