buddy-finder.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
  2. <link rel="import" href="../../bower_components/paper-styles/paper-styles.html">
  3. <link rel="import" href="buddy-avatar.html">
  4. <link rel="import" href="personal-avatar.html">
  5. <dom-module id="buddy-finder">
  6. <template>
  7. <style>
  8. :host {
  9. background-color: transparent;
  10. @apply(--layout-fit);
  11. @apply(--layout-horizontal);
  12. @apply(--layout-center-center);
  13. -webkit-user-select: none;
  14. -moz-user-select: none;
  15. -ms-user-select: none;
  16. user-select: none;
  17. margin: 0;
  18. --paper-tooltip: {
  19. font-size: 14px;
  20. background-color: #4285f4;
  21. }
  22. }
  23. .buddies {
  24. z-index: 1;
  25. @apply(--layout-horizontal);
  26. @apply(--layout-center-center);
  27. @apply(--layout-wrap);
  28. }
  29. .explanation {
  30. @apply(--paper-font-headline);
  31. color: #4285f4;
  32. text-align: center;
  33. cursor: default;
  34. }
  35. .short {
  36. font-size: 14px;
  37. line-height: 20px;
  38. color: #727272;
  39. }
  40. .short a {
  41. color: #4285f4;
  42. text-decoration: none;
  43. }
  44. .explanation:hover a {
  45. transform: scale(1.1);
  46. }
  47. @media all and (max-width: 600px) {
  48. .explanation {
  49. width: 340px;
  50. }
  51. }
  52. @media all and (max-height: 440px) {
  53. .buddies {
  54. padding-top: 56px;
  55. @apply(--layout-self-start);
  56. }
  57. }
  58. @media all and (max-height: 600px) {
  59. .buddies[two-lines] {
  60. padding-top: 56px;
  61. @apply(--layout-self-start);
  62. }
  63. }
  64. .explanation2 {
  65. display: none;
  66. position: absolute;
  67. width: 296px;
  68. margin-left: -148px;
  69. left: 50%;
  70. @apply(--paper-font-title);
  71. color: rgba(66, 133, 244, 0.65);
  72. text-align: center;
  73. opacity: 0;
  74. -webkit-transition: opacity 500ms ease-out;
  75. -moz-transition: opacity 500ms ease-out;
  76. -o-transition: opacity 500ms ease-out;
  77. transition: opacity 500ms ease-out;
  78. z-index: 0;
  79. }
  80. @media all and (min-height: 441px) and (max-height: 559px) {
  81. .explanation2 {
  82. display: block;
  83. top: 64px;
  84. opacity: 1;
  85. }
  86. }
  87. @media all and (min-height: 560px) {
  88. .explanation2 {
  89. display: block;
  90. top: 128px;
  91. opacity: 1;
  92. }
  93. }
  94. </style>
  95. <div class="explanation2" hidden$="{{!_showExplanation}}">
  96. Tap to send File.
  97. <br> Long Press to send Text.
  98. </div>
  99. <div class="buddies" two-lines$="{{twoLinesOfBuddies}}">
  100. <template is="dom-repeat" items="{{buddies}}">
  101. <buddy-avatar on-file-selected="_fileSelected" only$="{{!buddies.1}}" contact="{{item}}"></buddy-avatar>
  102. </template>
  103. </div>
  104. <div hidden$="{{buddies.0}}" class="explanation">
  105. Open Snapdrop on other devices to send files.
  106. <div class="short">
  107. Short link: <a href="http://yg.gl" target="_blank">yg.gl</a>
  108. </div>
  109. </div>
  110. <personal-avatar class="me"></personal-avatar>
  111. </template>
  112. <script>
  113. 'use strict';
  114. Polymer({
  115. is: 'buddy-finder',
  116. properties: {
  117. buddies: {
  118. type: Array,
  119. notify: true
  120. },
  121. me: {
  122. type: String,
  123. },
  124. _showExplanation: {
  125. computed: '_computeShowExplanation(buddies.length)',
  126. value: false
  127. },
  128. twoLinesOfBuddies: {
  129. value: false
  130. }
  131. },
  132. observers: [
  133. '_buddiesChanged(buddies.splices)'
  134. ],
  135. _fileSelected: function(e) {
  136. var peerId = e.model.item.peerId;
  137. var file = e.detail;
  138. app.conn.sendFile(peerId, file);
  139. },
  140. _computeShowExplanation: function(nBuddies) {
  141. if (!nBuddies || nBuddies === 0) {
  142. return false;
  143. }
  144. if (nBuddies < 3) {
  145. return true;
  146. }
  147. },
  148. _buddiesChanged: function() {
  149. var length = window.innerWidth / 120;
  150. this.set('twoLinesOfBuddies', (this.buddies.length > length));
  151. }
  152. });
  153. </script>
  154. </dom-module>