diff --git a/static/sharing.js b/static/sharing.js index aa4168f58..bc4394d4a 100644 --- a/static/sharing.js +++ b/static/sharing.js @@ -170,6 +170,16 @@ function initShareButton(getLink, layout, noteNewState) { setSocialSharing(socialSharing, result.url); } + function getEmbeddedCacheLinkId() { + if ($("#shareembedlink input:checked").length === 0) return "Embed"; + + return "Embed|" + $("#shareembedlink input:checked").map(function () { + return $(this).prop("class"); + }) + .get() + .join(); + } + function update() { var socialSharing = socialSharingElements; socialSharing.empty(); @@ -177,12 +187,8 @@ function initShareButton(getLink, layout, noteNewState) { permalink.prop('disabled', false); var config = layout.toConfig(); var cacheLinkId = currentBind; - if (cacheLinkId === "Embed" && $("#shareembedlink input:checked").length > 0) { - cacheLinkId += "|" + $("#shareembedlink input:checked").map(function () { - return $(this).prop("class"); - }) - .get() - .join(); + if (currentBind === "Embed") { + cacheLinkId = getEmbeddedCacheLinkId(); } if (!urls[cacheLinkId]) { label.text(currentNode.text()); @@ -210,8 +216,14 @@ function initShareButton(getLink, layout, noteNewState) { update(); }); - $(document).find('#embedsettings input').on('click', function () { - setCurrent(root.find('.sources [data-bind="Embed"]')); + var embeddedButton = $('#shareembed'); + $('#embedsettings input').on('click', function () { + setCurrent(embeddedButton); + update(); + }); + embeddedButton.off('click').on('click', function () { + $('#embedsettings').modal('show'); + setCurrent(embeddedButton); update(); }); diff --git a/views/templates.pug b/views/templates.pug index c1d693f55..3152f1ad4 100644 --- a/views/templates.pug +++ b/views/templates.pug @@ -14,12 +14,20 @@ | Short button.dropdown-item.btn.btn-light.btn-sm(data-bind="Full") | Full - button.dropdown-item.btn.btn-light.btn-sm(data-bind="Embed" href="javascript:;" data-target="#shareembedlink" data-toggle="modal") - | Embed input.form-control.input-sm.permalink(type="text" placeholder="Loading" readonly size="1024" style="font-size: 10px") .input-group-append button.input-group-btn.btn.btn-outline-secondary.btn-sm.clippy(type="button" data-clipboard-target=".popover .permalink" title="Copy to clipboard") span.fa.fa-clipboard + div + |   + .btn-group.btn-group-sm + .input-group.input-group-sm + .input-group-prepend + span + button.btn.btn-outline-secondary.btn-sm#shareembed(type="button" data-bind="Embed") + | Embedded + .input-group-append + span if sharingEnabled .card-footer .socialsharing