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