PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / 2.0.0.1
Admin Help Docs v2.0.0.1
2.0.1.1 trunk 1.4.3.2 2.0.0 2.0.0.1 2.0.0.2 2.0.1
admin-help-docs / inc / docs / page-locations / js / top.js
admin-help-docs / inc / docs / page-locations / js Last commit date
bottom.js 3 months ago contextual.js 3 months ago element.js 3 months ago side.js 3 months ago top.js 3 months ago
top.js
40 lines
1 jQuery( document ).ready( function( $ ) {
2 const data = typeof helpdocs_top !== 'undefined' ? helpdocs_top : {};
3 const docs = data.docs || [];
4 const template = data.template || '';
5
6 if ( docs.length === 0 ) return;
7
8 /**
9 * Gutenberg Injection logic
10 */
11 const renderGutenbergTopDocs = function() {
12 const $target = $( '.interface-interface-skeleton__content' );
13
14 if ( $target.length && docs.length && template ) {
15 // Prevent duplicate injection
16 if ( $target.find( '.helpdocs-gutenberg-top' ).length ) return;
17
18 let html = '<div class="helpdocs-top-wrapper helpdocs-gutenberg-top wrap">';
19
20 $.each( docs, function( index, doc ) {
21 let docHtml = template
22 .replace( '{doc_title}', doc.title )
23 .replace( '{doc_content}', doc.content );
24
25 html += docHtml;
26 } );
27
28 html += '</div>';
29
30 $target.prepend( html );
31 }
32 };
33
34 const checkGutenberg = setInterval( function() {
35 if ( $( '.interface-interface-skeleton__content' ).length ) {
36 renderGutenbergTopDocs();
37 clearInterval( checkGutenberg );
38 }
39 }, 500 );
40 } );