Advertisement
Guest User

Untitled

a guest
May 2nd, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. var timer;
  2.  
  3. $(document).ready(function() {
  4.  
  5.  
  6.  
  7. window.fbAsyncInit = function() {
  8. FB.init({appId: 'xxxx', status: true, cookie: true,
  9. xfbml: true});
  10. };
  11. (function() {
  12. var e = document.createElement('script'); e.async = true;
  13. e.src = document.location.protocol +
  14. '//connect.facebook.net/en_US/all.js';
  15. document.getElementById('fb-root').appendChild(e);
  16. }());
  17. $(document).ready(function(){
  18. $('#share_button').click(function(e){
  19. e.preventDefault();
  20. FB.ui(
  21. {
  22. method: 'feed',
  23. name: 'This is the content of the "name" field.',
  24. link: 'http://www.groupstudy.in/articlePost.php?id=A_111213073144',
  25. picture: 'http://www.groupstudy.in/img/logo3.jpeg',
  26. caption: 'Top 3 reasons why you should care about your finance',
  27. description: "What happens when you don't take care of your finances? Just look at our country -- you spend irresponsibly, get in debt up to your eyeballs, and stress about how you're going to make ends meet. The difference is that you don't have a glut of taxpayers…",
  28. message: ""
  29. });
  30. });
  31. });
  32. $(".result").on("click", function() {
  33.  
  34. var id = $(this).attr("data-linkId");
  35. var url = $(this).attr("href");
  36.  
  37. if(!id) {
  38. alert("data-linkId attribute not found");
  39. }
  40.  
  41. increaseLinkClicks(id, url);
  42.  
  43. return false;
  44. });
  45.  
  46.  
  47. var grid = $(".imageResults");
  48.  
  49. grid.on("layoutComplete", function() {
  50. $(".gridItem img").css("visibility", "visible");
  51. });
  52.  
  53. grid.masonry({
  54. itemSelector: ".gridItem",
  55. columnWidth: 200,
  56. gutter: 5,
  57. isInitLayout: false
  58. });
  59.  
  60.  
  61. $("[data-fancybox]").fancybox({
  62.  
  63. caption : function( instance, item ) {
  64. var caption = $(this).data('caption') || '';
  65. var siteUrl = $(this).data('siteurl') || '';
  66.  
  67.  
  68.  
  69. if ( item.type === 'image' ) {
  70. caption = (caption.length ? caption + '<br />' : '')
  71. + '<a href="' + item.src + '">View image</a><br>'
  72. + '<a href="' + siteUrl + '">Visit page</a><br>'
  73. + '<a href="' + share_button + '">Share</a>';
  74.  
  75. }
  76.  
  77. return caption;
  78. },
  79. afterShow : function( instance, item ) {
  80. increaseImageClicks(item.src);
  81. }
  82.  
  83.  
  84. });
  85.  
  86. });
  87.  
  88. function loadImage(src, className) {
  89.  
  90. var image = $("<img>");
  91.  
  92. image.on("load", function() {
  93. $("." + className + " a").append(image);
  94.  
  95. clearTimeout(timer);
  96.  
  97. timer = setTimeout(function() {
  98. $(".imageResults").masonry();
  99. }, 500);
  100.  
  101. });
  102.  
  103. image.on("error", function() {
  104.  
  105. $("." + className).remove();
  106.  
  107. $.post("ajax/setBroken.php", {src: src});
  108.  
  109. });
  110.  
  111. image.attr("src", src);
  112.  
  113. }
  114.  
  115.  
  116. function increaseLinkClicks(linkId, url) {
  117.  
  118. $.post("ajax/updateLinkCount.php", {linkId: linkId})
  119. .done(function(result) {
  120. if(result != "") {
  121. alert(result);
  122. return;
  123. }
  124.  
  125. window.location.href = url;
  126. });
  127.  
  128. }
  129.  
  130. function increaseImageClicks(imageUrl) {
  131.  
  132. $.post("ajax/updateImageCount.php", {imageUrl: imageUrl})
  133. .done(function(result) {
  134. if(result != "") {
  135. alert(result);
  136. return;
  137. }
  138. });
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement