2019-07-31 22:56:46 +05:30
|
|
|
import { __ } from '~/locale';
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
export default () => {
|
2018-11-08 19:23:39 +05:30
|
|
|
const { protocol, host, pathname } = window.location;
|
2018-10-15 14:42:47 +05:30
|
|
|
const shareBtn = document.querySelector('.js-share-btn');
|
|
|
|
const embedBtn = document.querySelector('.js-embed-btn');
|
|
|
|
const snippetUrlArea = document.querySelector('.js-snippet-url-area');
|
|
|
|
const embedAction = document.querySelector('.js-embed-action');
|
|
|
|
const url = `${protocol}//${host + pathname}`;
|
|
|
|
|
|
|
|
shareBtn.addEventListener('click', () => {
|
|
|
|
shareBtn.classList.add('is-active');
|
|
|
|
embedBtn.classList.remove('is-active');
|
|
|
|
snippetUrlArea.value = url;
|
2019-07-31 22:56:46 +05:30
|
|
|
embedAction.innerText = __('Share');
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
embedBtn.addEventListener('click', () => {
|
|
|
|
embedBtn.classList.add('is-active');
|
|
|
|
shareBtn.classList.remove('is-active');
|
|
|
|
const scriptTag = `<script src="${url}.js"></script>`;
|
|
|
|
snippetUrlArea.value = scriptTag;
|
2019-07-31 22:56:46 +05:30
|
|
|
embedAction.innerText = __('Embed');
|
2018-10-15 14:42:47 +05:30
|
|
|
});
|
|
|
|
};
|