Content.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div class="detail-main__article">
  3. <div v-html="rawHtml" ref="content"></div>
  4. <div class="tooltip-block" ref="tooltipBlock" v-show="tooltipShow">
  5. <div class="tooltip-block_title">{{ tooltipTitle }}</div>
  6. <div class="tooltip-block_text">{{ tooltipText }}</div>
  7. <div class="tooltip-block_close" @click="tooltipShow = false">
  8. <v-icon>mdi-close</v-icon>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import Vue from "vue";
  15. import VueSlickCarousel from "vue-slick-carousel";
  16. import "vue-slick-carousel/dist/vue-slick-carousel.css";
  17. import { createPopper } from "@popperjs/core";
  18. import Tinybox from "vue-tinybox";
  19. export default {
  20. props: {
  21. rawHtml: {
  22. type: String
  23. },
  24. isAdvert: {
  25. type: Boolean
  26. }
  27. },
  28. data () {
  29. return {
  30. tooltipShow: false,
  31. tooltipTitle: "",
  32. tooltipText: "",
  33. images: null,
  34. index: null
  35. };
  36. },
  37. computed: {
  38. content() {
  39. return this.rawHtml.split("##");
  40. },
  41. },
  42. mounted () {
  43. const secondParagaph = this.$refs.content.querySelectorAll("p")[1]
  44. if(this.$nuxt.$device.isMobile){
  45. const banner = document.createElement('p');
  46. banner.innerHTML = `
  47. <div id="adfox_167091964852627830" style="max-height: 80vh;">
  48. <div style="min-height: 300px;" class="adfox_placeholder"></div>
  49. </div>
  50. `
  51. secondParagaph.appendChild(banner)
  52. addEventListener('load', () => {
  53. window.yaContextCb.push(() => {
  54. // eslint-disable-next-line no-undef
  55. Ya.adfoxCode.createAdaptive({
  56. ownerId: 359693,
  57. containerId: 'adfox_167091964852627830',
  58. params: {
  59. pp: 'bufl',
  60. ps: 'gduo',
  61. p2: 'hywx'
  62. },
  63. lazyLoad: {
  64. fetchMargin: 100,
  65. mobileScaling: 1.3
  66. }
  67. },
  68. ['tablet', 'phone'], {
  69. tabletWidth: 899,
  70. phoneWidth: 480,
  71. isAutoReloads: true
  72. })
  73. })
  74. setInterval(function () {
  75. Ya.adfoxCode.reload('adfox_167091964852627830', {onlyIfWasVisible: true});
  76. }, 30000)
  77. })
  78. } else {
  79. const thirdParagraph = this.$refs.content.querySelectorAll('p')[2]
  80. if (typeof thirdParagraph !== 'undefined' && !this.isAdvert && 0) {
  81. // const videLib = document.createElement('script')
  82. // videLib.src = 'https://moevideo.biz/embed/js/mvpt.min.js'
  83. // thirdParagraph.appendChild(videLib)
  84. const videoBanner = document.createElement('p')
  85. videoBanner.innerHTML = '<div id="adv"></div>'
  86. thirdParagraph.appendChild(videoBanner)
  87. const script = document.createElement('script')
  88. script.innerHTML = `
  89. var moevideoQueue = moevideoQueue || []
  90. moevideoQueue.push(function () {
  91. moevideo.ContentRoll({
  92. mode: 'manual',
  93. el: '#adv',
  94. videoInstream: 'https://cdn1.playreplay.me/country.mp4',
  95. closeInstream: 'true',
  96. instream: true,
  97. maxRefresh: 3,
  98. ignorePlayers: true
  99. })
  100. })`
  101. thirdParagraph.appendChild(script)
  102. }
  103. }
  104. this.$refs.content.addEventListener("click", this.onClickContent);
  105. const galleries = this.$refs.content.querySelectorAll(".gallery");
  106. const slickComponent = Vue.extend({
  107. template: `<div><div class="detail-top__images"><vue-slick-carousel ref="galleryImages" :asNavFor="$refs.galleryThumbs" @beforeChange="syncSliders" v-if="images.length">
  108. <div class="single-article-content-slider-item" v-for="(image, i) in images" :key="i" >
  109. <img @click="index = i" :src="image.url" :alt="image.name"></img>
  110. <div v-if="image.name" class="image-title">{{ image.name }}</div>
  111. </div>
  112. <template #prevArrow="arrowOption">
  113. <button class="button button_news-slider button_news-slider-prev">
  114. <BaseIcon :name="'h-slider-prev'" clear />
  115. </button>
  116. </template>
  117. <template #nextArrow="arrowOption">
  118. <button class="button button_news-slider button_news-slider-next">
  119. <BaseIcon :name="'h-slider-next'" clear />
  120. </button>
  121. </template>
  122. </vue-slick-carousel> <div class="detail-top__thumbs">
  123. <vue-slick-carousel
  124. ref="galleryThumbs"
  125. :asNavFor="$refs.galleryImages"
  126. :focusOnSelect="true"
  127. :draggable="false"
  128. :touchThreshold="4"
  129. :slidesToScroll="1"
  130. :slidesToShow="4"
  131. :arrows="false"
  132. @beforeChange="syncSliders"
  133. >
  134. <div class="detail-top__thumb" v-for="(image, i) in images" :key="i">
  135. <img :src="image.url" :alt="image.name" />
  136. </div>
  137. </vue-slick-carousel>
  138. </div></div><Tinybox v-model="index" :images="img" /></div>`,
  139. components: { VueSlickCarousel, Tinybox },
  140. methods: {
  141. syncSliders(currentPosition, nextPosition) {
  142. this.$refs.galleryThumbs.goTo(nextPosition);
  143. this.$refs.galleryImages.goTo(nextPosition);
  144. }
  145. },
  146. props: ["images","img","index"],
  147. });
  148. galleries.forEach((gallery) => {
  149. const images = this.images = [...gallery.querySelectorAll("img")].map((img) => ({
  150. url: img.src,
  151. name: img.alt,
  152. }));
  153. const index = this.index,
  154. img_arr = this.images.map((elem, index) => {
  155. return index = {'src':elem.url,'caption':elem.name}
  156. } ),
  157. img = JSON.parse(JSON.stringify(img_arr));
  158. const slickMounted = new slickComponent({
  159. propsData: { images,img,index },
  160. }).$mount();
  161. gallery.replaceWith(slickMounted.$el);
  162. });
  163. const iframes = this.$refs.content.querySelectorAll('iframe');
  164. iframes.forEach(iframe => {
  165. if(iframe.getAttribute('class') != 'iframe-instagram'){
  166. const widthAttr = iframe.getAttribute('width');
  167. const heightAttr = iframe.getAttribute('height');
  168. if(widthAttr && heightAttr) {
  169. iframe.style.aspectRatio = `${widthAttr} / ${heightAttr}`;
  170. }
  171. }
  172. });
  173. window.addEventListener('load', () => {
  174. try{
  175. const iframeInstagram = this.$refs.content.querySelectorAll('.iframe-instagram');
  176. iframeInstagram.forEach(iframe => {
  177. iframe.removeAttribute('height');
  178. })
  179. } catch (e) {
  180. console.log('InstaIframe loading fail')
  181. }
  182. });
  183. },
  184. beforeDestroy() {
  185. this.$refs.content.removeEventListener("click", this.onClickContent);
  186. },
  187. methods: {
  188. onClickContent(e) {
  189. if (!e.target.classList.contains("tooltip")) return;
  190. this.tooltipShow = true;
  191. const tooltipBlock = this.$refs.tooltipBlock;
  192. const tooltipBtn = e.target;
  193. this.tooltipTitle = e.target.dataset.title;
  194. this.tooltipText = e.target.dataset.text;
  195. createPopper(tooltipBtn, tooltipBlock, {
  196. placement: "bottom",
  197. });
  198. },
  199. },
  200. };
  201. </script>
  202. <style lang="less" scoped>
  203. ::v-deep .single-article-content-slider-item img {
  204. margin: auto;
  205. }
  206. ::v-deep .slick-track {
  207. align-items: center;
  208. background-color: rgba(59, 85, 115, 0.08);
  209. }
  210. ::v-deep .button_news-slider {
  211. box-shadow: 0px 0px 20px 10px rgba(34, 60, 80, 0.2);
  212. }
  213. ::v-deep .image-title {
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. padding: 5px 0;
  218. }
  219. ::v-deep .tooltip {
  220. cursor: pointer;
  221. border-bottom: 1px dashed #5a748b;
  222. }
  223. .tooltip-block {
  224. background-color: #fff;
  225. min-width: 300px;
  226. border: 1px solid rgba(59, 85, 115, 0.08);
  227. border-radius: 5px;
  228. padding: 10px 20px;
  229. font-size: 16px;
  230. line-height: 20px;
  231. max-width: 700px;
  232. margin: 0 auto;
  233. inset: 0px auto auto auto !important;
  234. box-shadow: 0px 20px 40px rgba(0,0,0,.1);
  235. z-index: 2;
  236. @media screen and (max-width: 768px) {
  237. max-width: 300px;
  238. }
  239. &_title {
  240. font-weight: bold;
  241. }
  242. &_text {
  243. }
  244. &_close {
  245. position: absolute;
  246. top: 0px;
  247. right: 0;
  248. cursor: pointer;
  249. }
  250. }
  251. ::v-deep .style1 {
  252. display: block;
  253. padding: 20px;
  254. background-color: #fdf7e6;
  255. }
  256. ::v-deep iframe {
  257. width: 100%;
  258. }
  259. ::v-deep .iframe-wrapper {
  260. max-width: 100%;
  261. margin: 0 auto;
  262. iframe {
  263. min-height: 500px;
  264. width: 100%;
  265. }
  266. .iframe-instagram{
  267. height: 1015px;
  268. min-height: auto;
  269. }
  270. @media screen and (max-width: 768px) {
  271. iframe {
  272. min-height: 200px;
  273. }
  274. .iframe-instagram{
  275. height: 630px;
  276. min-height: auto;
  277. }
  278. }
  279. }
  280. //Audio style
  281. ::v-deep audio {
  282. width: 100%;
  283. }
  284. //Video style
  285. ::v-deep iframe[allow*="autoplay"],
  286. ::v-deep iframe[allow*="fullscreen"],
  287. ::v-deep iframe[allow*="picture-in-picture"] {
  288. width: 100%;
  289. height: 300px;
  290. @supports (aspect-ratio: 1) {
  291. height: auto;
  292. aspect-ratio: 16 / 9;
  293. }
  294. }
  295. //Inject style
  296. ::v-deep .detail-article-news {
  297. @media screen and (max-width: 768px) {
  298. &__side {
  299. max-width: 100%;
  300. flex: 1 0 auto;
  301. margin-right: 0;
  302. }
  303. &__figure {
  304. height: auto;
  305. padding-top: 20px;
  306. border-top: 1px solid #EAEAEA;
  307. }
  308. &__img {
  309. max-width: 100%;
  310. margin-right: 0;
  311. }
  312. }
  313. }
  314. @media screen and (min-device-width: 900px) {
  315. #adfox_167091964852627830 {
  316. display: none;
  317. }
  318. }
  319. </style>