1
0

PhotoAlbumPresenter.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div v-if="status.sensitive == true" class="content-label-wrapper">
  3. <div class="text-light content-label">
  4. <p class="text-center">
  5. <i class="far fa-eye-slash fa-2x"></i>
  6. </p>
  7. <p class="h4 font-weight-bold text-center">
  8. Sensitive Content
  9. </p>
  10. <p class="text-center py-2 content-label-text">
  11. {{ status.spoiler_text ? status.spoiler_text : 'This album may contain sensitive content.'}}
  12. </p>
  13. <p class="mb-0">
  14. <button @click="toggleContentWarning()" class="btn btn-outline-light btn-block btn-sm font-weight-bold">See Post</button>
  15. </p>
  16. </div>
  17. <blur-hash-image
  18. width="32"
  19. height="32"
  20. :punch="1"
  21. :hash="status.media_attachments[0].blurhash"
  22. :alt="altText(status)"/>
  23. </div>
  24. <div v-else class="w-100 h-100 p-0 album-wrapper">
  25. <carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb" class="p-0 m-0" :id="'carousel-' + status.id">
  26. <slide v-for="(img, index) in status.media_attachments" :key="'px-carousel-'+img.id + '-' + index" class="" style="background: #000; display: flex;align-items: center;" :title="img.description">
  27. <img
  28. class="img-fluid w-100 p-0"
  29. :src="img.url"
  30. :alt="altText(img)"
  31. loading="lazy"
  32. :data-bp="img.url"
  33. onerror="this.onerror=null;this.src='/storage/no-preview.png'">
  34. </slide>
  35. </carousel>
  36. <div class="album-overlay">
  37. <p v-if="!status.sensitive && sensitive"
  38. @click="status.sensitive = true"
  39. style="
  40. margin-top: 0;
  41. padding: 10px;
  42. color: #fff;
  43. font-size: 10px;
  44. text-align: right;
  45. position: absolute;
  46. top: 0;
  47. right: 0;
  48. border-top-left-radius: 5px;
  49. cursor: pointer;
  50. background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
  51. ">
  52. <i class="fas fa-eye-slash fa-lg"></i>
  53. </p>
  54. <p @click.prevent="toggleLightbox"
  55. style="
  56. margin-top: 0;
  57. padding: 10px;
  58. color: #fff;
  59. font-size: 10px;
  60. text-align: right;
  61. position: absolute;
  62. left: 0;
  63. top: 0;
  64. border-bottom-right-radius: 5px;
  65. cursor: pointer;
  66. background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
  67. ">
  68. <i class="fas fa-expand fa-lg"></i>
  69. </p>
  70. <p
  71. v-if="status.media_attachments[0].license"
  72. style="
  73. margin-bottom: 0;
  74. padding: 0 5px;
  75. color: #fff;
  76. font-size: 10px;
  77. text-align: right;
  78. position: absolute;
  79. bottom: 0;
  80. right: 0;
  81. border-top-left-radius: 5px;
  82. background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
  83. ">
  84. <a :href="status.url" class="font-weight-bold text-light">Photo</a> by <a :href="status.account.url" class="font-weight-bold text-light">&commat;{{status.account.username}}</a> licensed under <a :href="status.media_attachments[0].license.url" class="font-weight-bold text-light">{{status.media_attachments[0].license.title}}</a>
  85. </p>
  86. </div>
  87. </div>
  88. </template>
  89. <script type="text/javascript">
  90. import BigPicture from 'bigpicture';
  91. export default {
  92. props: ['status'],
  93. data() {
  94. return {
  95. sensitive: this.status.sensitive,
  96. cursor: 0
  97. }
  98. },
  99. created() {
  100. // window.addEventListener("keydown", this.keypressNavigation);
  101. },
  102. beforeDestroy() {
  103. // window.removeEventListener("keydown", this.keypressNavigation);
  104. },
  105. methods: {
  106. toggleContentWarning(status) {
  107. this.$emit('togglecw');
  108. },
  109. toggleLightbox(e) {
  110. BigPicture({
  111. el: e.target,
  112. gallery: '#carousel-' + this.status.id,
  113. position: this.$refs.carousel.currentPage
  114. })
  115. },
  116. altText(img) {
  117. let desc = img.description;
  118. if(desc) {
  119. return desc;
  120. }
  121. return 'Photo was not tagged with any alt text.';
  122. },
  123. keypressNavigation(e) {
  124. let ref = this.$refs.carousel;
  125. if (e.keyCode == "37") {
  126. e.preventDefault();
  127. let direction = "backward";
  128. ref.advancePage(direction);
  129. ref.$emit("navigation-click", direction);
  130. }
  131. if (e.keyCode == "39") {
  132. e.preventDefault();
  133. let direction = "forward";
  134. ref.advancePage(direction);
  135. ref.$emit("navigation-click", direction);
  136. }
  137. }
  138. }
  139. }
  140. </script>
  141. <style type="text/css" scoped>
  142. .card-img-top {
  143. border-top-left-radius: 0 !important;
  144. border-top-right-radius: 0 !important;
  145. }
  146. .content-label-wrapper {
  147. position: relative;
  148. }
  149. .content-label {
  150. margin: 0;
  151. position: absolute;
  152. top:50%;
  153. left:50%;
  154. transform: translate(-50%, -50%);
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. justify-content: center;
  159. width: 100%;
  160. height: 100%;
  161. z-index: 2;
  162. background: rgba(0, 0, 0, 0.2)
  163. }
  164. .album-wrapper {
  165. position: relative;
  166. }
  167. </style>