logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

attachment.vue (7296B)


  1. <template>
  2. <button
  3. v-if="usePlaceholder"
  4. class="Attachment -placeholder button-unstyled"
  5. :class="classNames"
  6. @click="openModal"
  7. >
  8. <a
  9. v-if="type !== 'html'"
  10. class="placeholder"
  11. target="_blank"
  12. :href="attachment.url"
  13. :alt="attachment.description"
  14. :title="attachment.description"
  15. @click.prevent
  16. >
  17. <FAIcon :icon="placeholderIconClass" />
  18. <b>{{ nsfw ? "NSFW / " : "" }}</b>{{ edit ? '' : placeholderName }}
  19. </a>
  20. <div
  21. v-if="edit || remove"
  22. class="attachment-buttons"
  23. >
  24. <button
  25. v-if="remove"
  26. class="button-unstyled attachment-button"
  27. @click.prevent="onRemove"
  28. >
  29. <FAIcon icon="trash-alt" />
  30. </button>
  31. </div>
  32. <div
  33. v-if="size !== 'hide' && !hideDescription && (edit || localDescription || showDescription)"
  34. class="description-container"
  35. :class="{ '-static': !edit }"
  36. >
  37. <input
  38. v-if="edit"
  39. v-model="localDescription"
  40. type="text"
  41. class="input description-field"
  42. :placeholder="$t('post_status.media_description')"
  43. @keydown.enter.prevent=""
  44. >
  45. <p v-else>
  46. {{ localDescription }}
  47. </p>
  48. </div>
  49. </button>
  50. <div
  51. v-else
  52. class="Attachment"
  53. :class="classNames"
  54. >
  55. <div
  56. v-show="!isEmpty"
  57. class="attachment-wrapper"
  58. >
  59. <a
  60. v-if="hidden"
  61. class="image-container"
  62. :href="attachment.url"
  63. :alt="attachment.description"
  64. :title="attachment.description"
  65. @click.prevent.stop="toggleHidden"
  66. >
  67. <img
  68. :key="nsfwImage"
  69. class="nsfw"
  70. :src="nsfwImage"
  71. >
  72. <FAIcon
  73. v-if="type === 'video'"
  74. class="play-icon"
  75. icon="play-circle"
  76. />
  77. </a>
  78. <div
  79. v-if="!hidden"
  80. class="attachment-buttons"
  81. >
  82. <button
  83. v-if="type === 'flash' && flashLoaded"
  84. class="button-unstyled attachment-button"
  85. :title="$t('status.attachment_stop_flash')"
  86. @click.prevent="stopFlash"
  87. >
  88. <FAIcon icon="stop" />
  89. </button>
  90. <button
  91. v-if="attachment.description && size !== 'small' && !edit && type !== 'unknown'"
  92. class="button-unstyled attachment-button"
  93. :title="$t('status.show_attachment_description')"
  94. @click.prevent="toggleDescription"
  95. >
  96. <FAIcon icon="align-right" />
  97. </button>
  98. <button
  99. v-if="!useModal && type !== 'unknown'"
  100. class="button-unstyled attachment-button"
  101. :title="$t('status.show_attachment_in_modal')"
  102. @click.prevent="openModalForce"
  103. >
  104. <FAIcon icon="search-plus" />
  105. </button>
  106. <button
  107. v-if="nsfw && hideNsfwLocal"
  108. class="button-unstyled attachment-button"
  109. :title="$t('status.hide_attachment')"
  110. @click.prevent="toggleHidden"
  111. >
  112. <FAIcon icon="times" />
  113. </button>
  114. <button
  115. v-if="shiftUp"
  116. class="button-unstyled attachment-button"
  117. :title="$t('status.move_up')"
  118. @click.prevent="onShiftUp"
  119. >
  120. <FAIcon icon="chevron-left" />
  121. </button>
  122. <button
  123. v-if="shiftDn"
  124. class="button-unstyled attachment-button"
  125. :title="$t('status.move_down')"
  126. @click.prevent="onShiftDn"
  127. >
  128. <FAIcon icon="chevron-right" />
  129. </button>
  130. <button
  131. v-if="remove"
  132. class="button-unstyled attachment-button"
  133. :title="$t('status.remove_attachment')"
  134. @click.prevent="onRemove"
  135. >
  136. <FAIcon icon="trash-alt" />
  137. </button>
  138. </div>
  139. <a
  140. v-if="type === 'image' && (!hidden || preloadImage)"
  141. class="image-container"
  142. :class="{'-hidden': hidden && preloadImage }"
  143. :href="attachment.url"
  144. target="_blank"
  145. @click.stop.prevent="openModal"
  146. >
  147. <StillImage
  148. class="image"
  149. :referrerpolicy="referrerpolicy"
  150. :mimetype="attachment.mimetype"
  151. :src="attachment.large_thumb_url || attachment.url"
  152. :image-load-handler="onImageLoad"
  153. :alt="attachment.description"
  154. />
  155. </a>
  156. <a
  157. v-if="type === 'unknown' && !hidden"
  158. class="placeholder-container"
  159. :href="attachment.url"
  160. target="_blank"
  161. >
  162. <FAIcon
  163. :size="compact ? '2x' : '5x'"
  164. :icon="placeholderIconClass"
  165. :title="localDescription"
  166. />
  167. <p v-if="!compact">
  168. {{ localDescription }}
  169. </p>
  170. </a>
  171. <component
  172. :is="videoTag"
  173. v-if="type === 'video' && !hidden"
  174. class="video-container"
  175. :href="attachment.url"
  176. @click.stop.prevent="openModal"
  177. >
  178. <VideoAttachment
  179. class="video"
  180. :attachment="attachment"
  181. :controls="!useModal"
  182. @play="$emit('play')"
  183. @pause="$emit('pause')"
  184. />
  185. <FAIcon
  186. v-if="useModal"
  187. class="play-icon"
  188. icon="play-circle"
  189. />
  190. </component>
  191. <span
  192. v-if="type === 'audio' && !hidden"
  193. class="audio-container"
  194. :href="attachment.url"
  195. @click.stop.prevent="openModal"
  196. >
  197. <audio
  198. v-if="type === 'audio'"
  199. :src="attachment.url"
  200. :alt="attachment.description"
  201. :title="attachment.description"
  202. controls
  203. @play="$emit('play')"
  204. @pause="$emit('pause')"
  205. />
  206. </span>
  207. <div
  208. v-if="type === 'html' && attachment.oembed"
  209. class="oembed-container"
  210. @click.prevent="linkClicked"
  211. >
  212. <div
  213. v-if="attachment.thumb_url"
  214. class="image"
  215. >
  216. <img :src="attachment.thumb_url">
  217. </div>
  218. <div class="text">
  219. <!-- eslint-disable vue/no-v-html -->
  220. <h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
  221. <div v-html="attachment.oembed.oembedHTML" />
  222. <!-- eslint-enable vue/no-v-html -->
  223. </div>
  224. </div>
  225. <span
  226. v-if="type === 'flash' && !hidden"
  227. class="flash-container"
  228. :href="attachment.url"
  229. @click.stop.prevent="openModal"
  230. >
  231. <Flash
  232. ref="flash"
  233. class="flash"
  234. :src="attachment.large_thumb_url || attachment.url"
  235. @playerOpened="setFlashLoaded(true)"
  236. @playerClosed="setFlashLoaded(false)"
  237. />
  238. </span>
  239. </div>
  240. <div
  241. v-if="size !== 'hide' && !hideDescription && (edit || (localDescription && showDescription))"
  242. class="description-container"
  243. :class="{ '-static': !edit }"
  244. >
  245. <input
  246. v-if="edit"
  247. v-model="localDescription"
  248. type="text"
  249. class="input description-field"
  250. :placeholder="$t('post_status.media_description')"
  251. @keydown.enter.prevent=""
  252. >
  253. <p v-else>
  254. {{ localDescription }}
  255. </p>
  256. </div>
  257. </div>
  258. </template>
  259. <script src="./attachment.js"></script>
  260. <style src="./attachment.scss" lang="scss"></style>