wpgroho.js 999 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var WPGroHo = {
  2. "my_hash": " "
  3. }; /* global WPGroHo:true, Gravatar */
  4. WPGroHo = jQuery.extend({
  5. my_hash: '',
  6. data: {},
  7. renderers: {},
  8. syncProfileData: function(hash, id) {
  9. if (!WPGroHo.data[hash]) {
  10. WPGroHo.data[hash] = {};
  11. jQuery('div.grofile-hash-map-' + hash + ' span').each(function() {
  12. WPGroHo.data[hash][this.className] = jQuery(this).text();
  13. });
  14. }
  15. WPGroHo.appendProfileData(WPGroHo.data[hash], hash, id);
  16. },
  17. appendProfileData: function(data, hash, id) {
  18. for (var key in data) {
  19. if (jQuery.isFunction(WPGroHo.renderers[key])) {
  20. return WPGroHo.renderers[key](data[key], hash, id, key);
  21. }
  22. jQuery('#' + id).find('h4').after(jQuery('<p class="grav-extra ' + key + '" />').html(data[key]));
  23. }
  24. }
  25. }, WPGroHo);
  26. jQuery(document).ready(function() {
  27. if ('undefined' === typeof Gravatar) {
  28. return;
  29. }
  30. Gravatar.profile_cb = function(h, d) {
  31. WPGroHo.syncProfileData(h, d);
  32. };
  33. Gravatar.my_hash = WPGroHo.my_hash;
  34. Gravatar.init('body', '#username');
  35. });