PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.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 All 502 releases
jetpack / modules / infinite-scroll / infinity-customizer.js

infinity-customizer.js in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at modules/infinite-scroll/infinity-customizer.js

54 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function ( $ ) {
2 /**
3 * Ready, set, go!
4 */
5 $( document ).ready( function () {
6 // Integrate with Selective Refresh in the Customizer.
7 if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) {
8 /**
9 * Handle rendering of selective refresh partials.
10 *
11 * Make sure that when a partial is rendered, the Jetpack post-load event
12 * will be triggered so that any dynamic elements will be re-constructed,
13 * such as ME.js elements, Photon replacements, social sharing, and more.
14 * Note that this is applying here not strictly to posts being loaded.
15 * If a widget contains a ME.js element and it is previewed via selective
16 * refresh, the post-load would get triggered allowing any dynamic elements
17 * therein to also be re-constructed.
18 *
19 * @param {wp.customize.selectiveRefresh.Placement} placement
20 */
21 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function ( placement ) {
22 var content;
23 if ( 'string' === typeof placement.addedContent ) {
24 content = placement.addedContent;
25 } else if ( placement.container ) {
26 content = $( placement.container ).html();
27 }
28
29 if ( content ) {
30 $( document.body ).trigger( 'post-load', { html: content } );
31 }
32 } );
33
34 /*
35 * Add partials for posts added via infinite scroll.
36 *
37 * This is unnecessary when MutationObserver is supported by the browser
38 * since then this will be handled by Selective Refresh in core.
39 */
40 if ( 'undefined' === typeof MutationObserver ) {
41 $( document.body ).on( 'post-load', function ( e, response ) {
42 var rootElement = null;
43 if ( response.html && -1 !== response.html.indexOf( 'data-customize-partial' ) ) {
44 if ( window.infiniteScroll.settings.id ) {
45 rootElement = $( '#' + window.infiniteScroll.settings.id );
46 }
47 wp.customize.selectiveRefresh.addPartials( rootElement );
48 }
49 } );
50 }
51 }
52 } );
53 } )( jQuery ); // Close closure
54