yandere_fe/src/components/attachment/attachment.vue

166 lines
3.9 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"
2019-01-26 07:45:03 -08:00
>
2020-10-20 14:01:28 -07:00
<FAIcon :icon="placeholderIconClass" />
<b>{{ nsfw ? "NSFW / " : "" }}</b>{{ placeholderName }}
2019-01-26 07:45:03 -08:00
</a>
</button>
<div
2019-07-05 00:17:44 -07:00
v-else
v-show="!isEmpty"
class="Attachment"
:class="classNames"
>
2019-07-05 00:17:44 -07:00
<a
v-if="hidden"
class="image-container"
2019-07-05 00:17:44 -07:00
:href="attachment.url"
:alt="attachment.description"
:title="attachment.description"
@click.prevent.stop="toggleHidden"
2019-07-05 00:17:44 -07:00
>
<img
:key="nsfwImage"
class="nsfw"
:src="nsfwImage"
>
2020-10-20 14:01:28 -07:00
<FAIcon
2019-07-05 00:17:44 -07:00
v-if="type === 'video'"
2020-10-20 14:31:16 -07:00
class="play-icon"
icon="play-circle"
2019-07-05 00:17:44 -07:00
/>
2016-10-28 09:08:03 -07:00
</a>
<div
class="attachment-buttons"
v-if="!hidden"
>
<button
v-if="type === 'flash' && flashLoaded"
class="button-unstyled attachment-button"
@click.prevent="stopFlash"
>
<FAIcon icon="stop" />
</button>
<button
v-if="!useModal"
class="button-unstyled attachment-button"
@click.prevent="openModalForce"
>
<FAIcon icon="search-plus" />
</button>
<button
v-if="nsfw && hideNsfwLocal"
class="button-unstyled attachment-button"
@click.prevent="toggleHidden"
>
<FAIcon icon="times" />
</button>
</div>
2019-07-05 00:17:44 -07:00
<a
v-if="type === 'image' && (!hidden || preloadImage)"
class="image-container"
:class="{'-hidden': hidden && preloadImage }"
2019-07-05 00:17:44 -07:00
:href="attachment.url"
target="_blank"
@click.stop.prevent="openModal"
>
2019-07-05 00:17:44 -07:00
<StillImage
class="image"
2019-07-05 00:17:44 -07:00
:referrerpolicy="referrerpolicy"
:mimetype="attachment.mimetype"
:src="attachment.large_thumb_url || attachment.url"
:image-load-handler="onImageLoad"
2019-02-17 21:03:26 -08:00
:alt="attachment.description"
2019-07-05 00:17:44 -07:00
/>
2016-11-25 16:19:25 -08:00
</a>
2016-10-28 09:08:03 -07:00
2019-07-05 00:17:44 -07:00
<a
v-if="type === 'video' && !hidden"
2019-07-05 00:17:44 -07:00
class="video-container"
:href="attachment.url"
@click.stop.prevent="openModal"
>
2019-07-05 00:17:44 -07:00
<VideoAttachment
class="video"
:attachment="attachment"
:controls="!useModal"
2020-09-29 03:18:37 -07:00
@play="$emit('play')"
@pause="$emit('pause')"
2019-07-05 00:17:44 -07:00
/>
2020-10-20 14:01:28 -07:00
<FAIcon
v-if="useModal"
2020-10-20 14:31:16 -07:00
class="play-icon"
icon="play-circle"
2019-07-05 00:17:44 -07:00
/>
</a>
2016-10-28 09:08:03 -07:00
<a
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')"
/>
</a>
2016-11-22 10:45:18 -08:00
2019-07-05 00:17:44 -07:00
<div
v-if="type === 'html' && attachment.oembed"
class="oembed-container"
2019-07-05 00:17:44 -07:00
@click.prevent="linkClicked"
>
<div
v-if="attachment.thumb_url"
class="image"
>
<img :src="attachment.thumb_url">
2016-10-28 16:38:41 -07:00
</div>
<div class="text">
2019-07-06 14:54:17 -07:00
<!-- eslint-disable vue/no-v-html -->
2019-07-05 00:17:44 -07:00
<h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
<div v-html="attachment.oembed.oembedHTML" />
2019-07-12 12:11:54 -07:00
<!-- eslint-enable vue/no-v-html -->
2016-10-28 16:38:41 -07:00
</div>
</div>
<a
v-if="type === 'flash' && !hidden"
class="flash-container"
:href="attachment.url"
@click.stop.prevent="openModal"
>
<Flash
class="flash"
ref="flash"
:src="attachment.large_thumb_url || attachment.url"
@playerOpened="setFlashLoaded(true)"
@playerClosed="setFlashLoaded(false)"
/>
</a>
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>