PageRenderTime 50ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/js/buttons.js

https://bitbucket.org/joomline/jllike
JavaScript | 902 lines | 715 code | 134 blank | 53 comment | 95 complexity | 11152644f56a77ee44fd8a146a4e4a86 MD5 | raw file
  1. var socialButtonCountObjects = {};
  2. var jllikeproShareUrls = {
  3. mail: {},
  4. pinteres: {},
  5. linkedin: {}
  6. };
  7. jQuery.noConflict();
  8. (function ($, w, d, undefined) {
  9. function getParam(key) {
  10. if (key) {
  11. var pairs = top.location.search.replace(/^\?/, '').split('&');
  12. for (var i in pairs) {
  13. var current = pairs[i];
  14. var match = current.match(/([^=]*)=(\w*)/);
  15. if (match[1] === key) {
  16. return decodeURIComponent(match[2]);
  17. }
  18. }
  19. }
  20. return false;
  21. }
  22. var ButtonConfiguration = function (params) {
  23. if (params) {
  24. return $.extend(true, ButtonConfiguration.defaults, params)
  25. }
  26. return ButtonConfiguration.defaults;
  27. }
  28. ButtonConfiguration.defaults = {
  29. selectors: {
  30. facebookButton: '.l-fb',
  31. twitterButton: '.l-tw',
  32. vkontakteButton: '.l-vk',
  33. odnoklassnikiButton: '.l-ok',
  34. gplusButton: '.l-gp',
  35. mailButton: '.l-ml',
  36. linButton: '.l-ln',
  37. pinteresButton: '.l-pinteres',
  38. LivejournalButton: '.l-lj',
  39. BloggerButton: '.l-bl',
  40. WeiboButton: '.l-wb',
  41. count: '.l-count',
  42. ico: '.l-ico',
  43. shareTitle: 'h2:eq(0)',
  44. shareSumary: 'p:eq(0)',
  45. shareImages: 'img[src]'
  46. },
  47. buttonDepth: 2,
  48. alternativeImage: '',
  49. alternativeSummary: '',
  50. alternativeTitle: '',
  51. forceAlternativeImage: false,
  52. forceAlternativeSummary: false,
  53. forceAlternativeTitle: false,
  54. classes: {
  55. countVisibleClass: 'like-not-empty'
  56. },
  57. keys: {
  58. shareLinkParam: 'href'
  59. },
  60. popupWindowOptions: [
  61. 'left=0',
  62. 'top=0',
  63. 'width=500',
  64. 'height=250',
  65. 'personalbar=0',
  66. 'toolbar=0',
  67. 'scrollbars=1',
  68. 'resizable=1'
  69. ]
  70. };
  71. var Button = function () {
  72. };
  73. Button.lastIndex = 0;
  74. Button.prototype = {
  75. /*@methods*/
  76. init: function ($context, conf, index) {
  77. this.config = conf;
  78. this.index = index;
  79. this.id = $($context).attr('id');
  80. this.$context = $context;
  81. this.$count = $(this.config.selectors.count, this.$context);
  82. this.$ico = $(this.config.selectors.ico, this.$context);
  83. this.collectShareInfo();
  84. this.bindEvents();
  85. this.ajaxRequest = this.countLikes();
  86. },
  87. bindEvents: function () {
  88. this
  89. .$context
  90. .bind('click', Button.returnFalse);
  91. this
  92. .$ico.parent()
  93. .bind('click', this, this.openShareWindow);
  94. },
  95. setCountValue: function (count) {
  96. this
  97. .$context
  98. .addClass(this.config.classes.countVisibleClass);
  99. this
  100. .$count
  101. .text(count);
  102. },
  103. getCountLink: function (url) {
  104. return this.countServiceUrl + encodeURIComponent(url);
  105. },
  106. collectShareInfo: function () {
  107. var
  108. $parent = this.$context,
  109. button = this;
  110. if(jQuery(jllickeproSettings.parentContayner).length > 0)
  111. {
  112. $parent = $parent.parents(jllickeproSettings.parentContayner).parent();
  113. }
  114. else{
  115. $parent = $parent.parents('.jllikeproSharesContayner').parent();
  116. }
  117. var
  118. $tmpParent,
  119. href = $('input.link-to-share', $parent).val(),
  120. title = $('input.share-title', $parent).val(),
  121. image = $('input.share-image', $parent).val(),
  122. origin = jllickeproSettings.url,
  123. $title = $(this.config.selectors.shareTitle, $parent),
  124. $summary;
  125. if(!$title.length){
  126. $title = $(this.config.selectors.shareTitle, $tmpParent);
  127. }
  128. $summary = $('input.share-desc', $parent).val();
  129. if(!$summary.length){
  130. $summary = $(this.config.selectors.shareSumary, $parent).text();
  131. }
  132. if(!$summary.length){
  133. $summary = $parent.text();
  134. }
  135. if(!$summary.length){
  136. $summary = $parent.parent().text();
  137. }
  138. this.domenhref = w.location.protocol + "//" + w.location.host;
  139. this.linkhref = jllickeproSettings.url + w.location.pathname + w.location.search;
  140. this.linkToShare = (!href) ? this.linkhref : href;
  141. //если заголовок в скрытомполе не пуст, то берем его, если пуст, то первый заголовок родителя
  142. this.title = (title != '') ? title : $title.text();
  143. if (this.config.forceAlternativeTitle){
  144. this.title = this.config.alternativeTitle;
  145. }
  146. else if (this.title == '' && this.config.alternativeTitle){
  147. this.title = this.config.alternativeTitle;
  148. }
  149. else if(this.title == ''){
  150. this.title = d.title;
  151. }
  152. if ($summary.length > 0)
  153. {
  154. this.summary = $summary;
  155. }
  156. else
  157. {
  158. this.summary = this.config.alternativeSummary ? this.config.alternativeSummary : '';
  159. }
  160. this.summary = (this.summary.length > 200) ? cropText(this.summary, 200) + '...' : this.summary;
  161. this.images = [];
  162. if(typeof(image) == 'undefined' || !image.length)
  163. {
  164. var $images = $(this.config.selectors.shareImages, $parent);
  165. $tmpParent = $parent;
  166. if(!$images.length){
  167. var $i = 0;
  168. while($images.length == 0 && $i < 20){
  169. $i++;
  170. $tmpParent = $tmpParent.parent();
  171. $images = $(this.config.selectors.shareImages, $tmpParent).not('#waitimg');
  172. }
  173. }
  174. if ($images.length > 0 & !this.config.forceAlternativeImage) {
  175. $images.each(function (index, element) {
  176. button.images[index] = element.src;
  177. });
  178. this.images = button.images;
  179. } else {
  180. this.images[0] = this.config.alternativeImage ? this.config.alternativeImage : undefined;
  181. }
  182. }
  183. else
  184. {
  185. this.images[0] = image;
  186. }
  187. },
  188. getPopupOptions: function () {
  189. return this.config.popupWindowOptions.join(',');
  190. },
  191. plusOne: function () {
  192. var parent = $('#'+this.id),
  193. counter = $('span.l-count', parent),
  194. count = counter.text();
  195. count = (count == '') ? 0 : parseInt(count);
  196. parent.addClass('like-not-empty');
  197. counter.text(count + 1);
  198. },
  199. disableMoreLikes: function () {
  200. if(jllickeproSettings.disableMoreLikes){
  201. var parent = $('#'+this.id).parents('.jllikeproSharesContayner');
  202. var id = parent.children('.share-id').val();
  203. var date = new Date( new Date().getTime() + 60*60*24*30*1000 );
  204. document.cookie="jllikepro_article_"+id+"=1; path=/; expires="+date.toUTCString();
  205. var div = $('<div/>').addClass('disable_more_likes');
  206. parent.prepend(div);
  207. }
  208. },
  209. openShareWindow: function (e) {
  210. var
  211. button = e.data,
  212. shareUri = button.getShareLink(),
  213. windowOptions = button.getPopupOptions();
  214. var
  215. newWindow = w.open(shareUri, '', windowOptions);
  216. button.plusOne();
  217. button.disableMoreLikes();
  218. if (w.focus) {
  219. newWindow.focus()
  220. }
  221. },
  222. /*@properties*/
  223. linkToShare: null,
  224. title: d.title,
  225. summary: null,
  226. images: [],
  227. countServiceUrl: null,
  228. $context: null,
  229. $count: null,
  230. $ico: null
  231. };
  232. Button = $.extend(Button, {
  233. /*@methods*/
  234. returnFalse: function (e) {
  235. return false;
  236. }
  237. /*@properties*/
  238. });
  239. var cropText = function (text, length) {
  240. var result = '';
  241. text
  242. .split(' ')
  243. .every( function(item)
  244. {
  245. var tmp = $.trim(item);
  246. if((result.length + tmp.length) <= length)
  247. {
  248. if(tmp != '')
  249. {
  250. result += ' '+tmp;
  251. }
  252. return true;
  253. }
  254. return false;
  255. });
  256. return result;
  257. };
  258. var FacebookButton = function ($context, conf, index) {
  259. this.init($context, conf, index);
  260. this.type = 'facebook';
  261. };
  262. FacebookButton.prototype = new Button;
  263. FacebookButton.prototype
  264. = $.extend(FacebookButton.prototype,
  265. {
  266. /*@methods*/
  267. countLikes: function () {
  268. var serviceURI = this.getCountLink(this.linkToShare);
  269. var id = this.id;
  270. return $.ajax({
  271. url: serviceURI,
  272. dataType: 'jsonp',
  273. success: function (data, status, jqXHR) {
  274. if (status == 'success' && typeof data.share != 'undefined' && typeof data.share.share_count != 'undefined') {
  275. if (data.share.share_count > 0) {
  276. var elem = $('#'+id);
  277. elem.addClass('like-not-empty');
  278. $('span.l-count', elem).text(data.share.share_count);
  279. jllikeproAllCouner(elem);
  280. }
  281. }
  282. }
  283. });
  284. },
  285. getShareLink: function ()
  286. {
  287. var url = 'https://www.facebook.com/sharer/sharer.php?app_id=114545895322903&sdk=joey&u='
  288. + encodeURIComponent(this.linkToShare)
  289. +'&display=popup&ref=plugin&src=share_button';
  290. //var url = 'https://www.facebook.com/sharer/sharer.php?s=100';
  291. //url += '&p[url]=' + encodeURIComponent(this.linkToShare);
  292. //url += '&p[title]=' + encodeURIComponent(this.title);
  293. //url += '&p[images][0]=' + encodeURIComponent(this.images[0]);
  294. //url += '&p[summary]=' + encodeURIComponent(this.summary);
  295. return url;
  296. },
  297. /*@properties*/
  298. countServiceUrl: 'https://graph.facebook.com/'
  299. });
  300. var TwitterButton = function ($context, conf, index) {
  301. this.init($context, conf, index);
  302. this.type = 'twitter';
  303. };
  304. TwitterButton.prototype = new Button;
  305. TwitterButton.prototype
  306. = $.extend(TwitterButton.prototype,
  307. {
  308. /*@methods*/
  309. countLikes: function () {},
  310. getShareLink: function () {
  311. var text = cropText(this.summary,(140 - this.title.length - this.linkToShare.length));
  312. return 'https://twitter.com/intent/tweet'
  313. + '?url=' + encodeURIComponent(this.linkToShare)
  314. + '&text=' + encodeURIComponent(this.title+ '. ' + text);
  315. },
  316. /*@properties*/
  317. countServiceUrl: 'https://urls.api.twitter.com/1/urls/count.json?url='
  318. });
  319. var VkontakteButton = function ($context, conf, index) {
  320. this.init($context, conf, index);
  321. this.type = 'vkontakte';
  322. };
  323. VkontakteButton.prototype = new Button;
  324. VkontakteButton.prototype
  325. = $.extend(VkontakteButton.prototype,
  326. {
  327. /*@methods*/
  328. countLikes: function () {
  329. w.socialButtonCountObjects[this.index] = this;
  330. var serviceURI = this.getCountLink(this.linkToShare) + '&index=' + this.index;
  331. function vkShare(index, count) {
  332. if (count > 0) {
  333. var id = w.socialButtonCountObjects[index].id;
  334. var elem = $('#'+id);
  335. elem.addClass('like-not-empty');
  336. $('span.l-count', elem).text(count);
  337. jllikeproAllCouner(elem);
  338. }
  339. }
  340. if(typeof w.VK == 'undefined')
  341. w.VK = {};
  342. if(typeof w.VK.Share == 'undefined')
  343. w.VK.Share = {};
  344. if(typeof w.VK.Share.count == 'undefined'){
  345. w.VK.Share.count = function (index, count) {
  346. vkShare(index, count);
  347. };
  348. } else {
  349. var originalVkCount = w.VK.Share.count;
  350. w.VK.Share.count = function (index, count) {
  351. vkShare(index, count);
  352. originalVkCount.call(w.VK.Share, index, count);
  353. };
  354. }
  355. return $.ajax({
  356. url: serviceURI,
  357. dataType: 'jsonp'
  358. });
  359. },
  360. getShareLink: function () {
  361. // return 'http://vkontakte.ru/share.php?'
  362. return 'http://vk.com/share.php?'
  363. + 'url=' + encodeURIComponent(this.linkToShare)
  364. // + '&title=' + encodeURIComponent(this.title)
  365. // + '&image=' + encodeURIComponent(this.images[0])
  366. // + (this.summary ? '&description=' + encodeURIComponent(this.summary) : '')
  367. ;
  368. },
  369. /*@properties*/
  370. countServiceUrl: 'https://vk.com/share.php?act=count&url='
  371. });
  372. // +++++++++
  373. /***odnoklassniki ***/////
  374. var odnoklassnikiButton = function ($context, conf, index) {
  375. this.init($context, conf, index);
  376. this.type = 'odnoklassniki';
  377. };
  378. odnoklassnikiButton.prototype = new Button;
  379. odnoklassnikiButton.prototype
  380. = $.extend(odnoklassnikiButton.prototype,
  381. {
  382. /*@methods*/
  383. countLikes: function ()
  384. {
  385. function odklShare(elementId, count)
  386. {
  387. if (count > 0)
  388. {
  389. var elem = $('#'+elementId);
  390. elem.addClass('like-not-empty');
  391. $('span.l-count', elem).text(count);
  392. jllikeproAllCouner(elem);
  393. }
  394. }
  395. var serviceURI = this.getCountLink(this.id, this.linkToShare);
  396. if (!w.ODKL)
  397. {
  398. w.ODKL = {
  399. updateCount: function(elementId, count){
  400. odklShare(elementId, count);
  401. }
  402. }
  403. }
  404. else
  405. {
  406. var originalOdCount = ODKL.updateCount;
  407. ODKL.updateCount = function (elementId, count)
  408. {
  409. odklShare(elementId, count);
  410. originalOdCount(elementId, count);
  411. };
  412. }
  413. var id = this.id;
  414. return $.ajax({
  415. url: serviceURI,
  416. dataType: 'jsonp'
  417. });
  418. },
  419. getShareLink: function () {
  420. return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl='
  421. + this.linkToShare
  422. +'&st.comments=' + encodeURIComponent(this.summary);
  423. },
  424. getCountLink: function (id, linkToShare) {
  425. return this.countServiceUrl + id + '&ref=' + encodeURIComponent(linkToShare);
  426. },
  427. /*@properties*/
  428. countServiceUrl: 'https://connect.ok.ru/dk?st.cmd=extLike&uid='
  429. });
  430. /***odnoklassniki ***/////
  431. /***GOOGLE ***/////
  432. var gplusButton = function ($context, conf, index) {
  433. this.init($context, conf, index);
  434. this.type = 'gplusButton';
  435. };
  436. gplusButton.prototype = new Button;
  437. gplusButton.prototype
  438. = $.extend(gplusButton.prototype,
  439. {
  440. /*@methods*/
  441. countLikes: function ()
  442. {
  443. serviceURI = this.linkToShare;
  444. var id = this.id;
  445. $.ajax({
  446. type: 'POST',
  447. url: 'https://clients6.google.com/rpc',
  448. processData: true,
  449. contentType: 'application/json',
  450. data: JSON.stringify({
  451. 'method': 'pos.plusones.get',
  452. 'id': this.linkToShare,
  453. 'params': {
  454. 'nolog': true,
  455. 'id': this.linkToShare,
  456. 'source': 'widget',
  457. 'userId': '@viewer',
  458. 'groupId': '@self'
  459. },
  460. 'jsonrpc': '2.0',
  461. 'key': 'p',
  462. 'apiVersion': 'v1'
  463. }),
  464. success: function(response) {
  465. if (response.result.metadata.globalCounts.count > 0) {
  466. var elem = $('#'+id);
  467. elem.addClass('like-not-empty');
  468. $('span.l-count', elem).text(response.result.metadata.globalCounts.count);
  469. jllikeproAllCouner(elem);
  470. }
  471. }
  472. });
  473. },
  474. getShareLink: function () {
  475. return 'https://plus.google.com/share?url=' + encodeURIComponent(this.linkToShare);
  476. },
  477. /*@properties*/
  478. countServiceUrl: 'https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ'
  479. });
  480. /***GOOGLE ***/////
  481. /***MAIL ***/////
  482. var mailButton = function ($context, conf, index) {
  483. this.init($context, conf, index);
  484. this.type = 'mailButton';
  485. };
  486. mailButton.prototype = new Button;
  487. mailButton.prototype
  488. = $.extend(mailButton.prototype,
  489. {
  490. /*@methods*/
  491. countLikes: function ()
  492. {
  493. jllikeproShareUrls.mail[this.linkToShare] = this.id;
  494. w.setMailRuCount = function(data){
  495. for (var url in data) if (data.hasOwnProperty(url))
  496. {
  497. if(!jllikeproShareUrls.mail.hasOwnProperty(url))
  498. {
  499. return;
  500. }
  501. var id = jllikeproShareUrls.mail[url];
  502. var shares = data[url].shares;
  503. if(shares>0){
  504. var elem = $('#'+id);
  505. elem.addClass('like-not-empty');
  506. $('span.l-count', elem).text(shares);
  507. jllikeproAllCouner(elem);
  508. }
  509. }
  510. }
  511. serviceURI = this.getCountLink(this.linkToShare);
  512. return $.ajax({
  513. url: serviceURI,
  514. dataType: 'jsonp'
  515. });
  516. },
  517. getShareLink: function () {
  518. return 'http://connect.mail.ru/share' +
  519. '?url='+ encodeURIComponent(this.linkToShare) +
  520. '&imageurl' + encodeURIComponent(this.images[0]) +
  521. '&title' + encodeURIComponent(this.title) +
  522. '&description' + encodeURIComponent(this.summary)
  523. ;
  524. },
  525. /*@properties*/
  526. countServiceUrl: 'https://connect.mail.ru/share_count?callback=1&func=setMailRuCount&url_list='
  527. });
  528. /***MAIL ***/////
  529. /***LINKIN ***/////
  530. var linButton = function ($context, conf, index) {
  531. this.init($context, conf, index);
  532. this.type = 'linButton';
  533. };
  534. linButton.prototype = new Button;
  535. linButton.prototype
  536. = $.extend(linButton.prototype,
  537. {
  538. /*@methods*/
  539. countLikes: function ()
  540. {
  541. jllikeproShareUrls.linkedin[this.linkToShare] = this.id;
  542. w.setLinkedInCount = function(data){
  543. if(!jllikeproShareUrls.linkedin.hasOwnProperty(data.url))
  544. {
  545. return;
  546. }
  547. var id = jllikeproShareUrls.linkedin[data.url];
  548. var shares = data.count;
  549. if(shares>0){
  550. var elem = $('#'+id);
  551. elem.addClass('like-not-empty');
  552. $('span.l-count', elem).text(shares);
  553. jllikeproAllCouner(elem);
  554. }
  555. }
  556. var serviceURI = this.getCountLink(this.linkToShare);
  557. return $.ajax({
  558. url: serviceURI,
  559. dataType: 'jsonp'
  560. });
  561. },
  562. getShareLink: function () {
  563. return 'http://www.linkedin.com/shareArticle?mini=true&ro=false&trk=bookmarklet&url='
  564. + this.linkToShare;//encodeURIComponent(this.linkToShare);
  565. },
  566. /*@properties*/
  567. countServiceUrl: 'https://www.linkedin.com/countserv/count/share?&callback=setLinkedInCount&format=jsonp&url='
  568. });
  569. /***LINKIN ***/////
  570. /***pinteres ***/////
  571. var pinteresButton = function ($context, conf, index) {
  572. this.init($context, conf, index);
  573. this.type = 'pinteresButton';
  574. };
  575. pinteresButton.prototype = new Button;
  576. pinteresButton.prototype
  577. = $.extend(pinteresButton.prototype,
  578. {
  579. /*@methods*/
  580. countLikes: function ()
  581. {
  582. jllikeproShareUrls.pinteres[this.linkToShare] = this.id;
  583. w.setPinteresCount = function(data)
  584. {
  585. if (data.hasOwnProperty('count'))
  586. {
  587. if(!jllikeproShareUrls.pinteres.hasOwnProperty(data.url))
  588. {
  589. return;
  590. }
  591. var id = jllikeproShareUrls.pinteres[data.url];
  592. if(data.count > 0){
  593. var elem = $('#'+id);
  594. elem.addClass('like-not-empty');
  595. $('span.l-count', elem).text(data.count);
  596. jllikeproAllCouner(elem);
  597. }
  598. }
  599. }
  600. serviceURI = this.getCountLink(this.linkToShare);
  601. return $.ajax({
  602. url: serviceURI,
  603. dataType: 'jsonp'
  604. });
  605. },
  606. getShareLink: function () {
  607. var media = (this.images[0] != undefined) ? this.images[0] : '';
  608. return 'http://www.pinterest.com/pin/create/button/?' +
  609. 'url=' + encodeURIComponent(this.linkToShare)+
  610. '&media=' + media +
  611. '&description=' + this.summary;
  612. },
  613. /*@properties*/
  614. countServiceUrl: 'https://api.pinterest.com/v1/urls/count.json?callback=setPinteresCount&url='
  615. });
  616. /***pinteres ***/////
  617. /*** LiveJournal ***///
  618. var LivejournalButton = function ($context, conf, index) {
  619. this.init($context, conf, index);
  620. this.type = 'livejournal';
  621. };
  622. LivejournalButton.prototype = new Button;
  623. LivejournalButton.prototype
  624. = $.extend(LivejournalButton.prototype,
  625. {
  626. /*@methods*/
  627. countLikes: function () {},
  628. getShareLink: function () {
  629. return 'http://livejournal.com/update.bml?'
  630. + 'subject=' + encodeURIComponent(this.title)
  631. + '&event=' + encodeURIComponent('<a href="' + this.linkToShare + '">' + this.title + '</a> ' + this.summary);
  632. },
  633. /*@properties*/
  634. countServiceUrl: 'http://livejournal.com/'
  635. });
  636. /*** LiveJournal ***///
  637. /*** Blogger ***///
  638. var BloggerButton = function ($context, conf, index) {
  639. this.init($context, conf, index);
  640. this.type = 'Blogger';
  641. };
  642. BloggerButton.prototype = new Button;
  643. BloggerButton.prototype
  644. = $.extend(BloggerButton.prototype,
  645. {
  646. /*@methods*/
  647. countLikes: function () {},
  648. getShareLink: function () {
  649. return 'https://www.blogger.com/blog-this.g?'
  650. + 'u=' + encodeURIComponent(this.linkToShare)
  651. + '&n=' + encodeURIComponent(this.title);
  652. },
  653. /*@properties*/
  654. countServiceUrl: 'https://www.blogger.com/'
  655. });
  656. /*** Weibo ***///
  657. var WeiboButton = function ($context, conf, index) {
  658. this.init($context, conf, index);
  659. this.type = 'Weibo';
  660. };
  661. WeiboButton.prototype = new Button;
  662. WeiboButton.prototype
  663. = $.extend(WeiboButton.prototype,
  664. {
  665. /*@methods*/
  666. countLikes: function () {},
  667. getShareLink: function () {
  668. return 'http://service.weibo.com/share/share.php?'
  669. + 'url=' + encodeURIComponent(this.linkToShare)
  670. + '&title=' + encodeURIComponent(this.title);
  671. },
  672. /*@properties*/
  673. countServiceUrl: 'http://service.weibo.com/'
  674. });
  675. /*** Weibo ***///
  676. //+++++++++
  677. var jllikeproAllCouner = function(element)
  678. {
  679. var parent = $(element).parents('.jllikeproSharesContayner');
  680. var counterSpan = parent.find('span.l-all-count');
  681. var counterValue = 0;
  682. var tmpVal;
  683. parent.find('.l-count').not('.l-all-count').each(function(){
  684. tmpVal = $(this).text();
  685. if(tmpVal != ''){
  686. counterValue += parseInt(tmpVal);
  687. }
  688. });
  689. counterSpan.text(counterValue);
  690. };
  691. $.fn.socialButton = function (config) {
  692. this.each(function (index, element) {
  693. setTimeout(function () {
  694. var
  695. $element = $(element),
  696. conf = new ButtonConfiguration(config),
  697. b = false;
  698. Button.lastIndex++;
  699. if ($element.is(conf.selectors.facebookButton)) {
  700. b = new FacebookButton($element, conf, Button.lastIndex);
  701. } else if ($element.is(conf.selectors.twitterButton)) {
  702. b = new TwitterButton($element, conf, Button.lastIndex);
  703. } else if ($element.is(conf.selectors.vkontakteButton)) {
  704. b = new VkontakteButton($element, conf, Button.lastIndex);
  705. } else if ($element.is(conf.selectors.odnoklassnikiButton)) {
  706. b = new odnoklassnikiButton($element, conf, Button.lastIndex);
  707. } else if ($element.is(conf.selectors.gplusButton)) {
  708. b = new gplusButton($element, conf, Button.lastIndex);
  709. } else if ($element.is(conf.selectors.mailButton)) {
  710. b = new mailButton($element, conf, Button.lastIndex);
  711. } else if ($element.is(conf.selectors.linButton)) {
  712. b = new linButton($element, conf, Button.lastIndex);
  713. } else if ($element.is(conf.selectors.pinteresButton)) {
  714. b = new pinteresButton($element, conf, Button.lastIndex);
  715. } else if ($element.is(conf.selectors.LivejournalButton)) {
  716. b = new LivejournalButton($element, conf, Button.lastIndex);
  717. } else if ($element.is(conf.selectors.BloggerButton)) {
  718. b = new BloggerButton($element, conf, Button.lastIndex);
  719. } else if ($element.is(conf.selectors.WeiboButton)) {
  720. b = new WeiboButton($element, conf, Button.lastIndex);
  721. }
  722. $
  723. .when(b.ajaxRequest)
  724. .then(
  725. function () {
  726. $element.trigger('socialButton.done', [b.type]);
  727. }
  728. , function () {
  729. $element.trigger('socialButton.done', [b.type]);
  730. }
  731. );
  732. }, 0);
  733. });
  734. return this;
  735. };
  736. $.scrollToButton = function (hashParam, duration) {
  737. if (!w.location.hash) {
  738. if (w.location.search) {
  739. var currentHash = getParam(hashParam);
  740. if (currentHash) {
  741. var $to = $('#' + currentHash);
  742. if ($to.length > 0) {
  743. $('html,body')
  744. .animate({
  745. scrollTop: $to.offset().top,
  746. scrollLeft: $to.offset().left
  747. }, duration || 1000);
  748. }
  749. }
  750. }
  751. }
  752. return this;
  753. };
  754. })(jQuery, window, document);
  755. jQuery(document).ready(function ($)
  756. {
  757. $('.like').socialButton();
  758. var likes = $('div.jllikeproSharesContayner');
  759. var contayner = jllickeproSettings.buttonsContayner;
  760. if(contayner != ''
  761. && $(contayner).length > 0
  762. && likes.length > 0
  763. && jllickeproSettings.isCategory == 0)
  764. {
  765. likes.remove();
  766. $(contayner).html(likes);
  767. }
  768. });