/* share42.com | 23.09.2014 | (c) Dimox */ (function($) { $(function() { $('div.share42init').each(function(idx) { var el = $(this), u = el.attr('data-url'), t = el.attr('data-title'), i = el.attr('data-image'), d = el.attr('data-description'), f = el.attr('data-path'), fn = el.attr('data-icons-file'), z = el.attr("data-zero-counter"); if (!u) u = location.href; if (!fn) fn = 'icons.png'; if (!z) z = 0; function fb_count(url) { var shares; $.getJSON('//graph.facebook.com/?callback=?&ids=' + url, function(data) { shares = data[url].shares || 0; if (shares > 0 || z == 1) el.find('a[data-count="fb"]').after('' + shares + '') }) } fb_count(u); function gplus_count(url) { if (!window.services) { window.services = {}; window.services.gplus = {} } window.services.gplus.cb = function(number) { window.gplusShares = number }; $.getScript('//share.yandex.ru/gpp.xml?url=' + url, function() { var shares = window.gplusShares; if (shares > 0 || z == 1) el.find('a[data-count="gplus"]').after('' + shares + '') }) } gplus_count(u); function odkl_count(url) { $.getScript('//ok.ru/dk?st.cmd=extLike&uid=' + idx + '&ref=' + url); if (!window.ODKL) window.ODKL = {}; window.ODKL.updateCount = function(idx, shares) { if (shares > 0 || z == 1) $('div.share42init').eq(idx).find('a[data-count="odkl"]').after('' + shares + '') } } odkl_count(u); function vk_count(url) { $.getScript('//vk.com/share.php?act=count&index=' + idx + '&url=' + url); if (!window.VK) window.VK = {}; window.VK.Share = { count: function(idx, shares) { if (shares > 0 || z == 1) $('div.share42init').eq(idx).find('a[data-count="vk"]').after('' + shares + '') } } } vk_count(u); if (!f) { function path(name) { var sc = document.getElementsByTagName('script'), sr = new RegExp('^(.*/|)(' + name + ')([#?]|$)'); for (var p = 0, scL = sc.length; p < scL; p++) { var m = String(sc[p].src).match(sr); if (m) { if (m[1].match(/^((https?|file)\:\/{2,}|\w:[\/\\])/)) return m[1]; if (m[1].indexOf("/") == 0) return m[1]; b = document.getElementsByTagName('base'); if (b[0] && b[0].href) return b[0].href + m[1]; else return document.location.pathname.match(/(.*[\/\\])/)[0] + m[1]; } } return null; } f = path('share42.min.js'); } if (!t) t = document.title; if (!d) { var meta = $('meta[name="description"]').attr('content'); if (meta !== undefined) d = meta; else d = ''; } u = encodeURIComponent(u); t = encodeURIComponent(t); t = t.replace(/\'/g, '%27'); i = encodeURIComponent(i); d = encodeURIComponent(d); d = d.replace(/\'/g, '%27'); var fbQuery = 'u=' + u; if (i != 'null' && i != '') fbQuery = 's=100&p[url]=' + u + '&p[title]=' + t + '&p[summary]=' + d + '&p[images][0]=' + i; var vkImage = ''; if (i != 'null' && i != '') vkImage = '&image=' + i; var s = new Array('"#" data-count="fb" onclick="window.open(\'//www.facebook.com/sharer.php?m2w&' + fbQuery + '\', \'_blank\', \'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0\');return false" title="Поделиться в Facebook"', '"#" data-count="gplus" onclick="window.open(\'//plus.google.com/share?url=' + u + '\', \'_blank\', \'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0\');return false" title="Поделиться в Google+"', '"#" data-count="odkl" onclick="window.open(\'//ok.ru/dk?st.cmd=addShare&st._surl=' + u + '&title=' + t + '\', \'_blank\', \'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0\');return false" title="Добавить в Одноклассники"', '"#" data-count="twi" onclick="window.open(\'//twitter.com/intent/tweet?text=' + t + '&url=' + u + '\', \'_blank\', \'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0\');return false" title="Добавить в Twitter"', '"#" data-count="vk" onclick="window.open(\'//vk.com/share.php?url=' + u + '&title=' + t + vkImage + '&description=' + d + '\', \'_blank\', \'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0\');return false" title="Поделиться В Контакте"', '"#" onclick="print();return false" title="Распечатать"'); var l = ''; for (j = 0; j < s.length; j++) l += ''; el.html('' + l + '' + ''); }) }) })(jQuery);