buddy-finder.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. {{_clickExplanation1}} Device to send File.
  97. <br> {{_clickExplanation2}} to send a 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. (function() {
  115. var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  116. Polymer({
  117. is: 'buddy-finder',
  118. properties: {
  119. buddies: {
  120. type: Array,
  121. notify: true
  122. },
  123. me: {
  124. type: String,
  125. },
  126. _showExplanation: {
  127. computed: '_computeShowExplanation(buddies.length)',
  128. value: false
  129. },
  130. twoLinesOfBuddies: {
  131. value: false
  132. },
  133. _clickExplanation1: {
  134. value: (function() {
  135. if (isMobile) {
  136. return 'Tap';
  137. } else {
  138. return 'Click';
  139. }
  140. })
  141. },
  142. _clickExplanation2: {
  143. value: (function() {
  144. if (isMobile) {
  145. return 'Long Press';
  146. } else {
  147. return 'Right Click';
  148. }
  149. })
  150. }
  151. },
  152. observers: [
  153. '_buddiesChanged(buddies.splices)'
  154. ],
  155. _fileSelected: function(e) {
  156. var peerId = e.model.item.peerId;
  157. var file = e.detail;
  158. app.conn.sendFile(peerId, file);
  159. //document.querySelector('#ads').open();
  160. },
  161. _computeShowExplanation: function(nBuddies) {
  162. if (!nBuddies || nBuddies === 0) {
  163. return false;
  164. }
  165. if (nBuddies < 3) {
  166. return true;
  167. }
  168. },
  169. _buddiesChanged: function() {
  170. var length = window.innerWidth / 120;
  171. this.set('twoLinesOfBuddies', (this.buddies.length > length));
  172. }
  173. });
  174. }());
  175. </script>
  176. </dom-module>