canonical-urls
2 months ago
carousel
2 days ago
comment-likes
6 months ago
comments
1 week ago
custom-post-types
3 months ago
external-media
6 months ago
google-fonts
4 months ago
gravatar
5 years ago
infinite-scroll
1 week ago
likes
1 week ago
markdown
1 week ago
memberships
1 week ago
photon-cdn
1 month ago
plugin-search
4 weeks ago
post-by-email
6 months ago
related-posts
2 days ago
scan
2 months ago
seo-tools
1 week ago
sharedaddy
1 week ago
shortcodes
1 week ago
shortlinks
1 week ago
simple-payments
6 months ago
site-icon
6 months ago
sitemaps
1 week ago
stats
5 months ago
subscriptions
2 days ago
theme-tools
2 weeks ago
tiled-gallery
1 week ago
verification-tools
2 weeks ago
videopress
1 week ago
widget-visibility
1 week ago
widgets
2 days ago
woocommerce-analytics
1 month ago
wordads
1 month ago
wpcom-tos
5 months ago
account-protection.php
1 month ago
blaze.php
6 months ago
blocks.php
6 months ago
canonical-urls.php
3 months ago
carousel.php
6 months ago
comment-likes.php
6 months ago
comments.php
2 months ago
contact-form.php
6 months ago
copy-post.php
2 weeks ago
custom-content-types.php
1 month ago
google-fonts.php
1 month ago
gravatar-hovercards.php
1 week ago
infinite-scroll.php
6 months ago
json-api.php
6 months ago
latex.php
1 week ago
likes.php
4 weeks ago
markdown.php
6 months ago
module-extras.php
6 months ago
module-headings.php
1 week ago
module-info.php
3 months ago
monitor.php
2 days ago
notes.php
5 months ago
photon-cdn.php
6 months ago
photon.php
6 months ago
plugin-search.php
4 weeks ago
post-by-email.php
1 month ago
post-list.php
6 months ago
protect.php
1 month ago
publicize.php
6 months ago
related-posts.php
2 weeks ago
search.php
6 months ago
seo-tools.php
6 months ago
sharedaddy.php
3 months ago
shortcodes.php
6 months ago
shortlinks.php
2 weeks ago
simple-payments.php
6 months ago
sitemaps.php
6 months ago
sso.php
6 months ago
stats.php
1 week ago
subscriptions.php
1 week ago
theme-tools.php
6 months ago
tiled-gallery.php
6 months ago
vaultpress.php
6 months ago
verification-tools.php
1 month ago
videopress.php
6 months ago
waf.php
6 months ago
widget-visibility.php
6 months ago
widgets.php
6 months ago
woocommerce-analytics.php
6 months ago
wordads.php
6 months ago
wpcom-reader.php
3 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 |