comments_helper_facebook.tmpl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ## -*- coding: utf-8 -*-
  2. <%def name="comment_form(url, title, identifier)">
  3. <div id="fb-root"></div>
  4. <script>
  5. window.fbAsyncInit = function() {
  6. // init the FB JS SDK
  7. FB.init({
  8. appId : '${comment_system_id}',
  9. status : true,
  10. xfbml : true
  11. });
  12. };
  13. // Load the SDK asynchronously
  14. (function(d, s, id){
  15. var js, fjs = d.getElementsByTagName(s)[0];
  16. if (d.getElementById(id)) {return;}
  17. js = d.createElement(s); js.id = id;
  18. js.src = "//connect.facebook.net/en_US/all.js";
  19. fjs.parentNode.insertBefore(js, fjs);
  20. }(document, 'script', 'facebook-jssdk'));
  21. </script>
  22. <div class="fb-comments" data-href="${url}" data-width="470"></div>
  23. </%def>
  24. <%def name="comment_link(link, identifier)">
  25. <span class="fb-comments-count" data-url="${link}">
  26. </%def>
  27. <%def name="comment_link_script()">
  28. <div id="fb-root"></div>
  29. <script>
  30. // thank lxml for this
  31. $('.fb-comments-count').each(function(i, obj) {
  32. var url = obj.attributes['data-url'].value;
  33. // change here if you dislike the default way of displaying
  34. // this
  35. obj.innerHTML = '<fb:comments-count href="' + url + '"></fb:comments-count> comments';
  36. });
  37. window.fbAsyncInit = function() {
  38. // init the FB JS SDK
  39. FB.init({
  40. appId : '${comment_system_id}',
  41. status : true,
  42. xfbml : true
  43. });
  44. };
  45. // Load the SDK asynchronously
  46. (function(d, s, id){
  47. var js, fjs = d.getElementsByTagName(s)[0];
  48. if (d.getElementById(id)) {return;}
  49. js = d.createElement(s); js.id = id;
  50. js.src = "//connect.facebook.net/en_US/all.js";
  51. fjs.parentNode.insertBefore(js, fjs);
  52. }(document, 'script', 'facebook-jssdk'));
  53. </script>
  54. </%def>