yandere_fe/src/components/attachment/attachment.vue

266 lines
7.1 KiB
Vue
Raw Normal View History

2016-10-28 09:08:03 -07:00
<template>
<button
v-if="usePlaceholder"
class="Attachment -placeholder button-unstyled"
:class="classNames"
2019-07-05 00:17:44 -07:00
@click="openModal"
>
<a
2019-01-26 07:45:03 -08:00
v-if="type !== 'html'"
2019-07-05 00:17:44 -07:00
class="placeholder"
target="_blank"
:href="attachment.url"
:alt="attachment.description"
:title="attachment.description"
@click.prevent
2019-01-26 07:45:03 -08:00
>
2020-10-20 14:01:28 -07:00
<FAIcon :icon="placeholderIconClass" />
2021-06-22 10:47:35 -07:00
<b>{{ nsfw ? "NSFW / " : "" }}</b>{{ edit ? '' : placeholderName }}
2019-01-26 07:45:03 -08:00
</a>
<div
v-if="edit || remove"
2021-06-22 10:47:35 -07:00
class="attachment-buttons"
>
<button
v-if="remove"
class="button-unstyled attachment-button"
@click.prevent="onRemove"
>
<FAIcon icon="trash-alt" />
</button>
</div>
<div
v-if="size !== 'hide' && !hideDescription && (edit || localDescription || showDescription)"
class="description-container"
:class="{ '-static': !edit }"
>
<input
v-if="edit"
v-model="localDescription"
type="text"
class="description-field"
:placeholder="$t('post_status.media_description')"
@keydown.enter.prevent=""
>
<p v-else>
{{ localDescription }}
</p>
</div>
</button>
<div
2021-06-22 10:47:35 -07:00
v-else
class="Attachment"
:class="classNames"
>
<div
2021-06-17 16:04:01 -07:00
v-show="!isEmpty"
2021-06-22 10:47:35 -07:00
class="attachment-wrapper"
>
2021-06-17 16:04:01 -07:00
<a
v-if="hidden"
class="image-container"
:href="attachment.url"
2019-02-17 21:03:26 -08:00
:alt="attachment.description"
2021-06-17 16:04:01 -07:00
:title="attachment.description"
@click.prevent.stop="toggleHidden"
>
<img
:key="nsfwImage"
class="nsfw"
:src="nsfwImage"
>
<FAIcon
v-if="type === 'video'"
class="play-icon"
icon="play-circle"
/>
</a>
<div
v-if="!hidden"
2021-06-22 10:47:35 -07:00
class="attachment-buttons"
>
2021-06-17 16:04:01 -07:00
<button
v-if="type === 'flash' && flashLoaded"
class="button-unstyled attachment-button"
@click.prevent="stopFlash"
:title="$t('status.attachment_stop_flash')"
2021-06-17 16:04:01 -07:00
>
<FAIcon icon="stop" />
</button>
2021-08-15 11:04:28 -07:00
<button
2022-02-10 05:42:28 -08:00
v-if="attachment.description && size !== 'small' && !edit && type !== 'unknown'"
2021-08-15 11:04:28 -07:00
class="button-unstyled attachment-button"
@click.prevent="toggleDescription"
:title="$t('status.show_attachment_description')"
>
<FAIcon icon="align-right" />
</button>
2021-06-17 16:04:01 -07:00
<button
2022-02-10 05:42:28 -08:00
v-if="!useModal && type !== 'unknown'"
2021-06-17 16:04:01 -07:00
class="button-unstyled attachment-button"
@click.prevent="openModalForce"
:title="$t('status.show_attachment_in_modal')"
2021-06-17 16:04:01 -07:00
>
<FAIcon icon="search-plus" />
</button>
<button
v-if="nsfw && hideNsfwLocal"
class="button-unstyled attachment-button"
@click.prevent="toggleHidden"
:title="$t('status.hide_attachment')"
2021-06-17 16:04:01 -07:00
>
<FAIcon icon="times" />
</button>
<button
v-if="shiftUp"
class="button-unstyled attachment-button"
@click.prevent="onShiftUp"
:title="$t('status.move_up')"
>
<FAIcon icon="chevron-left" />
</button>
<button
v-if="shiftDn"
class="button-unstyled attachment-button"
@click.prevent="onShiftDn"
:title="$t('status.move_down')"
>
<FAIcon icon="chevron-right" />
</button>
2021-06-17 16:04:01 -07:00
<button
v-if="remove"
class="button-unstyled attachment-button"
@click.prevent="onRemove"
:title="$t('status.remove_attachment')"
2021-06-17 16:04:01 -07:00
>
<FAIcon icon="trash-alt" />
</button>
</div>
2016-10-28 09:08:03 -07:00
2021-06-17 16:04:01 -07:00
<a
v-if="type === 'image' && (!hidden || preloadImage)"
class="image-container"
:class="{'-hidden': hidden && preloadImage }"
:href="attachment.url"
target="_blank"
@click.stop.prevent="openModal"
>
<StillImage
class="image"
:referrerpolicy="referrerpolicy"
:mimetype="attachment.mimetype"
:src="attachment.large_thumb_url || attachment.url"
:image-load-handler="onImageLoad"
:alt="attachment.description"
/>
</a>
2016-10-28 09:08:03 -07:00
2022-02-10 05:42:28 -08:00
<a
v-if="type === 'unknown' && !hidden"
class="placeholder-container"
:href="attachment.url"
target="_blank"
>
<FAIcon size="5x" :icon="placeholderIconClass" />
<p>
{{ localDescription }}
</p>
</a>
<component
:is="videoTag"
2021-06-17 16:04:01 -07:00
v-if="type === 'video' && !hidden"
class="video-container"
:class="{ 'button-unstyled': 'isModal' }"
2021-06-17 16:04:01 -07:00
:href="attachment.url"
@click.stop.prevent="openModal"
>
<VideoAttachment
class="video"
:attachment="attachment"
:controls="!useModal"
@play="$emit('play')"
@pause="$emit('pause')"
/>
<FAIcon
v-if="useModal"
class="play-icon"
icon="play-circle"
/>
</component>
2021-06-17 16:04:01 -07:00
<span
2021-06-17 16:04:01 -07:00
v-if="type === 'audio' && !hidden"
class="audio-container"
:href="attachment.url"
@click.stop.prevent="openModal"
>
<audio
v-if="type === 'audio'"
:src="attachment.url"
:alt="attachment.description"
:title="attachment.description"
controls
@play="$emit('play')"
@pause="$emit('pause')"
/>
</span>
2016-11-22 10:45:18 -08:00
2019-07-05 00:17:44 -07:00
<div
2021-06-17 16:04:01 -07:00
v-if="type === 'html' && attachment.oembed"
class="oembed-container"
@click.prevent="linkClicked"
2019-07-05 00:17:44 -07:00
>
2021-06-17 16:04:01 -07:00
<div
v-if="attachment.thumb_url"
class="image"
>
<img :src="attachment.thumb_url">
</div>
<div class="text">
<!-- eslint-disable vue/no-v-html -->
<h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
<div v-html="attachment.oembed.oembedHTML" />
<!-- eslint-enable vue/no-v-html -->
</div>
2016-10-28 16:38:41 -07:00
</div>
<span
2021-06-17 16:04:01 -07:00
v-if="type === 'flash' && !hidden"
class="flash-container"
:href="attachment.url"
@click.stop.prevent="openModal"
>
<Flash
ref="flash"
2021-06-22 10:47:35 -07:00
class="flash"
2021-06-17 16:04:01 -07:00
:src="attachment.large_thumb_url || attachment.url"
@playerOpened="setFlashLoaded(true)"
@playerClosed="setFlashLoaded(false)"
/>
</span>
2021-06-17 16:04:01 -07:00
</div>
<div
v-if="size !== 'hide' && !hideDescription && (edit || (localDescription && showDescription))"
2021-06-17 16:04:01 -07:00
class="description-container"
:class="{ '-static': !edit }"
>
2021-06-17 16:04:01 -07:00
<input
v-if="edit"
v-model="localDescription"
type="text"
class="description-field"
:placeholder="$t('post_status.media_description')"
@keydown.enter.prevent=""
>
<p v-else>
{{ localDescription }}
</p>
</div>
2016-10-28 09:08:03 -07:00
</div>
</template>
<script src="./attachment.js"></script>
2016-10-28 16:38:41 -07:00
<style src="./attachment.scss" lang="scss"></style>