PhotoAlbumPresenter.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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">
  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">
  25. <carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb" class="p-0 m-0">
  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.filter_class + ' img-fluid w-100 p-0'"
  29. style=""
  30. :src="img.url"
  31. :alt="altText(img)"
  32. loading="lazy"
  33. onerror="this.onerror=null;this.src='/storage/no-preview.png'">
  34. <p v-if="!status.sensitive && sensitive"
  35. @click="status.sensitive = true"
  36. style="
  37. margin-top: 0;
  38. padding: 10px;
  39. color: #fff;
  40. font-size: 10px;
  41. text-align: right;
  42. position: absolute;
  43. top: 0;
  44. right: 0;
  45. border-top-left-radius: 5px;
  46. cursor: pointer;
  47. background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
  48. ">
  49. <i class="fas fa-eye-slash fa-lg"></i>
  50. </p>
  51. <p
  52. v-if="status.media_attachments[0].license"
  53. style="
  54. margin-bottom: 0;
  55. padding: 0 5px;
  56. color: #fff;
  57. font-size: 10px;
  58. text-align: right;
  59. position: absolute;
  60. bottom: 0;
  61. right: 0;
  62. border-top-left-radius: 5px;
  63. background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
  64. ">
  65. <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>
  66. </p>
  67. </slide>
  68. </carousel>
  69. </div>
  70. </template>
  71. <style type="text/css" scoped>
  72. .card-img-top {
  73. border-top-left-radius: 0 !important;
  74. border-top-right-radius: 0 !important;
  75. }
  76. .content-label-wrapper {
  77. position: relative;
  78. }
  79. .content-label {
  80. margin: 0;
  81. position: absolute;
  82. top:50%;
  83. left:50%;
  84. transform: translate(-50%, -50%);
  85. display: flex;
  86. flex-direction: column;
  87. align-items: center;
  88. justify-content: center;
  89. width: 100%;
  90. height: 100%;
  91. z-index: 2;
  92. background: rgba(0, 0, 0, 0.2)
  93. }
  94. </style>
  95. <script type="text/javascript">
  96. import BigPicture from 'bigpicture';
  97. export default {
  98. props: ['status'],
  99. data() {
  100. return {
  101. sensitive: this.status.sensitive,
  102. cursor: 0
  103. }
  104. },
  105. created() {
  106. // window.addEventListener("keydown", this.keypressNavigation);
  107. },
  108. beforeDestroy() {
  109. // window.removeEventListener("keydown", this.keypressNavigation);
  110. },
  111. methods: {
  112. toggleContentWarning(status) {
  113. this.$emit('togglecw');
  114. },
  115. toggleLightbox(e) {
  116. BigPicture({
  117. el: e.target
  118. })
  119. },
  120. altText(img) {
  121. let desc = img.description;
  122. if(desc) {
  123. return desc;
  124. }
  125. return 'Photo was not tagged with any alt text.';
  126. },
  127. keypressNavigation(e) {
  128. let ref = this.$refs.carousel;
  129. if (e.keyCode == "37") {
  130. e.preventDefault();
  131. let direction = "backward";
  132. ref.advancePage(direction);
  133. ref.$emit("navigation-click", direction);
  134. }
  135. if (e.keyCode == "39") {
  136. e.preventDefault();
  137. let direction = "forward";
  138. ref.advancePage(direction);
  139. ref.$emit("navigation-click", direction);
  140. }
  141. }
  142. }
  143. }
  144. </script>