diff options
author | haseeb <haseebeqx@yahoo.com> | 2018-02-06 16:33:18 +0300 |
---|---|---|
committer | haseeb <haseebeqx@yahoo.com> | 2018-02-28 16:18:26 +0300 |
commit | 27e8d38cea92d165a2e8400b25df23f408b4dca0 (patch) | |
tree | 0a16f63c8f380c92fb4185ca21ba8a264c572641 /app/assets/javascripts/snippet | |
parent | 56af0631c6c6d838301ac068f2e79b8f4de9fda7 (diff) |
embedded snippets support
Diffstat (limited to 'app/assets/javascripts/snippet')
-rw-r--r-- | app/assets/javascripts/snippet/snippet_embed.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/assets/javascripts/snippet/snippet_embed.js b/app/assets/javascripts/snippet/snippet_embed.js new file mode 100644 index 00000000000..c032414552e --- /dev/null +++ b/app/assets/javascripts/snippet/snippet_embed.js @@ -0,0 +1,18 @@ +(() => { + $(() => { + const { protocol, host, pathname } = location; + + $('#share-btn').click((event) => { + event.preventDefault(); + $('#snippet-url-area').val(`${protocol}//${host + pathname}`); + $('#embed-action').html('Share'); + }); + + $('#embed-btn').click((event) => { + event.preventDefault(); + const scriptTag = `<script src="${protocol}//${host + pathname}.js"></script>`; + $('#snippet-url-area').val(scriptTag); + $('#embed-action').html('Embed'); + }); + }); +}).call(window); |