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.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 1.7.0.9 All 211 releases
charitable / assets / js / admin / charitable-admin-checklist.js

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

1,061 lines 30.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global Charitable, CharitableCampaignBuilder, wpchar */
2 /**
3 * Charitable Checklist function.
4 *
5 * @since 1.8.1.15
6 */
7 "use strict";
8
9 var CharitableChecklist = window.CharitableChecklist || (function (document, window, $) { /**
10 * Public functions and properties.
11 *
12 * @since 1.8.1.15
13 *
14 * @type {object}
15 */
16 var app = {
17 /**
18 * Start the engine.
19 *
20 * @since 1.8.1.15
21 */
22 init: function () {
23 $(app.ready);
24 $(window).on("load", function () { // in case of jQuery 3.+ we need to wait for an `ready` event first.
25 if (typeof $.ready.then === "function") {
26 $.ready.then(app.load);
27 } else {
28 app.load();
29 }
30 });
31 },
32
33 /**
34 * Document ready.
35 *
36 * @since 1.8.1.15
37 */
38 ready: function () {},
39
40 /**
41 * Window load.
42 *
43 * @since 1.8.1.15
44 */
45 load: function () {
46 app.setup();
47 },
48
49 /**
50 * Initial setup.
51 *
52 * @since 1.8.1.15
53 */
54 setup: function () { // test and see if Shepherd is available, etc. - if not, return.
55 if (typeof Shepherd === "undefined" || typeof charitable_admin_checklist_onboarding === "undefined" || typeof charitable_admin_checklist_onboarding.option === "undefined" || typeof charitable_admin_checklist_onboarding.option.tour === "undefined" || typeof charitable_admin_checklist_onboarding.option.tour.status === "undefined") { // eslint-disable-line
56 return;
57 }
58
59 // If we are on the actual check list page, load the shepherd if there's a # in the URL.
60 if (window.location.search.includes("checklist") && window.location.hash) {
61 app.setupChecklistPage();
62 }
63
64 // If the url includes 'page=charitable-setup-checklist' then load the checklist.
65 if (window.location.search.includes("page=charitable-setup-checklist")) {
66 app.setupChecklistPage();
67 }
68
69 // Detect if there's a change in the hash and load the appropriate step.
70 $(window).on("hashchange", function () {
71 if (window.location.search.includes("checklist") && window.location.hash) {
72 app.setupChecklistPage();
73 }
74 });
75
76 app.events();
77
78 // possible values: 'init', 'started', 'completed', 'skipped'.
79 if (charitable_admin_checklist_onboarding.option.tour.status === "init" || charitable_admin_checklist_onboarding.option.tour.status === "started" || charitable_admin_checklist_onboarding.option.tour.status === "") {
80 app.setupChecklistGeneralSettings();
81 app.setupChecklistEmailSettings();
82 app.setupChecklistGatewaySettings();
83 } else if (charitable_admin_checklist_onboarding.option.tour.status === "started") {}
84
85 // Opt-in to anlaytics/tracking.
86 app.setupAnalyticsTrackingSignInOut();
87 },
88
89 /**
90 * Setup the analytics tracking for sign in and sign out.
91 * This is for the checklist page.
92 *
93 * @since 1.8.4
94 *
95 * @return {void}
96 */
97 setupAnalyticsTrackingSignInOut: function () { // since this is the checklist page, we need to check if the opt-in section is present.
98 if ($('.charitable-step-opt-in').length === 0 || $('.charitable-step-opt-in a.charitable-button').length === 0) {
99 wpchar.debug('not found the charitable-step-opt-in section or the button.');
100 return;
101 }
102
103 $('.charitable-step-opt-in').on('click', 'a.charitable-button', function (e) {
104 e.preventDefault();
105
106 wpchar.debug('clicked on the opt-in button');
107
108 // <i class="fa fa-check"></i>
109
110 // <i class="fa fa-spinner fa-spin"></i>
111
112 var $this = $(this);
113
114 // does this link have an attribute of data-optin-tracking? If not, bail.
115 if ('undefined' === typeof $(this).attr('data-optin-tracking-status')) {
116 wpchar.debug('no data-optin-tracking attribute found.');
117 return;
118 }
119
120 // Replace the fa-arrow-right with a spinner.
121 $this.find('i').removeClass('fa-arrow-right').addClass('fa-spinner fa-spin');
122
123 var data = {
124 action: 'charitable_setup_process_tracking',
125 tracking_action: $(this).attr('data-optin-tracking-status') === 'joined' ? 'opt-out' : 'opt-in',
126 nonce: charitable_admin.nonce
127 };
128
129 $.post(charitable_admin.ajax_url, data, function (response) {
130
131 if (response.success) {
132
133 var tracking = false;
134
135 if (response.data.opt_in_tracking === true) {
136
137 tracking = true;
138
139 wpchar.debug('going with joined');
140 // remove all css classes.
141 $this.attr('data-optin-tracking-status', 'joined');
142 $this.attr('class', 'charitable-button charitable-button-primary');
143 // alter the checklist item to show that it has been completed.
144 $('.chartiable-opt-in-tracking').addClass('charitable-hidden');
145 $('.chartiable-opt-in-tracking-1').removeClass('charitable-hidden');
146 wpchar.debug($this.closest('.charitable-step').find('.charitable-checklist-checkbox'));
147 wpchar.debug($this);
148 $this.closest('.charitable-step').find('.charitable-checklist-checkbox').addClass('charitable-checklist-completed');
149 $this.closest('.charitable-step').find('.charitable-checklist-checkbox').addClass('charitable-checklist-checked');
150
151 // replace the spinner icon with a checkmark.
152 $this.find('i').removeClass('fa-spinner fa-spin').addClass('fa-check');
153
154 } else {
155
156 wpchar.debug('going with not-joined');
157 $this.attr('data-optin-tracking-status', 'not-joined');
158 $this.attr('class', 'charitable-button charitable-button-primary alt');
159 $('.chartiable-opt-in-tracking-1').addClass('charitable-hidden');
160 $('.chartiable-opt-in-tracking').removeClass('charitable-hidden');
161 wpchar.debug($this.closest('.charitable-step').find('.charitable-checklist-checkbox'));
162 wpchar.debug($this);
163 $this.closest('.charitable-step').find('.charitable-checklist-checkbox').removeClass('charitable-checklist-completed');
164 $this.closest('.charitable-step').find('.charitable-checklist-checkbox').removeClass('charitable-checklist-checked');
165
166 // replace the spinner icon with a checkmark.
167 $this.find('i').removeClass('fa-spinner fa-spin').addClass('fa-check');
168
169 }
170
171 if (response.data.text.length > 0) {
172 $this.html(response.data.text + ' <i class="fa fa-check"></i>');
173 }
174
175 // wait one second and then remove the checkmark.
176 setTimeout(function () { // fade removing the checkmark.
177 $this.find('i').fadeOut(1000);
178 // remove the checkmark.
179 $this.find('i').remove();
180
181 if (true === tracking) {
182 $this.closest('.charitable-step').find('a.charitable-toggle').click();
183 }
184 }, 1000);
185
186 } else { // there is has been an error.
187
188 }
189
190 });
191
192 });
193
194
195 },
196
197 /**
198 * Setup the tour steps for the checklist page itself.
199 *
200 * @since 1.8.1.15
201 */
202 setupChecklistPage: function () {
203 var $step_element = null;
204
205 // first, add a on click event to the buttons in the fundrasing box - if the user clicks on the button, then we (via ajax) mark the step as completed.
206 $(".charitable-step.charitable-step-fundraising-next-level").on("click", ".charitable-button", function () { // disable the button and reduce opacity.
207 $(this).attr("disabled", "disabled").css("opacity", "0.5");
208 var stepData = {
209 stepStatus: 'completed',
210 step: 'next-level'
211 };
212 var updateStatus = app.saveChecklistOption(stepData);
213 // refresh the page so items can be updated.
214 updateStatus.done(function () { // reload the page without any hash.
215 window.location.href = window.location.href.split('#')[0];
216 });
217 },);
218
219 // determine the # and load the appropriate step.
220 if (window.location.hash === "#general-settings") {
221 $step_element = $(".charitable-step.charitable-step-plugin-config");
222 } else if (window.location.hash === "#email-settings") {
223 $step_element = $(".charitable-step.charitable-step-email-settings");
224 } else if (window.location.hash === "#connect-gateway") {
225 $step_element = $(".charitable-step.charitable-step-connect-payment");
226 } else if (window.location.hash === "#first-campaign") {
227 $step_element = $(".charitable-step.charitable-step-create-first-campaign",);
228 } else if (window.location.hash === "#first-donation") {
229 $step_element = $(".charitable-step.charitable-step-create-first-donation",);
230 } else if (window.location.hash === "#next-level") {
231 $step_element = $(".charitable-step.charitable-step-fundraising-next-level",);
232 } else {
233 return;
234 }
235
236 if (! $step_element.length) {
237 return;
238 }
239
240 // animate and scroll the screen to the 'charitable-step.charitable-step-plugin-config' div.
241 $("html, body").animate({
242 scrollTop: $step_element.offset().top - 50
243 });
244
245 // make sure the section step is visible.
246 // remove any charitable-angle-right class from the step.
247 $step_element.find(".charitable-angle-right").removeClass("charitable-angle-right");
248 // make sure the charitable-toggle-container is visible.
249 $step_element.find(".charitable-toggle-container").show();
250
251 // Add a style to the class to make background color yellow then fade it to transparent over the course of 5 seconds.
252 $step_element.addClass("charitable-step-highlight");
253 setTimeout(function () {
254 $step_element.removeClass("charitable-step-highlight");
255 }, 1000);
256 },
257
258 /**
259 * Setup the tour steps.
260 *
261 * @since 1.8.1.15
262 */
263 setupChecklistGeneralSettings: function () { // if the url contains the query name of 'checklist' and the value of 'general-settings', then start the tour.
264 if (! window.location.search.includes("checklist=general-settings")) {
265 return;
266 }
267
268 // if the step has already been completed, then return. check the array charitable_admin_checklist_onboarding.option.tour.steps_completed.
269 if (charitable_admin_checklist_onboarding.option.tour.steps_completed.includes("general-settings",)) {
270 return;
271 }
272
273 const checklistTour = new Shepherd.Tour({
274 defaultStepOptions: {
275 cancelIcon: {
276 enabled: true
277 },
278 classes: "",
279 scrollTo: {
280 behavior: "smooth",
281 block: "center"
282 },
283 when: {
284 show() { // remove .shshepherd-target class from the target element.
285 $(".shepherd-target").removeClass("shepherd-target");
286 }
287 }
288 },
289 tourName: "wpchar-checklist-general-settings",
290 useModalOverlay: true
291 });
292
293 checklistTour.addStep({
294 id: "wpchar-checklist-step-general-settings-0",
295 title: charitable_admin_checklist_onboarding.strings.general_settings_step_0_title,
296 text: charitable_admin_checklist_onboarding.strings.general_settings_step_0_text,
297 arrow: false,
298 classes: "wpchar-checklist-step-general-settings-0",
299 buttons: [
300 {
301 text: charitable_admin_checklist_onboarding.strings.ok,
302 classes: "charitable-tour-btn-primary",
303 action: checklistTour.next
304 },
305 ]
306 });
307
308 checklistTour.addStep({
309 id: "wpchar-checklist-step-general-settings-1",
310 text: charitable_admin_checklist_onboarding.strings.general_settings_step_1_text,
311 arrow: true,
312 modalOverlayOpeningPadding: 8,
313 cancelIcon: {
314 enabled: false
315 },
316 attachTo: {
317 element: "p.submit .button.button-primary",
318 on: "bottom"
319 },
320 classes: "wpchar-visual-campaign-builder-step-2",
321 buttons: [
322 {
323 text: charitable_admin_checklist_onboarding.strings.ok,
324 classes: "charitable-tour-btn-primary",
325 action: function () {
326 app.gotoTop();
327 checklistTour.next();
328 }
329 },
330 ]
331 });
332
333 checklistTour.start();
334 },
335
336 /**
337 * Setup the tour steps.
338 *
339 * @since 1.8.1.15
340 */
341 setupChecklistEmailSettings: function () { // if the url contains the query name of 'checklist' and the value of 'email-settings', then start the tour.
342
343 if (! window.location.search.includes("checklist=email-settings")) {
344 return;
345 }
346
347 // if the step has already been completed, then return. check the array charitable_admin_checklist_onboarding.option.tour.steps_completed.
348 if (charitable_admin_checklist_onboarding.option.tour.steps_completed.includes("email-settings",)) {
349 return;
350 }
351
352 const checklistTour = new Shepherd.Tour({
353 defaultStepOptions: {
354 cancelIcon: {
355 enabled: true
356 },
357 classes: "",
358 scrollTo: {
359 behavior: "smooth",
360 block: "center"
361 },
362 when: {
363 show() { // remove .shshepherd-target class from the target element.
364 $(".shepherd-target").removeClass("shepherd-target");
365 }
366 }
367 },
368 tourName: "wpchar-checklist-email-settings",
369 useModalOverlay: true
370 });
371
372 checklistTour.addStep({
373 id: "wpchar-checklist-step-email-settings-0",
374 title: charitable_admin_checklist_onboarding.strings.email_settings_step_0_title,
375 text: charitable_admin_checklist_onboarding.strings.email_settings_step_0_text,
376 arrow: false,
377 classes: "wpchar-checklist-step-email-settings-0",
378 buttons: [
379 {
380 text: charitable_admin_checklist_onboarding.strings.ok,
381 classes: "charitable-tour-btn-primary",
382 action: checklistTour.next
383 },
384 ]
385 });
386
387 checklistTour.addStep({
388 id: "wpchar-checklist-step-email-settings-1",
389 text: charitable_admin_checklist_onboarding.strings.email_settings_step_1_text,
390 arrow: true,
391 modalOverlayOpeningPadding: 8,
392 cancelIcon: {
393 enabled: false
394 },
395 attachTo: {
396 element: "td.charitable-fullwidth div.cf:nth-child(1)",
397 on: "bottom"
398 },
399 classes: "wpchar-checklist-step-email-settings-1",
400 buttons: [
401 {
402 text: charitable_admin_checklist_onboarding.strings.ok,
403 classes: "charitable-tour-btn-primary",
404 action: function () {
405 checklistTour.next();
406 }
407 },
408 ]
409 });
410
411 checklistTour.addStep({
412 id: "wpchar-checklist-step-email-settings-2",
413 text: charitable_admin_checklist_onboarding.strings.email_settings_step_2_text,
414 arrow: true,
415 modalOverlayOpeningPadding: 8,
416 cancelIcon: {
417 enabled: false
418 },
419 attachTo: {
420 element: "td.charitable-fullwidth div.cf:nth-child(3)",
421 on: "bottom"
422 },
423 classes: "wpchar-checklist-step-email-settings-2",
424 buttons: [
425 {
426 text: charitable_admin_checklist_onboarding.strings.ok,
427 classes: "charitable-tour-btn-primary",
428 action: function () {
429 checklistTour.next();
430 }
431 },
432 ]
433 });
434
435 checklistTour.addStep({
436 id: "wpchar-checklist-step-email-settings-3",
437 text: charitable_admin_checklist_onboarding.strings.email_settings_step_3_text,
438 arrow: true,
439 modalOverlayOpeningPadding: 8,
440 cancelIcon: {
441 enabled: false
442 },
443 attachTo: {
444 element: "p.submit .button.button-primary",
445 on: "bottom"
446 },
447 classes: "wpchar-checklist-step-email-settings-3",
448 buttons: [
449 {
450 text: charitable_admin_checklist_onboarding.strings.ok,
451 classes: "charitable-tour-btn-primary",
452 action: function () {
453 app.gotoTop();
454 checklistTour.next();
455 }
456 },
457 ]
458 });
459
460 checklistTour.start();
461 },
462
463 /**
464 * Setup the tour steps.
465 *
466 * @since 1.8.1.15
467 */
468 setupChecklistGatewaySettings: function () { // if the url contains the query name of 'checklist' and the value of 'connect-gateway', then start the tour.
469 if (! window.location.search.includes("checklist=connect-gateway")) {
470 return;
471 }
472
473 // if the step has already been completed, then return. check the array charitable_admin_checklist_onboarding.option.tour.steps_completed.
474 if (charitable_admin_checklist_onboarding.option.tour.steps_completed.includes("connect-gateway",)) {
475 return;
476 }
477
478 const checklistTour = new Shepherd.Tour({
479 defaultStepOptions: {
480 cancelIcon: {
481 enabled: true
482 },
483 classes: "",
484 scrollTo: {
485 behavior: "smooth",
486 block: "center"
487 },
488 when: {
489 show() { // remove .shshepherd-target class from the target element.
490 $(".shepherd-target").removeClass("shepherd-target");
491 }
492 }
493 },
494 tourName: "wpchar-checklist-connect-gateway",
495 useModalOverlay: true
496 });
497
498 checklistTour.addStep({
499 id: "wpchar-checklist-step-connect-gateway-0",
500 text: charitable_admin_checklist_onboarding.strings.gateway_settings_step_0_text,
501 arrow: false,
502 classes: "wpchar-checklist-step-connect-gateway-0",
503 buttons: [
504 {
505 text: charitable_admin_checklist_onboarding.strings.ok,
506 classes: "charitable-tour-btn-primary",
507 action: checklistTour.next
508 },
509 ]
510 });
511
512 checklistTour.addStep({
513 id: "wpchar-checklist-step-connect-gateway-1",
514 text: charitable_admin_checklist_onboarding.strings.gateway_settings_step_1_text,
515 arrow: true,
516 modalOverlayOpeningPadding: 8,
517 cancelIcon: {
518 enabled: false
519 },
520 attachTo: {
521 element: "td.charitable-fullwidth div.cf:nth-child(1)",
522 on: "right"
523 },
524 classes: "wpchar-checklist-step-connect-gateway-1",
525 buttons: [
526 {
527 text: charitable_admin_checklist_onboarding.strings.ok,
528 classes: "charitable-tour-btn-primary",
529 action: function () {
530 checklistTour.next();
531 }
532 },
533 ]
534 });
535
536 checklistTour.addStep({
537 id: "wpchar-checklist-step-connect-gateway-2",
538 text: charitable_admin_checklist_onboarding.strings.gateway_settings_step_2_text,
539 arrow: true,
540 modalOverlayOpeningPadding: 8,
541 cancelIcon: {
542 enabled: false
543 },
544 attachTo: {
545 element: "table.form-table tbody tr:nth-last-child(2) input",
546 on: "right"
547 },
548 classes: "wpchar-checklist-step-connect-gateway-2",
549 buttons: [
550 {
551 text: charitable_admin_checklist_onboarding.strings.ok,
552 classes: "charitable-tour-btn-primary",
553 action: function () {
554 checklistTour.next();
555 }
556 },
557 ]
558 });
559
560 checklistTour.addStep({
561 id: "wpchar-checklist-step-connect-gateway-3",
562 text: charitable_admin_checklist_onboarding.strings.gateway_settings_step_3_text,
563 arrow: true,
564 modalOverlayOpeningPadding: 8,
565 cancelIcon: {
566 enabled: false
567 },
568 attachTo: {
569 element: "p.submit .button.button-primary",
570 on: "right"
571 },
572 classes: "wpchar-checklist-step-connect-gateway-3",
573 buttons: [
574 {
575 text: charitable_admin_checklist_onboarding.strings.ok,
576 classes: "charitable-tour-btn-primary",
577 action: function () {
578 app.gotoTop();
579 checklistTour.next();
580 }
581 },
582 ]
583 });
584
585 checklistTour.start();
586 },
587
588 /**
589 * Scroll to the top of the page.
590 *
591 * @since 1.8.1.15
592 *
593 * @return {void}
594 */
595 gotoTop: function () {
596 $("html, body").animate({
597 scrollTop: 0
598 }, "slow", function () { // do something here?
599 });
600 },
601
602 /**
603 * Setup the tour steps.
604 *
605 * @since 1.8.1.15
606 */
607 setupChecklist: function () {
608 const tour = new Shepherd.Tour({
609 defaultStepOptions: {
610 cancelIcon: {
611 enabled: true
612 },
613 classes: "",
614 scrollTo: {
615 behavior: "smooth",
616 block: "center"
617 },
618 when: {
619 show() {
620 const footer = $(".shepherd-footer"),
621 currentStep = tour ?. getCurrentStep(),
622 currentStepNumber = tour ?. steps.indexOf(currentStep) + 1,
623 totalSteps = tour ?. steps.length;
624
625 if (currentStepNumber === 1 || currentStepNumber === totalSteps) {
626 return;
627 }
628
629 var progressPercentage = (currentStepNumber / totalSteps) * 100;
630
631 if (progressPercentage > 100) {
632 progressPercentage = 100;
633 }
634
635 // insert HTML into footer that is a progress bar showing % of current/completed steps.
636 footer.after('<span class="charitable-tour-progress-bar"><span class="charitable-tour-progress" style="width: ' + progressPercentage + '%"></span></span>',);
637
638 if (currentStepNumber > 2) { // remove .shshepherd-target class from the target element.
639 $(".shepherd-target").removeClass("shepherd-target");
640 }
641 }
642 }
643 },
644 tourName: "wpchar-visual-campaign-builder",
645 useModalOverlay: true
646 });
647
648 tour.addStep({
649 id: "wpchar-visual-campaign-builder-step-0",
650 text: charitable_builder.onboarding_tour.step_0_text,
651 arrow: false,
652 classes: "wpchar-visual-campaign-builder-step-0",
653 buttons: [
654 {
655 text: charitable_builder.onboarding_tour.start_tour,
656 classes: "charitable-tour-btn-primary",
657 action: tour.next
658 }, {
659 text: charitable_builder.onboarding_tour.watch_video,
660 classes: "charitable-tour-btn-primary",
661 action: function () {
662 app.openVideo();
663 }
664 },
665 ]
666 });
667
668 const name_step = tour.addStep({
669 id: "wpchar-visual-campaign-builder-step-1",
670 title: charitable_builder.onboarding_tour.step_1_title,
671 text: charitable_builder.onboarding_tour.step_1_text,
672 attachTo: {
673 element: "#charitable_settings_title",
674 on: "bottom"
675 },
676 classes: "wpchar-visual-campaign-builder-step-1",
677 buttons: [
678 {
679 text: charitable_builder.onboarding_tour.next,
680 classes: "charitable-tour-btn-primary charitable-tour-btn-disabled",
681 action: tour.next
682 },
683 ]
684 });
685
686 tour.addStep({
687 id: "wpchar-visual-campaign-builder-step-2",
688 title: charitable_builder.onboarding_tour.step_2_title,
689 text: charitable_builder.onboarding_tour.step_2_text,
690 arrow: true,
691 modalOverlayOpeningPadding: 8,
692 attachTo: {
693 element: ".charitable-template-animal-sanctuary div.charitable-template",
694 on: "right"
695 },
696 classes: "wpchar-visual-campaign-builder-step-2",
697 buttons: [
698 {
699 text: charitable_builder.onboarding_tour.choose_a_template,
700 classes: "charitable-tour-btn-primary",
701 action: tour.hide
702 },
703 ]
704 });
705
706 tour.addStep({
707 id: "wpchar-visual-campaign-builder-step-3",
708 title: charitable_builder.onboarding_tour.step_3_title,
709 text: charitable_builder.onboarding_tour.step_3_text,
710 arrow: true,
711 modalOverlayOpeningPadding: 5,
712
713 attachTo: {
714 element: "#add-layout",
715 on: "right-end"
716 },
717 classes: "wpchar-visual-campaign-builder-step-3",
718 buttons: [
719 {
720 text: charitable_builder.onboarding_tour.next,
721 classes: "charitable-tour-btn-primary",
722 action: tour.next
723 },
724 ]
725 });
726
727 tour.addStep({
728 id: "wpchar-visual-campaign-builder-step-4",
729 title: charitable_builder.onboarding_tour.step_4_title,
730 text: charitable_builder.onboarding_tour.step_4_text,
731 arrow: true,
732 modalOverlayOpeningPadding: 5,
733 attachTo: {
734 element: "#charitable-tour-block-1",
735 on: "left"
736 },
737 classes: "wpchar-visual-campaign-builder-step-4",
738 buttons: [
739 {
740 text: charitable_builder.onboarding_tour.next,
741 classes: "charitable-tour-btn-primary",
742 action: tour.next
743 },
744 ]
745 });
746
747 tour.addStep({
748 id: "wpchar-visual-campaign-builder-step-5",
749 title: charitable_builder.onboarding_tour.step_5_title,
750 text: charitable_builder.onboarding_tour.step_5_text,
751 arrow: true,
752 modalOverlayOpeningPadding: 5,
753 attachTo: {
754 element: "#charitable-tour-block-2",
755 on: "left"
756 },
757 classes: "wpchar-visual-campaign-builder-step-5",
758 buttons: [
759 {
760 text: charitable_builder.onboarding_tour.next,
761 classes: "charitable-tour-btn-primary",
762 action: tour.next
763 },
764 ]
765 });
766
767 tour.addStep({
768 id: "wpchar-visual-campaign-builder-step-6",
769 title: charitable_builder.onboarding_tour.step_6_title,
770 text: charitable_builder.onboarding_tour.step_6_text,
771 arrow: true,
772 modalOverlayOpeningPadding: 5,
773 attachTo: {
774 element: "#charitable-tour-block-3",
775 on: "left"
776 },
777 classes: "wpchar-visual-campaign-builder-step-6",
778 buttons: [
779 {
780 text: charitable_builder.onboarding_tour.next,
781 classes: "charitable-tour-btn-primary",
782 action: tour.next
783 },
784 ]
785 });
786
787 tour.addStep({
788 id: "wpchar-visual-campaign-builder-step-7",
789 title: charitable_builder.onboarding_tour.step_7_title,
790 text: charitable_builder.onboarding_tour.step_7_text,
791 arrow: true,
792 modalOverlayOpeningPadding: 5,
793 attachTo: {
794 element: "#charitable-save",
795 on: "top-end"
796 },
797 classes: "wpchar-visual-campaign-builder-step-7",
798 buttons: [
799 {
800 text: charitable_builder.onboarding_tour.next,
801 classes: "charitable-tour-btn-primary",
802 action: function () {
803 app.gotoDraftPublishStep();
804 tour.next();
805 }
806 },
807 ]
808 });
809
810 tour.addStep({
811 id: "wpchar-visual-campaign-builder-step-8",
812 title: charitable_builder.onboarding_tour.step_8_title,
813 text: charitable_builder.onboarding_tour.step_8_text,
814 arrow: true,
815 modalOverlayOpeningPadding: 10,
816
817 attachTo: {
818 element: "#charitable-tour-block-4",
819 on: "left-start"
820 },
821 classes: "wpchar-visual-campaign-builder-step-8",
822 buttons: [
823 {
824 text: charitable_builder.onboarding_tour.next,
825 classes: "charitable-tour-btn-primary",
826 action: function () {
827 app.undoDraftPublishStep();
828 tour.next();
829 }
830 },
831 ]
832 });
833
834 tour.addStep({
835 id: "wpchar-visual-campaign-builder-step-9",
836 title: charitable_builder.onboarding_tour.step_9_title,
837 text: charitable_builder.onboarding_tour.step_9_text,
838 arrow: true,
839 modalOverlayOpeningPadding: 3,
840
841 attachTo: {
842 element: "#charitable-preview-btn",
843 on: "top"
844 },
845 classes: "wpchar-visual-campaign-builder-step-9",
846 buttons: [
847 {
848 text: charitable_builder.onboarding_tour.next,
849 classes: "charitable-tour-btn-primary",
850 action: function () {
851 tour.next();
852 }
853 },
854 ]
855 });
856
857 tour.addStep({
858 id: "wpchar-visual-campaign-builder-step-10",
859 title: charitable_builder.onboarding_tour.step_10_title,
860 text: charitable_builder.onboarding_tour.step_10_text,
861 arrow: true,
862 modalOverlayOpeningPadding: 3,
863
864 attachTo: {
865 element: "#charitable-view-btn",
866 on: "top"
867 },
868 classes: "wpchar-visual-campaign-builder-step-10",
869 buttons: [
870 {
871 text: charitable_builder.onboarding_tour.next,
872 classes: "charitable-tour-btn-primary",
873 action: function () {
874 tour.next();
875 }
876 },
877 ]
878 });
879
880 tour.addStep({
881 id: "wpchar-visual-campaign-builder-step-11",
882 title: charitable_builder.onboarding_tour.step_11_title,
883 text: charitable_builder.onboarding_tour.step_11_text,
884 arrow: true,
885 modalOverlayOpeningPadding: 3,
886
887 attachTo: {
888 element: "#charitable-embed",
889 on: "top"
890 },
891 classes: "wpchar-visual-campaign-builder-step-11",
892 buttons: [
893 {
894 text: charitable_builder.onboarding_tour.next,
895 classes: "charitable-tour-btn-primary",
896 action: function () {
897 app.gotoSettingsStep();
898 tour.next();
899 }
900 },
901 ]
902 });
903
904 tour.addStep({
905 id: "wpchar-visual-campaign-builder-step-12",
906 title: charitable_builder.onboarding_tour.step_12_title,
907 text: charitable_builder.onboarding_tour.step_12_text,
908 arrow: true,
909 modalOverlayOpeningPadding: 0,
910
911 attachTo: {
912 element: "#charitable-panel-settings .charitable-panel-sidebar",
913 on: "right"
914 },
915 classes: "wpchar-visual-campaign-builder-step-12",
916 buttons: [
917 {
918 text: charitable_builder.onboarding_tour.next,
919 classes: "charitable-tour-btn-primary",
920 action: function () {
921 CharitableCampaignBuilder.panelSwitch("design");
922 tour.next();
923 }
924 },
925 ]
926 });
927
928 tour.addStep({
929 id: "wpchar-visual-campaign-builder-step-13",
930 title: charitable_builder.onboarding_tour.step_13_title,
931 text: charitable_builder.onboarding_tour.step_13_text,
932 arrow: false,
933 classes: "wpchar-visual-campaign-builder-step-13",
934 cancelIcon: {
935 enabled: false
936 },
937 buttons: [
938 {
939 text: charitable_builder.onboarding_tour.lets_get_started,
940 classes: "charitable-tour-btn-primary",
941 action: tour.next
942 },
943 ]
944 });
945
946 tour.start();
947 },
948
949 /**
950 * Register JS events.
951 *
952 * @since 1.8.1.15
953 */
954 events: function () {
955
956 $(".charitable-checklist-list-block").on("click", ".checklist-skip", function (e) {
957 app.skipChecklist(e);
958 },);
959 $(".charitable-checklist-list-block").on("click", ".checklist-toggle", function (e) {
960 app.toggleChecklist(e);
961 },);
962
963 },
964
965 /**
966 * Toggle checklist icon click.
967 *
968 * @since 1.8.2
969 *
970 * @param {object} e Event object.
971 */
972 toggleChecklist: function (e) {
973
974 var $icon = $(e.target),
975 $listBlock = $('.charitable-checklist-list-block');
976
977 if (! $listBlock.length || ! $icon.length) {
978 return;
979 }
980
981 if ($listBlock.hasClass('closed')) {
982 charitable_admin_checklist_onboarding.option.window_closed = '0';
983 $listBlock.removeClass('closed');
984
985 setTimeout(function () {
986 $listBlock.removeClass('transition-back');
987 }, 600);
988 } else {
989 charitable_admin_checklist_onboarding.option.window_closed = '1';
990 $listBlock.addClass('closed');
991
992 // Add `transition-back` class when the forward transition is completed.
993 // It is needed to properly implement transitions order for some elements.
994 setTimeout(function () {
995 $listBlock.addClass('transition-back');
996 }, 600);
997 }
998
999
1000 var optionData = {
1001 status: "",
1002 window_closed: charitable_admin_checklist_onboarding.option.window_closed
1003 };
1004
1005 app.saveChecklistOption(optionData);
1006
1007 },
1008
1009 /**
1010 * Skip the Checklist without starting it.
1011 *
1012 * @since 1.8.2
1013 */
1014 skipChecklist: function () {
1015 var optionData = {
1016 status: "skipped",
1017 seconds_spent: 0,
1018 seconds_left: 0
1019 };
1020
1021 // remove the widget in the lower right hand corner
1022 $(".charitable-checklist").remove();
1023
1024 // this removes the menu option in the WordPress admin.
1025 $('#adminmenu a[href="admin.php?page=charitable-setup-checklist"]').parent().remove();
1026
1027 app.saveChecklistOption(optionData);
1028 },
1029
1030 /**
1031 * Set Challenge parameter(s) to Challenge option.
1032 *
1033 * @since 1.8.2
1034 *
1035 * @param {object} optionData Query using option schema keys.
1036 *
1037 * @returns {promise} jQuery.post() promise interface.
1038 */
1039 saveChecklistOption: function (optionData) {
1040 var data = {
1041 action: "charitable_onboarding_checklist_save_option",
1042 option_data: optionData,
1043 _wpnonce: charitable_admin_checklist_onboarding.nonce
1044 };
1045
1046 return $.post(ajaxurl, data, function (response) {
1047 if (! response.success) {
1048 console.error("Error saving Charitable Checklist option.");
1049 }
1050 });
1051 }
1052 };
1053
1054 // Provide access to public functions/properties.
1055 return app;
1056 })(document, window, jQuery);
1057 // eslint-disable-line
1058
1059 // Initialize.
1060 CharitableChecklist.init();
1061