PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 10.3
Jetpack – WP Security, Backup, Speed, & Growth v10.3
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
77 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 ] ) continue;
8
9 for ( var key in arguments[ i ] ) {
10 if ( arguments[ i ].hasOwnProperty( 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