PhotoAlbumPresenter.vue 3.9 KB

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