2019-05-03 03:42:19 -04:00
|
|
|
import { __ } from '~/locale';
|
|
|
|
|
2018-03-03 01:41:19 -05:00
|
|
|
export default () => {
|
2018-06-15 11:58:27 -04:00
|
|
|
const { protocol, host, pathname } = window.location;
|
2018-03-07 08:06:16 -05:00
|
|
|
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');
|
2018-03-06 13:44:57 -05:00
|
|
|
const url = `${protocol}//${host + pathname}`;
|
2018-02-06 08:33:18 -05:00
|
|
|
|
2018-03-03 03:00:08 -05:00
|
|
|
shareBtn.addEventListener('click', () => {
|
2018-03-03 01:41:19 -05:00
|
|
|
shareBtn.classList.add('is-active');
|
|
|
|
embedBtn.classList.remove('is-active');
|
2018-03-06 13:44:57 -05:00
|
|
|
snippetUrlArea.value = url;
|
2019-05-03 03:42:19 -04:00
|
|
|
embedAction.innerText = __('Share');
|
2018-03-03 01:41:19 -05:00
|
|
|
});
|
2018-02-06 08:33:18 -05:00
|
|
|
|
2018-03-03 03:00:08 -05:00
|
|
|
embedBtn.addEventListener('click', () => {
|
2018-03-03 01:41:19 -05:00
|
|
|
embedBtn.classList.add('is-active');
|
|
|
|
shareBtn.classList.remove('is-active');
|
2018-03-06 13:44:57 -05:00
|
|
|
const scriptTag = `<script src="${url}.js"></script>`;
|
2018-03-03 01:41:19 -05:00
|
|
|
snippetUrlArea.value = scriptTag;
|
2019-05-03 03:42:19 -04:00
|
|
|
embedAction.innerText = __('Embed');
|
2018-02-06 08:33:18 -05:00
|
|
|
});
|
2018-03-03 01:41:19 -05:00
|
|
|
};
|