2022-04-02 10:26:41 +02:00
|
|
|
/* global jp_banner */
|
2019-11-15 23:26:29 +01:00
|
|
|
|
2020-09-15 14:30:05 +02:00
|
|
|
( function ( $ ) {
|
2022-12-15 17:41:53 +01:00
|
|
|
var fullScreenContainer = $( '.jp-connect-full__container' ),
|
2019-11-15 23:26:29 +01:00
|
|
|
fullScreenDismiss = $( '.jp-connect-full__dismiss, .jp-connect-full__dismiss-paragraph' ),
|
|
|
|
|
wpWelcomeNotice = $( '#welcome-panel' ),
|
2022-12-15 17:41:53 +01:00
|
|
|
connectionBanner = $( '.jp-connection-banner' ),
|
|
|
|
|
connectionBannerDismiss = $( '.jp-connection-banner__dismiss' );
|
2019-11-15 23:26:29 +01:00
|
|
|
|
|
|
|
|
// Move the banner below the WP Welcome notice on the dashboard
|
2020-09-15 14:30:05 +02:00
|
|
|
$( window ).on( 'load', function () {
|
2019-11-15 23:26:29 +01:00
|
|
|
wpWelcomeNotice.insertBefore( connectionBanner );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
// Dismiss the connection banner via AJAX
|
2020-09-15 14:30:05 +02:00
|
|
|
connectionBannerDismiss.on( 'click', function () {
|
2019-11-15 23:26:29 +01:00
|
|
|
$( connectionBanner ).hide();
|
|
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
|
action: 'jetpack_connection_banner',
|
|
|
|
|
nonce: jp_banner.connectionBannerNonce,
|
|
|
|
|
dismissBanner: true,
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-15 14:30:05 +02:00
|
|
|
$.post( jp_banner.ajax_url, data, function ( response ) {
|
2019-11-15 23:26:29 +01:00
|
|
|
if ( true !== response.success ) {
|
|
|
|
|
$( connectionBanner ).show();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Full-screen connection prompt
|
|
|
|
|
*/
|
2020-09-15 14:30:05 +02:00
|
|
|
fullScreenDismiss.on( 'click', function () {
|
2019-11-15 23:26:29 +01:00
|
|
|
$( fullScreenContainer ).hide();
|
|
|
|
|
} );
|
|
|
|
|
|
2020-09-15 14:30:05 +02:00
|
|
|
$( document ).keyup( function ( e ) {
|
2022-12-15 17:41:53 +01:00
|
|
|
if ( e.code === 'Escape' ) {
|
2019-11-15 23:26:29 +01:00
|
|
|
$( fullScreenDismiss ).click();
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
} )( jQuery );
|