PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 14.2
Jetpack – WP Security, Backup, Speed, & Growth v14.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / wpgroho.js
wpgroho.js
81 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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