Last active
December 15, 2017 11:49
-
-
Save Pum-purum/a0cf8030aab4582c1aebf537aa10d27b to your computer and use it in GitHub Desktop.
Ссылки Поделиться в соцсетях
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var purl = "http://<?= SITE_SERVER_NAME . $arResult['DETAIL_PAGE_URL'] ?>"; | |
var ptitle = "<?= $arResult['NAME'] ?>"; | |
var pimg = "<?= SITE_SERVER_NAME . $file['src'] ?>"; | |
var text = "<?=$arResult['NAME']?>"; | |
Share = { | |
vkontakte: function (purl, ptitle, pimg, text) { | |
url = 'http://vk.com/share.php?'; | |
url += 'url=' + encodeURIComponent(purl); | |
url += '&title=' + encodeURIComponent(ptitle); | |
url += '&description=' + encodeURIComponent(text); | |
url += '&image=' + encodeURIComponent(pimg); | |
url += '&noparse=true'; | |
Share.popup(url); | |
} | |
, | |
odnoklassniki: function (purl, text) { | |
url = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1'; | |
url += '&st.comments=' + encodeURIComponent(text); | |
url += '&st._surl=' + encodeURIComponent(purl); | |
Share.popup(url); | |
} | |
, | |
facebook: function (purl, ptitle, pimg, text) { | |
url = 'http://www.facebook.com/sharer.php?s=100'; | |
url += '&p[title]=' + encodeURIComponent(ptitle); | |
url += '&p[summary]=' + encodeURIComponent(text); | |
url += '&p[url]=' + encodeURIComponent(purl); | |
url += '&p[images][0]=' + encodeURIComponent(pimg); | |
Share.popup(url); | |
} | |
, | |
twitter: function (purl, ptitle) { | |
url = 'http://twitter.com/share?'; | |
url += 'text=' + encodeURIComponent(ptitle); | |
url += '&url=' + encodeURIComponent(purl); | |
url += '&counturl=' + encodeURIComponent(purl); | |
Share.popup(url); | |
} | |
, | |
mailru: function (purl, ptitle, pimg, text) { | |
url = 'http://connect.mail.ru/share?'; | |
url += 'url=' + encodeURIComponent(purl); | |
url += '&title=' + encodeURIComponent(ptitle); | |
url += '&description=' + encodeURIComponent(text); | |
url += '&imageurl=' + encodeURIComponent(pimg); | |
Share.popup(url) | |
} | |
, | |
popup: function (url) { | |
window.open(url, '', 'toolbar=0,status=0,width=626,height=436'); | |
} | |
} | |
; | |
</script> | |
<?php if (\Bitrix\Main\Config\Configuration::getValue("show_social_links")) { | |
?> | |
<div class="soc detail"> | |
<span class="soc_text">Поделиться:</span> | |
<a target="_blank" class="vk" | |
onclick="Share.vkontakte(purl, ptitle, pimg, text);"></a> | |
<a target="_blank" class="fb" | |
onclick="Share.facebook(purl, ptitle, pimg, text)"></a> | |
<a target="_blank" class="tw" onclick="Share.twitter(purl, ptitle)"></a> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment