canonical-urls
3 months ago
carousel
1 month ago
comment-likes
7 months ago
comments
1 month ago
custom-post-types
1 week ago
external-media
7 months ago
google-fonts
1 week ago
gravatar
6 years ago
infinite-scroll
1 week ago
likes
1 week ago
markdown
1 month ago
memberships
2 days ago
photon-cdn
2 days ago
plugin-search
2 months ago
post-by-email
7 months ago
related-posts
1 week ago
scan
3 months ago
seo-tools
1 week ago
sharedaddy
1 month ago
shortcodes
1 week ago
shortlinks
1 week ago
simple-payments
7 months ago
site-icon
7 months ago
sitemaps
1 month ago
stats
6 months ago
subscriptions
2 days ago
theme-tools
1 week ago
tiled-gallery
1 month ago
verification-tools
1 month ago
videopress
2 days ago
widget-visibility
1 month ago
widgets
1 week ago
woocommerce-analytics
2 months ago
wordads
1 week ago
wpcom-tos
6 months ago
account-protection.php
3 months ago
blaze.php
7 months ago
blocks.php
7 months ago
canonical-urls.php
4 months ago
carousel.php
7 months ago
comment-likes.php
7 months ago
comments.php
3 months ago
contact-form.php
7 months ago
copy-post.php
1 month ago
custom-content-types.php
3 months ago
google-fonts.php
2 months ago
gravatar-hovercards.php
1 month ago
infinite-scroll.php
7 months ago
json-api.php
7 months ago
latex.php
1 month ago
likes.php
2 months ago
markdown.php
7 months ago
module-extras.php
7 months ago
module-headings.php
1 week ago
module-info.php
4 months ago
monitor.php
1 month ago
notes.php
1 week ago
photon-cdn.php
7 months ago
photon.php
7 months ago
plugin-search.php
1 week ago
podcast.php
1 week ago
post-by-email.php
3 months ago
post-list.php
7 months ago
protect.php
3 months ago
publicize.php
7 months ago
related-posts.php
1 month ago
search.php
7 months ago
seo-tools.php
1 week ago
sharedaddy.php
4 months ago
shortcodes.php
7 months ago
shortlinks.php
1 month ago
simple-payments.php
7 months ago
sitemaps.php
7 months ago
sso.php
1 week ago
stats.php
1 month ago
subscriptions.php
1 week ago
theme-tools.php
7 months ago
tiled-gallery.php
7 months ago
vaultpress.php
7 months ago
verification-tools.php
3 months ago
videopress.php
7 months ago
waf.php
7 months ago
widget-visibility.php
7 months ago
widgets.php
7 months ago
woocommerce-analytics.php
7 months ago
wordads.php
7 months ago
wpcom-reader.php
4 months ago
wpgroho.js
1 year ago
wpgroho.js
81 lines
| 1 | /* global WPGroHo:true, Gravatar */ |
| 2 | ( function () { |
| 3 | var extend = function ( out ) { |
| 4 | out = out || {}; |
| 5 | |
| 6 | for ( var i = 1; i < arguments.length; i++ ) { |
| 7 | if ( ! arguments[ i ] ) { |
| 8 | continue; |
| 9 | } |
| 10 | |
| 11 | for ( var key in arguments[ i ] ) { |
| 12 | if ( Object.hasOwn( arguments[ i ], key ) ) { |
| 13 | out[ key ] = arguments[ i ][ key ]; |
| 14 | } |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | return out; |
| 19 | }; |
| 20 | |
| 21 | WPGroHo = extend( |
| 22 | { |
| 23 | my_hash: '', |
| 24 | data: {}, |
| 25 | renderers: {}, |
| 26 | syncProfileData: function ( hash, id ) { |
| 27 | var hashElements; |
| 28 | |
| 29 | if ( ! WPGroHo.data[ hash ] ) { |
| 30 | WPGroHo.data[ hash ] = {}; |
| 31 | hashElements = document.querySelectorAll( 'div.grofile-hash-map-' + hash + ' span' ); |
| 32 | for ( var i = 0; i < hashElements.length; i++ ) { |
| 33 | WPGroHo.data[ hash ][ hashElements[ i ].className ] = hashElements[ i ].innerText; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | WPGroHo.appendProfileData( WPGroHo.data[ hash ], hash, id ); |
| 38 | }, |
| 39 | appendProfileData: function ( data, hash, id ) { |
| 40 | for ( var key in data ) { |
| 41 | if ( 'function' === typeof WPGroHo.renderers[ key ] ) { |
| 42 | return WPGroHo.renderers[ key ]( data[ key ], hash, id, key ); |
| 43 | } |
| 44 | |
| 45 | var card = document.getElementById( id ); |
| 46 | if ( card ) { |
| 47 | var heading = card.querySelector( 'h4' ); |
| 48 | if ( heading ) { |
| 49 | var extra = document.createElement( 'p' ); |
| 50 | extra.className = 'grav-extra ' + key; |
| 51 | extra.innerHTML = data[ key ]; |
| 52 | |
| 53 | heading.insertAdjacentElement( 'afterend', extra ); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | }, |
| 58 | }, |
| 59 | WPGroHo || {} |
| 60 | ); |
| 61 | |
| 62 | var jetpackHovercardsInit = function () { |
| 63 | if ( 'undefined' === typeof Gravatar ) { |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | Gravatar.profile_cb = function ( h, d ) { |
| 68 | WPGroHo.syncProfileData( h, d ); |
| 69 | }; |
| 70 | |
| 71 | Gravatar.my_hash = WPGroHo.my_hash; |
| 72 | Gravatar.init( 'body', '#wpadminbar' ); |
| 73 | }; |
| 74 | |
| 75 | if ( document.readyState === 'interactive' || document.readyState === 'complete' ) { |
| 76 | jetpackHovercardsInit(); |
| 77 | } else { |
| 78 | document.addEventListener( 'DOMContentLoaded', jetpackHovercardsInit ); |
| 79 | } |
| 80 | } )(); |
| 81 |