Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2969463
Social sharing modification
Closed

Comments

  • Maxivillus started the conversation

    Is it possible to add to 'Like Posts & Social Sharing' 'Copy to clipboard' feature?

    Or may be i can add this feature by below code?

    $(".copy_to_clipboard").click(function (e) {
                        e.preventDefault();
                        var $temp = $("<input>");
                        $("body").append($temp);
                        $temp.val($(this).attr('href')).select();
                        document.execCommand("copy");
                        $temp.remove();
                        alert("Copied the text ");
                })


  •  2,492
    PenciDesign replied

    Hi,

    Here is a full code about your request:

    <script type="text/javascript">
    $('.tags-share-box.center-box .post-share, .tags-share-box.hide-tags.page-share .post-share').append('<a href="#" class="copy_to_clipboard post-share-item post-share-copy"><i class="penci-faicon fa fa-copy"></i></a>');
    $(".copy_to_clipboard").click(function(e) {
        e.preventDefault();
        var $temp = $("<input>");
        $("body").append($temp);
        $temp.val($(this).attr('href')).select();
        document.execCommand("copy");
        $temp.remove();
        alert("Copied the text ");
    })
    </script>

    You can paste it at Appearance → Customize → Footer → General → Add Custom HTML code before close </body> tag / Google Analytics Code

    Regards,
    PenciDesign.



  • Maxivillus replied

    This code will work on woocommerce products?

  • Maxivillus replied

    Correct code for using in codesnippets:

    jQuery(document).ready(function($) {
    $('.list-posts-share').append('<a href="#" class="copy_to_clipboard post-share-item post-share-copy"><i class="penci-faicon fa fa-copy"></i></a>');
    $(".copy_to_clipboard").click(function(e) {
        e.preventDefault();
        var $temp = $("<input>");
        $("body").append($temp);
        $temp.val($(this).attr('href')).select();
        document.execCommand("copy");
        $temp.remove();
        alert("Copied the text ");
    });
    });


  • Maxivillus replied

    Finally correct code :)

    jQuery(document).ready(function($) {
    let sometext = '<a href="' + document.baseURI + '#" title="Copy link to Clipboard" alt="Copy link to Clipboard" class="copy_to_clipboard post-share-item post-share-copy"><i class="penci-faicon fa fa-copy"></i></a>';
    $('.single-product-share .list-posts-share').append(sometext);
    $(".copy_to_clipboard").click(function(e) {
    e.preventDefault();
    var copyText = $(this).attr('href');
    document.addEventListener('copy', function(e) {
    e.clipboardData.setData('text/plain', copyText);
    e.preventDefault();
    }, true);
    document.execCommand('copy');  
       //console.log('copied text : ', copyText);
       //alert('Copied link: ' + copyText);
    $(this).hide(600);
    $(this).show(600);
    });
    });


  • Maxivillus replied

    Last question: how to make this code work in section 'quick product view'?

  •  2,492
    PenciDesign replied

    Hi,

    Unfortunately, this code doesn't work on Product Quickview because this content can't run after the ajax content loading.

    We'll consider adding more JS hooks in the future update to make the custom code work after the quick view popup shows.

    Regards,
    PenciDesign.