Skip to main content

max / makenotwork

979 B · 22 lines History Blame Raw
1 (function() {
2 var cfg = document.getElementById('tab-item-embed-cfg');
3 var hostUrl = cfg.dataset.hostUrl;
4 var itemId = cfg.dataset.itemId;
5 var itemTitle = cfg.dataset.itemTitle;
6
7 window.copyEmbed = function(btn) {
8 window.copyWithFeedback(btn, btn.previousElementSibling.textContent, 'Copied!', 1500);
9 };
10
11 window.switchCardLayout = function(layout) {
12 const iframe = document.getElementById('card-preview');
13 const code = document.getElementById('card-code');
14 const w = layout === 'horizontal' ? 600 : 350;
15 const h = layout === 'horizontal' ? 200 : 400;
16 iframe.src = hostUrl + '/embed/i/' + itemId + '/card?layout=' + layout;
17 iframe.width = w;
18 iframe.height = h;
19 code.textContent = '<iframe src="' + hostUrl + '/embed/i/' + itemId + '/card?layout=' + layout + '" width="' + w + '" height="' + h + '" frameborder="0" title="' + itemTitle + ' on Makenotwork"></iframe>';
20 };
21 })();
22