1
0

PhotoAlbumPresenter.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <div v-if="status.sensitive == true">
  3. <details class="details-animated">
  4. <summary @click="loadSensitive">
  5. <p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
  6. <p class="font-weight-light">(click to show)</p>
  7. </summary>
  8. <carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb">
  9. <slide v-for="(img, index) in status.media_attachments" :key="'px-carousel-'+img.id + '-' + index" class="w-100 h-100 d-block mx-auto text-center" :title="img.description">
  10. <img :class="img.filter_class + ' img-fluid'" :src="img.url" :alt="img.description" onerror="this.onerror=null;this.src='/storage/no-preview.png'">
  11. </slide>
  12. </carousel>
  13. </details>
  14. </div>
  15. <div v-else class="w-100 h-100 p-0">
  16. <carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb" class="p-0 m-0">
  17. <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">
  18. <img :class="img.filter_class + ' img-fluid w-100 p-0'" style="" :src="img.url" :alt="img.description" onerror="this.onerror=null;this.src='/storage/no-preview.png'">
  19. </slide>
  20. </carousel>
  21. </div>
  22. </template>
  23. <style type="text/css" scoped>
  24. .card-img-top {
  25. border-top-left-radius: 0 !important;
  26. border-top-right-radius: 0 !important;
  27. }
  28. </style>
  29. <script type="text/javascript">
  30. export default {
  31. props: ['status'],
  32. data() {
  33. return {
  34. cursor: 0
  35. }
  36. },
  37. created() {
  38. // window.addEventListener("keydown", this.keypressNavigation);
  39. },
  40. beforeDestroy() {
  41. // window.removeEventListener("keydown", this.keypressNavigation);
  42. },
  43. methods: {
  44. loadSensitive() {
  45. this.$refs.carousel.onResize();
  46. this.$refs.carousel.goToPage(0);
  47. },
  48. keypressNavigation(e) {
  49. let ref = this.$refs.carousel;
  50. if (e.keyCode == "37") {
  51. e.preventDefault();
  52. let direction = "backward";
  53. ref.advancePage(direction);
  54. ref.$emit("navigation-click", direction);
  55. }
  56. if (e.keyCode == "39") {
  57. e.preventDefault();
  58. let direction = "forward";
  59. ref.advancePage(direction);
  60. ref.$emit("navigation-click", direction);
  61. }
  62. }
  63. }
  64. }
  65. </script>