PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.33
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.33
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / js / admin / deactivation-feedback.js

deactivation-feedback.js in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.33, at js/admin/deactivation-feedback.js

116 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function() {
2 'use strict';
3
4 const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-pro"] .deactivate a, tr[data-slug="formidable-forms-pro"] .deactivate a';
5
6 let deactivationModal;
7 let deactivationUrl;
8
9 const Modal = {
10 init( id, width ) {
11 const $info = jQuery( id );
12 const self = this;
13
14 if ( ! $info.length ) {
15 return false;
16 }
17
18 if ( width === undefined ) {
19 width = '550px';
20 }
21
22 const dialogArgs = {
23 dialogClass: 'frm-dialog',
24 modal: true,
25 autoOpen: false,
26 closeOnEscape: true,
27 width,
28 resizable: false,
29 draggable: false,
30 open() {
31 jQuery( '.ui-dialog-titlebar' ).addClass( 'frm_hidden' ).removeClass( 'ui-helper-clearfix' );
32 jQuery( '#wpwrap' ).addClass( 'frm_overlay' );
33 jQuery( '.frm-dialog' ).removeClass( 'ui-widget ui-widget-content ui-corner-all' );
34 $info.removeClass( 'ui-dialog-content ui-widget-content' );
35 self.bindClickForDialogClose( $info );
36 },
37 close() {
38 jQuery( '#wpwrap' ).removeClass( 'frm_overlay' );
39 jQuery( '.spinner' ).css( 'visibility', 'hidden' );
40
41 this.removeAttribute( 'data-option-type' );
42 const optionType = document.getElementById( 'bulk-option-type' );
43 if ( optionType ) {
44 optionType.value = '';
45 }
46 }
47 };
48
49 $info.dialog( dialogArgs );
50
51 return $info;
52 },
53
54 bindClickForDialogClose( $modal ) {
55 const closeModal = function() {
56 $modal.dialog( 'close' );
57 };
58 jQuery( '.ui-widget-overlay' ).on( 'click', closeModal );
59 $modal.on( 'click', 'a.dismiss', closeModal );
60 }
61 };
62
63 const addSkipBtn = formEl => {
64 const btn = frmDom.a( {
65 text: FrmDeactivationFeedbackI18n.skip_text,
66 href: deactivationUrl,
67 className: 'frm-skip-link'
68 } );
69
70 formEl.querySelector( '.frm_submit' ).prepend( btn );
71 };
72
73 const onClickDeactivate = event => {
74 event.preventDefault();
75
76 if ( ! deactivationModal ) {
77 deactivationModal = Modal.init(
78 '#frm-deactivation-modal',
79 '440px'
80 );
81 }
82
83 deactivationUrl = `${ event.target.href }&frm_feedback_submitted=1`;
84
85 const pluginSlug = event.target.closest( 'tr' ).dataset.slug;
86
87 const url = `https://feedback.strategy11.com/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=${ pluginSlug }&site=${ window.location.host }&return=html&exclude_script=jquery&exclude_style=formidable-css`;
88
89 const response = fetch( url, {
90 method: 'GET'
91 } );
92
93 response
94 .then( response => response.json() )
95 .then( response => {
96 const wrapper = document.getElementById( 'frm-deactivation-form-wrapper' );
97 const form = response.renderedHtml.replace( /<link\b[^>]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' );
98
99 jQuery( wrapper ).html( form );
100 wrapper.setAttribute( 'data-slug', pluginSlug );
101 addSkipBtn( wrapper );
102 deactivationModal.dialog( 'open' );
103 } )
104 .catch( error => {
105 console.error( error );
106 } );
107 };
108
109 frmDom.util.documentOn( 'click', selectors, onClickDeactivate );
110
111 document.addEventListener( 'frmFormCompleteBeforeReplace', function( event ) {
112 document.getElementById( 'frm-deactivation-modal-icon' ).remove();
113 window.location.href = deactivationUrl;
114 } );
115 }() );
116