Skip to content

Instantly share code, notes, and snippets.

@fomvasss
Last active May 26, 2021 07:12
Show Gist options
  • Save fomvasss/a01a72d20052cb6ab8efdcae2d07ace3 to your computer and use it in GitHub Desktop.
Save fomvasss/a01a72d20052cb6ab8efdcae2d07ace3 to your computer and use it in GitHub Desktop.
Пример кнопок "Поделится" в соц. сетях
<ul class="social js-social-share">
    <li><span>Поділитися:</span></li>
    <li>
        <a href="#" target="_blank" data-social="facebook">
            <i class='bx bxl-facebook'></i>
        </a>
    </li>
    <li>
        <a href="#" target="_blank" data-social="twitter">
            <i class='bx bxl-twitter'></i>
        </a>
    </li>
    <li>
        <a href="#" target="_blank" data-social="instagram">
            <i class='bx bxl-instagram'></i>
        </a>
    </li>
    <li>
        <a href="#" target="_blank" data-social="telegram">
            <i class='bx bxl-telegram'></i>
        </a>
    </li>
</ul>
//-------------------------------- Поделится в соц.сетях ----------------------------------//
$('.js-social-share a').on('click', function(e) {
    e.preventDefault();
    var $this = $(this),
        socials = {
            facebook: 'http://www.facebook.com/sharer.php?u=',
            //instagram: 'http://www.instagram.com/sharer.php?u=',
            vk: 'http://vk.com/share.php?url=',
            twitter: 'https://twitter.com/share?url=',
            telegram: 'https://t.me/share/url?url=',
            google: 'https://plus.google.com/share?url=',
            linkedin: 'https://www.linkedin.com/shareArticle?mini=true&url=',
            ok: 'https://www.ok.ru/dk?st.cmd=addShare&st.s=1&st._surl=',
            pinterest: 'https://www.pinterest.com/pin/create/bookmarklet/?url=',
            whatsapp: 'https://api.whatsapp.com/send/?phone&app_absent=0&text='
        },
        url = location.href,
        socialUrl = socials[$this.data('social')];
    open(socialUrl + url,"displayWindow","width=520,height=300,left=350,top=170,status=no,toolbar=no,menubar=no");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment