/* global gapi, FB, twttr, PaypalExpressCheckout */ /** * Utilities to work with widgets in Customizer. */ /** * Checks whether this Customizer supports partial widget refresh. * @return {boolean} */ wp.customizerHasPartialWidgetRefresh = function () { return ( 'object' === typeof wp && 'function' === typeof wp.customize && 'object' === typeof wp.customize.selectiveRefresh && 'object' === typeof wp.customize.widgetsPreview && 'function' === typeof wp.customize.widgetsPreview.WidgetPartial ); }; /** * Verifies that the placed widget ID contains the widget name. * @param {object} placement * @param {string} widgetName * @return {*|boolean} */ wp.isJetpackWidgetPlaced = function ( placement, widgetName ) { return placement.partial.widgetId && 0 === placement.partial.widgetId.indexOf( widgetName ); }; /** * Bind events for selective refresh in Customizer. */ ( function ( $ ) { $( document ).ready( function () { if ( wp && wp.customize && wp.customizerHasPartialWidgetRefresh() ) { // Refresh widget contents when a partial is rendered. wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function ( placement ) { if ( placement.container ) { // Refresh Google+ if ( wp.isJetpackWidgetPlaced( placement, 'googleplus-badge' ) && 'object' === typeof gapi && gapi.person && 'function' === typeof gapi.person.go ) { gapi.person.go( placement.container[ 0 ] ); } // Refresh Facebook XFBML else if ( wp.isJetpackWidgetPlaced( placement, 'facebook-likebox' ) && 'object' === typeof FB && 'object' === typeof FB.XFBML && 'function' === typeof FB.XFBML.parse ) { FB.XFBML.parse( placement.container[ 0 ], function () { var $fbContainer = $( placement.container[ 0 ] ).find( '.fb_iframe_widget' ), fbWidth = $fbContainer.data( 'width' ), fbHeight = $fbContainer.data( 'height' ); $fbContainer.find( 'span' ).css( { width: fbWidth, height: fbHeight } ); setTimeout( function () { $fbContainer .find( 'iframe' ) .css( { width: fbWidth, height: fbHeight, position: 'relative' } ); }, 1 ); } ); } // Refresh Twitter else if ( wp.isJetpackWidgetPlaced( placement, 'twitter_timeline' ) && 'object' === typeof twttr && 'object' === typeof twttr.widgets && 'function' === typeof twttr.widgets.load ) { twttr.widgets.load( placement.container[ 0 ] ); } else if ( wp.isJetpackWidgetPlaced( placement, 'eu_cookie_law_widget' ) ) { // Refresh EU Cookie Law if ( $( '#eu-cookie-law' ).hasClass( 'top' ) ) { $( '.widget_eu_cookie_law_widget' ).addClass( 'top' ); } else { $( '.widget_eu_cookie_law_widget' ).removeClass( 'top' ); } placement.container.fadeIn(); } else if ( wp.isJetpackWidgetPlaced( placement, 'jetpack_simple_payments_widget' ) ) { // Refresh Simple Payments Widget try { var buttonId = $( '.jetpack-simple-payments-button', placement.container ) .attr( 'id' ) .replace( '_button', '' ); PaypalExpressCheckout.renderButton( null, null, buttonId, null ); } catch { // PaypalExpressCheckout may fail. // For the same usage, see also: // https://github.com/Automattic/jetpack/blob/6c1971e6bed7d3df793392a7a58ffe0afaeeb5fe/modules/simple-payments/simple-payments.php#L111 } } } } ); // Refresh widgets when they're moved. wp.customize.selectiveRefresh.bind( 'partial-content-moved', function ( placement ) { if ( placement.container ) { // Refresh Twitter timeline iframe, since it has to be re-built. if ( wp.isJetpackWidgetPlaced( placement, 'twitter_timeline' ) && placement.container.find( 'iframe.twitter-timeline:not([src]):first' ).length ) { placement.partial.refresh(); } else if ( wp.isJetpackWidgetPlaced( placement, 'jetpack_simple_payments_widget' ) ) { // Refresh Simple Payments Widget placement.partial.refresh(); } } } ); } } ); } )( jQuery );
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
authors | Folder | 0755 |
|
|
contact-info | Folder | 0755 |
|
|
eu-cookie-law | Folder | 0755 |
|
|
facebook-likebox | Folder | 0755 |
|
|
flickr | Folder | 0755 |
|
|
gallery | Folder | 0755 |
|
|
goodreads | Folder | 0755 |
|
|
google-translate | Folder | 0755 |
|
|
image-widget | Folder | 0755 |
|
|
Folder | 0755 |
|
||
internet-defense-league | Folder | 0755 |
|
|
migrate-to-core | Folder | 0755 |
|
|
milestone | Folder | 0755 |
|
|
my-community | Folder | 0755 |
|
|
simple-payments | Folder | 0755 |
|
|
social-icons | Folder | 0755 |
|
|
social-media-icons | Folder | 0755 |
|
|
top-posts | Folder | 0755 |
|
|
wordpress-post-widget | Folder | 0755 |
|
|
authors.php | File | 8.95 KB | 0644 |
|
blog-stats.php | File | 6.11 KB | 0644 |
|
class-jetpack-eu-cookie-law-widget.php | File | 10.55 KB | 0644 |
|
class-jetpack-instagram-widget.php | File | 24.05 KB | 0644 |
|
contact-info.php | File | 17.95 KB | 0644 |
|
customizer-controls.css | File | 165 B | 0644 |
|
customizer-utils.js | File | 4.06 KB | 0644 |
|
facebook-likebox.php | File | 15.28 KB | 0644 |
|
flickr.php | File | 7.46 KB | 0644 |
|
gallery.php | File | 16.14 KB | 0644 |
|
goodreads.php | File | 8.71 KB | 0644 |
|
google-translate.php | File | 6.44 KB | 0644 |
|
gravatar-profile.css | File | 1.23 KB | 0644 |
|
gravatar-profile.php | File | 16.04 KB | 0644 |
|
image-widget.php | File | 12.09 KB | 0644 |
|
internet-defense-league.php | File | 5.65 KB | 0644 |
|
mailchimp.php | File | 4.29 KB | 0644 |
|
milestone.php | File | 346 B | 0644 |
|
my-community.php | File | 10.93 KB | 0644 |
|
rsslinks-widget.php | File | 10.6 KB | 0644 |
|
simple-payments.php | File | 21.91 KB | 0644 |
|
social-icons.php | File | 22.41 KB | 0644 |
|
social-media-icons.php | File | 10.72 KB | 0644 |
|
top-posts.php | File | 27.65 KB | 0644 |
|
twitter-timeline-admin.js | File | 2.18 KB | 0644 |
|
twitter-timeline.php | File | 19.9 KB | 0644 |
|
upcoming-events.php | File | 6.73 KB | 0644 |
|
wordpress-post-widget.php | File | 3.71 KB | 0644 |
|