Urs Wolfer | 3752568 | 2016-01-22 11:57:10 +0100 | [diff] [blame] | 1 | <!-- |
| 2 | Copyright (C) 2016 The Android Open Source Project |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | --> |
| 16 | |
| 17 | <link rel="import" href="../bower_components/polymer/polymer.html"> |
| 18 | <link rel="import" href="gr-avatar.html"> |
| 19 | |
| 20 | <dom-module id="gr-account-label"> |
| 21 | <template> |
| 22 | <style> |
| 23 | :host { |
| 24 | display: inline; |
| 25 | } |
| 26 | gr-avatar { |
| 27 | height: 1.3em; |
| 28 | width: 1.3em; |
Andrew Bonventre | 09c8c24 | 2016-02-23 17:28:50 -0500 | [diff] [blame^] | 29 | margin-right: .15em; |
| 30 | vertical-align: -.25em; |
Urs Wolfer | 3752568 | 2016-01-22 11:57:10 +0100 | [diff] [blame] | 31 | } |
| 32 | .text:hover { |
| 33 | @apply(--gr-account-label-text-hover-style); |
| 34 | } |
| 35 | </style> |
| 36 | <span title$="[[_computeAccountTitle(account)]]"> |
| 37 | <gr-avatar account="[[account]]" |
| 38 | image-size="[[avatarImageSize]]"></gr-avatar> |
| 39 | <span class="text"> |
| 40 | <span>[[account.name]]</span> |
| 41 | <span hidden$="[[!_computeShowEmail(showEmail, account)]]"> |
| 42 | ([[account.email]]) |
| 43 | </span> |
| 44 | </span> |
| 45 | </span> |
| 46 | </template> |
| 47 | <script> |
| 48 | (function() { |
| 49 | 'use strict'; |
| 50 | |
| 51 | Polymer({ |
| 52 | is: 'gr-account-label', |
| 53 | |
| 54 | properties: { |
| 55 | account: Object, |
| 56 | avatarImageSize: { |
| 57 | type: Number, |
| 58 | value: 32, |
| 59 | }, |
| 60 | showEmail: { |
| 61 | type: Boolean, |
| 62 | value: false, |
| 63 | }, |
| 64 | }, |
| 65 | |
| 66 | _computeAccountTitle: function(account) { |
| 67 | if (!account || !account.name) { return; } |
| 68 | var result = util.escapeHTML(account.name); |
| 69 | if (account.email) { |
| 70 | result += ' <' + util.escapeHTML(account.email) + '>'; |
| 71 | } |
| 72 | return result; |
| 73 | }, |
| 74 | |
| 75 | _computeShowEmail: function(showEmail, account) { |
| 76 | return !!(showEmail && account && account.email); |
| 77 | }, |
| 78 | |
| 79 | }); |
| 80 | })(); |
| 81 | </script> |
| 82 | </dom-module> |