PostPresenter.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <style>
  2. .carousel {
  3. position: relative;
  4. width: 600px;
  5. height: 400px;
  6. overflow: hidden;
  7. margin: 0 auto;
  8. }
  9. .carousel:hover .slide:after,
  10. .carousel:hover .counter,
  11. .carousel:hover .slide:before {
  12. opacity: 1;
  13. }
  14. .slide {
  15. float: right;
  16. position: absolute;
  17. z-index: 1;
  18. width: 600px;
  19. height: 400px;
  20. background-color: #fff;
  21. text-align: center;
  22. transition: opacity 0.4s;
  23. opacity: 1;
  24. }
  25. .slide:before {
  26. content: attr(annot);
  27. display: block;
  28. position: absolute;
  29. left: 20px;
  30. bottom: 20px;
  31. color: #fff;
  32. font-size: 14px;
  33. font-weight: bold;
  34. z-index: 12;
  35. opacity: 0;
  36. transition: opacity 0.3s;
  37. }
  38. .slide:after {
  39. content: attr(slide);
  40. display: block;
  41. position: absolute;
  42. bottom: 0;
  43. transition: opacity 0.3s;
  44. width: 100%;
  45. height: 80px;
  46. opacity: 0;
  47. background-image: linear-gradient(transparent, rgba(0,0,0,0.2));
  48. text-align: left;
  49. text-indent: 549px;
  50. line-height: 101px;
  51. font-size: 13px;
  52. color: #fff;
  53. font-weight: bold;
  54. }
  55. .counter {
  56. position: absolute;
  57. bottom: 20px;
  58. right: 2px;
  59. height: 20px;
  60. width: 60px;
  61. z-index: 2;
  62. text-align: center;
  63. color: #fff;
  64. line-height: 21px;
  65. font-size: 13px;
  66. font-weight: bold;
  67. opacity: 0;
  68. transition: opacity 0.3s;
  69. }
  70. .carousel-slide {
  71. top: 0;
  72. right: 0;
  73. float: right;
  74. position: absolute;
  75. margin-top: 0;
  76. z-index: 9;
  77. height: 100%;
  78. width: 100%;
  79. opacity: 0;
  80. cursor: pointer;
  81. }
  82. .carousel-slide:checked {
  83. z-index: 8;
  84. }
  85. .carousel-slide:checked + .slide {
  86. opacity: 0;
  87. }
  88. .carousel-slide:checked:nth-child(1):checked {
  89. z-index: 9;
  90. }
  91. .carousel-slide:nth-child(1):checked {
  92. float: left;
  93. z-index: 9;
  94. }
  95. .carousel-slide:nth-child(1):checked + .slide {
  96. opacity: 1;
  97. }
  98. .carousel-slide:nth-child(1):checked ~ .carousel-slide {
  99. float: left;
  100. z-index: 8;
  101. }
  102. .carousel-slide:nth-child(1):checked ~ .carousel-slide + .slide {
  103. opacity: 0;
  104. }
  105. .carousel-slide:nth-child(1):checked ~ .carousel-slide:checked {
  106. z-index: 9;
  107. }
  108. .carousel-slide:nth-child(1):checked ~ .carousel-slide:checked + .slide {
  109. opacity: 1;
  110. }
  111. </style>
  112. <template>
  113. <div class="">
  114. <div class="postPresenterLoader text-center">
  115. <div class="lds-ring"><div></div><div></div><div></div><div></div></div>
  116. </div>
  117. <div class="postPresenterContainer d-none">
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. pixelfed.presenter = {
  123. show: {
  124. image: function(container, media) {
  125. let wrapper = $('<div>');
  126. wrapper.addClass(media[0]['filter_class']);
  127. let el = $('<img>');
  128. el.attr('src', media[0]['url']);
  129. el.attr('title', media[0]['description']);
  130. wrapper.append(el);
  131. container.append(wrapper);
  132. },
  133. video: function(container, media) {
  134. let wrapper = $('<div>');
  135. wrapper.addClass('embed-responsive embed-responsive-4by3');
  136. let el = $('<video>');
  137. el.addClass('embed-responsive-item');
  138. el.attr('controls', '');
  139. el.attr('src', media[0]['url']);
  140. el.attr('title', media[0]['description']);
  141. wrapper.append(el);
  142. container.append(wrapper);
  143. },
  144. imageAlbum: function(container, media) {
  145. let wrapper = $('<div>');
  146. wrapper.addClass('carousel');
  147. let counter = $('<div>');
  148. counter.attr('class', 'counter');
  149. counter.attr('count', media.length);
  150. counter.text(' / ' + media.length);
  151. for(var i = media.length - 1; i >= 0; i--) {
  152. let item = media[i];
  153. let carouselItem = $('<div>').addClass('slide d-flex align-items-center');
  154. carouselItem.attr('slide', i + 1);
  155. carouselItem.attr('annot', item.description);
  156. let check = $('<input>');
  157. check.attr('type', 'checkbox');
  158. check.attr('class', 'carousel-slide');
  159. let img = $('<img>');
  160. img.addClass('img-fluid');
  161. img.attr('src', item['url']);
  162. carouselItem.append(img);
  163. wrapper.append(check);
  164. wrapper.append(carouselItem);
  165. pixelfed.orientation.set(item.orientation);
  166. }
  167. wrapper.append(counter);
  168. container.append(wrapper);
  169. }
  170. }
  171. };
  172. export default {
  173. props: ['status-id', 'status-username', 'status-template']
  174. }
  175. </script>