PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / assets / js / admin / charitable-external-banner.js

charitable-external-banner.js in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at assets/js/admin/charitable-external-banner.js

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Charitable External Banner
3 *
4 * Handles positioning, display, and dismissal of Charitable banners
5 * on non-Charitable admin screens.
6 *
7 * @since 1.8.10
8 */
9 ( function( $ ) {
10
11 $( document ).ready( function() {
12
13 var $banner = $( '.charitable-external-banner' );
14
15 if ( ! $banner.length ) {
16 return;
17 }
18
19 // Reposition the banner before the main content area.
20 // GiveWP React pages use root divs like #give-admin-campaigns-root.
21 // Traditional pages use .wrap containers.
22 var $target = $( '#wpbody-content' ).children( '[id^="give-admin-"], [id="reports-app"], .wrap' ).first();
23
24 if ( $target.length ) {
25 $banner.detach().insertBefore( $target );
26 } else {
27 // Fallback: prepend to #wpbody-content.
28 $banner.detach().prependTo( '#wpbody-content' );
29 }
30
31 // Slide the banner down.
32 var bannerId = $banner.data( 'banner-id' );
33 var seenKey = 'charitable-ext-banner-' + bannerId + '-seen';
34
35 if ( window.localStorage.getItem( seenKey ) ) {
36 $banner.show();
37 } else {
38 setTimeout( function() {
39 window.localStorage.setItem( seenKey, true );
40 $banner.slideDown( 300 );
41 }, 800 );
42 }
43
44 // Dismiss handler.
45 $banner.on( 'click', '.charitable-external-banner-dismiss', function( e ) {
46 e.preventDefault();
47
48 var nonce = $banner.data( 'nonce' );
49
50 $.ajax( {
51 type: 'POST',
52 url: charitable_external_banner.ajaxurl,
53 data: {
54 action: 'charitable_dismiss_external_banner',
55 banner_id: bannerId,
56 nonce: nonce,
57 },
58 dataType: 'json',
59 success: function() {
60 $banner.slideUp( 'fast', function() {
61 $banner.remove();
62 } );
63 window.localStorage.removeItem( seenKey );
64 },
65 } );
66 } );
67 } );
68
69 } )( jQuery );
70