1var wpcf7_redirect; 2 3(function ($) { 4 function Wpcf7_redirect() { 5 this.init = function () { 6 this.wpcf7_redirect_mailsent_handler(); 7 }; 8 9 this.wpcf7_redirect_mailsent_handler = function () { 10 11 document.addEventListener('wpcf7mailsent', function (event) { 12 13 $(document.body).trigger('wpcf7r-mailsent', [event]); 14 15 if (typeof event.detail.apiResponse != 'undefined' && event.detail.apiResponse) { 16 var apiResponse = event.detail.apiResponse; 17 var actionDelay = 0; 18 19 //handle api response 20 if (typeof apiResponse.api_url_request != 'undefined' && apiResponse.api_url_request) { 21 wpcf7_redirect.handle_api_action(apiResponse.api_url_request); 22 } 23 24 //handle api response 25 if (typeof apiResponse.api_json_xml_request != 'undefined' && apiResponse.api_json_xml_request) { 26 wpcf7_redirect.handle_api_action(apiResponse.api_json_xml_request); 27 } 28 29 //handle fire javascript action 30 if (typeof apiResponse.FireScript != 'undefined' && apiResponse.FireScript) { 31 actionDelay = typeof apiResponse.FireScript.delay_redirect != 'undefined' ? apiResponse.FireScript.delay_redirect : actionDelay; 32 window.setTimeout(function () { 33 wpcf7_redirect.handle_javascript_action(apiResponse.FireScript); 34 }, actionDelay); 35 } 36 37 //catch and handle popup action 38 if (typeof apiResponse.popup != 'undefined' && apiResponse.popup) { 39 wpcf7_redirect.handle_popups(apiResponse.popup); 40 } 41 42 //catch redirect to paypal 43 if (typeof apiResponse.redirect_to_paypal != 'undefined' && apiResponse.redirect_to_paypal) { 44 actionDelay = typeof apiResponse.redirect_to_paypal.delay_redirect != 'undefined' ? apiResponse.redirect_to_paypal.delay_redirect : actionDelay; 45 window.setTimeout(function () { 46 wpcf7_redirect.handle_redirect_action(apiResponse.redirect_to_paypal); 47 }, actionDelay); 48 } 49 50 //catch redirect action 51 if (typeof apiResponse.redirect != 'undefined' && apiResponse.redirect) { 52 actionDelay = typeof apiResponse.redirect.delay_redirect != 'undefined' ? apiResponse.redirect.delay_redirect : actionDelay; 53 window.setTimeout(function () { 54 wpcf7_redirect.handle_redirect_action(apiResponse.redirect); 55 }, actionDelay); 56 } 57 } 58 }, false); 59 60 document.addEventListener('wpcf7invalid', function (event) { 61 62 $(document.body).trigger('wpcf7r-invalid', [event]); 63 64 if (typeof event.detail.apiResponse != 'undefined' && event.detail.apiResponse) { 65 response = event.detail.apiResponse; 66 if (response.invalidFields) { 67 //support for multistep by ninja 68 wpcf7_redirect.ninja_multistep_mov_to_invalid_tab(event, response); 69 } 70 } 71 }); 72 }; 73 74 this.handle_popups = function (popups) { 75 76 $(document.body).trigger('wpcf7r-before-open-popup', [event]); 77 78 $.each(popups, function (k, popup) { 79 80 var $new_elem = $(popup['popup-template']); 81 82 $(document.body).append($new_elem); 83 $(document.body).addClass(popup['template-name']); 84 85 window.setTimeout(function () { 86 $(document.body).addClass('modal-popup-open'); 87 $new_elem.addClass('is-open'); 88 }, 1000); 89 90 $new_elem.find('.close-button').on('click', function () { 91 92 $new_elem.removeClass('is-open').addClass('fade'); 93 94 $(document.body).removeClass('modal-popup-open'); 95 96 window.setTimeout(function () { 97 $('.wpcf7r-modal').remove(); 98 $(document.body).trigger('wpcf7r-popup-removed', [$new_elem]); 99 }, 4000); 100 }); 101 102 $(document.body).trigger('wpcf7r-popup-appended', [$new_elem]); 103 }); 104 105 } 106 107 this.handle_api_action = function (send_to_api_result, request) { 108 109 $.each(send_to_api_result, function (k, v) { 110 if (!v.result_javascript) { 111 return; 112 } 113 response = typeof v.api_response != 'undefined' ? v.api_response : ''; 114 request = typeof v.request != 'undefined' ? v.request : ''; 115 eval(v.result_javascript); 116 }); 117 }; 118
119 this.ninja_multistep_mov_to_invalid_tab = function (event, response) { 120 121 if ($('.fieldset-cf7mls-wrapper').length) { 122 var form = $(event.target); 123 var first_invalid_field = response.invalidFields[0]; 124 var parent_step = $(first_invalid_field.into).parents('fieldset'); 125 126 form.find('.fieldset-cf7mls').removeClass('cf7mls_current_fs'); 127 parent_step.addClass('cf7mls_current_fs').removeClass('cf7mls_back_fs'); 128 if (form.find('.cf7mls_progress_bar').length) { 129 form.find('.cf7mls_progress_bar li').eq(form.find("fieldset.fieldset-cf7mls").index(previous_fs)).addClass("current"); 130 form.find('.cf7mls_progress_bar li').eq(form.find("fieldset.fieldset-cf7mls").index(current_fs)).removeClass("active current"); 131 } 132 } 133 } 134 135 this.handle_redirect_action = function (redirect) { 136 137 $(document.body).trigger('wpcf7r-handle_redirect_action', [redirect]); 138 139 $.each(redirect, function (k, v) { 140 var delay = typeof v.delay != 'undefined' && v.delay ? v.delay : ''; 141 142 delay = delay * 1000; 143 144 window.setTimeout(function (v) { 145 var redirect_url = typeof v.redirect_url != 'undefined' && v.redirect_url ? v.redirect_url : ''; 146 var type = typeof v.type != 'undefined' && v.type ? v.type : ''; 147 148 if (typeof v.form != 'undefined' && v.form) { 149 $('body').append(v.form); 150 $('#cf7r-result-form').submit(); 151 } else { 152 153 if (redirect_url && type == 'redirect') { 154 window.location = redirect_url; 155 } else if (redirect_url && type == 'new_tab') { 156 window.open(redirect_url); 157 } 158 } 159 }, delay, v); 160 161 }); 162 163 }; 164 165 this.handle_javascript_action = function (scripts) { 166 167 $(document.body).trigger('wpcf7r-handle_javascript_action', [scripts]); 168 169 $.each(scripts, function (k, script) { 170 eval(script); //not using user input 171 }); 172 173 }; 174 175 this.htmlspecialchars_decode = function (string) { 176 177 var map = { 178 '&': '&', 179 '&': "&", 180 '<': '<', 181 '>': '>', 182 '"': '"', 183 ''': "'", 184 '’': "â", 185 '‘': "â", 186 '–': "â", 187 '—': "â", 188 '…': "â¦", 189 '”': 'â' 190 }; 191 192 return string.replace(/\&[\w\d\#]{2,5}\;/g, function (m) { return map[m]; }); 193 }; 194 195 this.init(); 196 } 197 198 wpcf7_redirect = new Wpcf7_redirect(); 199})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.