PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11
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-admin-splash.js

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

148 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global charitable_admin_splash_data, ajaxurl */
2 /**
3 * Charitable Admin Splash.
4 *
5 * @since 1.8.6
6 */
7 const CharitableAdminSplash = window.CharitableAdminSplash || ( function( document, window, $ ) {
8 /**
9 * Public functions and properties.
10 *
11 * @since 1.8.6
12 *
13 * @type {Object}
14 */
15 const app = {
16
17 /**
18 * Initialize.
19 *
20 * @since 1.8.6
21 */
22 init() {
23 $( app.ready );
24 },
25
26 /**
27 * Document ready.
28 *
29 * @since 1.8.6
30 */
31 ready() {
32 app.events();
33
34 if ( charitable_admin_splash_data.triggerForceOpen ) {
35 app.openModal();
36 }
37 },
38
39 /**
40 * Events.
41 *
42 * @since 1.8.6
43 */
44 events() {
45 $( document )
46 .on( 'click', '.charitable-splash-modal-open', function( e ) {
47 e.preventDefault();
48 app.openModal();
49 } );
50 },
51
52 /**
53 * Open the modal.
54 *
55 * @since 1.8.6
56 */
57 openModal() {
58 $.alert( {
59 title: false,
60 content: wp.template( 'charitable-splash-modal-content' )(),
61 icon: false,
62 closeIcon: true,
63 boxWidth: '1000px',
64 theme: 'modern',
65 useBootstrap: false,
66 scrollToPreviousElement: false,
67 buttons: false,
68 backgroundDismiss: true,
69 offsetTop: 50,
70 offsetBottom: 50,
71 animation: 'opacity',
72 closeAnimation: 'opacity',
73 animateFromElement: false,
74 onOpenBefore() {
75 const scrollbarWidth = ( window.innerWidth - document.body.clientWidth ) + 'px';
76
77 $( 'body' )
78 .addClass( 'charitable-splash-modal' )
79 .css( '--charitable-body-scrollbar-width', scrollbarWidth );
80
81 $( '.charitable-challenge-popup-container' ).addClass( 'charitable-invisible' );
82
83 setTimeout( () => {
84 if ( navigator.userAgent.includes( 'Safari' ) && ! navigator.userAgent.includes( 'Chrome' ) ) {
85 $( 'html, body' ).animate( { scrollTop: 0 }, 0 );
86 }
87
88 $( '.jconfirm-box-container' )
89 .css( 'padding-top', '50px' )
90 .animate( { opacity: 1 }, 30 );
91 }, 0 );
92 },
93 onOpen() {
94 $( '.jconfirm' ).css( 'bottom', 0 );
95 $( '.charitable-dash-widget-welcome-block' ).remove();
96 app.injectVideoEmbeds();
97 },
98 onDestroy() {
99 $( 'body' )
100 .removeClass( 'charitable-splash-modal' )
101 .css( '--charitable-body-scrollbar-width', null );
102 },
103 } );
104 },
105
106 /**
107 * Inject video iframes into placeholder divs.
108 *
109 * The PHP template renders empty divs with data-vimeo-id; we build the
110 * iframe client-side because admin output filters can strip server-rendered
111 * iframes from the response.
112 *
113 * @since 1.8.10.6
114 */
115 injectVideoEmbeds() {
116 $( '.charitable-splash-video-embed[data-vimeo-id]' ).each( function() {
117 const $el = $( this );
118
119 if ( $el.children( 'iframe' ).length ) {
120 return;
121 }
122
123 const id = String( $el.attr( 'data-vimeo-id' ) || '' ).replace( /[^0-9]/g, '' );
124
125 if ( ! id ) {
126 return;
127 }
128
129 const title = $el.attr( 'data-video-title' ) || '';
130 const iframe = document.createElement( 'iframe' );
131
132 iframe.src = 'https://player.vimeo.com/video/' + id + '?autoplay=0&muted=1&controls=1&dnt=1';
133 iframe.setAttribute( 'frameborder', '0' );
134 iframe.setAttribute( 'allow', 'fullscreen; picture-in-picture' );
135 iframe.setAttribute( 'allowfullscreen', '' );
136 iframe.setAttribute( 'title', title );
137
138 $el.append( iframe );
139 } );
140 },
141 };
142
143 // Provide access to public functions/properties.
144 return app;
145 }( document, window, jQuery ) );
146
147 CharitableAdminSplash.init();
148