diff options
author | beatrix <beatrix.bitrot@gmail.com> | 2018-04-22 12:07:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-22 12:07:29 -0400 |
commit | e88ce278550b9797d02fabf0783989a22be371f5 (patch) | |
tree | d9912392fc84393ea35274f9656237007b6a5c05 /app/javascript/flavours/glitch/packs | |
parent | d7ae97c10ae8c5a0064e3a0d9262c9f182f53a6e (diff) | |
parent | 7a68079b3fc0c80238451eb1f0264ce66e495502 (diff) |
Merge pull request #435 from ThibG/glitch-soc/features/public-modals
[Glitch] Show media modal on public pages
Diffstat (limited to 'app/javascript/flavours/glitch/packs')
-rw-r--r-- | app/javascript/flavours/glitch/packs/public.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js index 9ea82b53a..ed685b6b7 100644 --- a/app/javascript/flavours/glitch/packs/public.js +++ b/app/javascript/flavours/glitch/packs/public.js @@ -7,7 +7,6 @@ function main() { const { getLocale } = require('locales'); const { localeData } = getLocale(); const VideoContainer = require('flavours/glitch/containers/video_container').default; - const MediaGalleryContainer = require('flavours/glitch/containers/media_gallery_container').default; const CardContainer = require('flavours/glitch/containers/card_container').default; const React = require('react'); const ReactDOM = require('react-dom'); @@ -58,15 +57,20 @@ function main() { ReactDOM.render(<VideoContainer locale={locale} {...props} />, content); }); - [].forEach.call(document.querySelectorAll('[data-component="MediaGallery"]'), (content) => { - const props = JSON.parse(content.getAttribute('data-props')); - ReactDOM.render(<MediaGalleryContainer locale={locale} {...props} />, content); - }); - [].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => { const props = JSON.parse(content.getAttribute('data-props')); ReactDOM.render(<CardContainer locale={locale} {...props} />, content); }); + + const mediaGalleries = document.querySelectorAll('[data-component="MediaGallery"]'); + + if (mediaGalleries.length > 0) { + const MediaGalleriesContainer = require('flavours/glitch/containers/media_galleries_container').default; + const content = document.createElement('div'); + + ReactDOM.render(<MediaGalleriesContainer locale={locale} galleries={mediaGalleries} />, content); + document.body.appendChild(content); + } }); } |