PhotoAlbumPresenter.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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="altText(img)" 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="altText(img)" 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. altText(img) {
  49. let desc = img.description;
  50. if(desc) {
  51. return desc;
  52. }
  53. return 'Photo was not tagged with any alt text.';
  54. },
  55. keypressNavigation(e) {
  56. let ref = this.$refs.carousel;
  57. if (e.keyCode == "37") {
  58. e.preventDefault();
  59. let direction = "backward";
  60. ref.advancePage(direction);
  61. ref.$emit("navigation-click", direction);
  62. }
  63. if (e.keyCode == "39") {
  64. e.preventDefault();
  65. let direction = "forward";
  66. ref.advancePage(direction);
  67. ref.$emit("navigation-click", direction);
  68. }
  69. }
  70. }
  71. }
  72. </script>