PageSourceSearch

https://www.kayapaper.com/js/9a448a5baf0b671b0ddc6c0ba5e47a94/cf7mls.js

js kayapaper.com collected 2026-10-07 13:11:36 UTC 13,230 bytes, 345 lines download raw bytes

1(function($){
2    //jQuery time
3    var current_fs, next_fs, previous_fs; //fieldsets
4    var left, opacity, scale; //fieldset properties which we will animate
5    var animating; //flag to prevent quick multi-click glitches
6    var has_response = false;
7    var preview_clicked = false;
8
9    jQuery(document).ready(function($) {
10        $('form.wpcf7-form').each(function(index, el) {
11            var totalFieldset = 0;
12            var this_form = $(el);
13            var findFieldset = $(el).find('fieldset.fieldset-cf7mls');
14            if (findFieldset.length > 0) {
15                $.each(findFieldset, function(i2, el2) {
16                    if (i2 == 0) {
17                        $(el2).addClass('cf7mls_current_fs');
18                    }
19
20                    jQuery(el2).attr('data-cf7mls-order', i2);
21                    totalFieldset = totalFieldset + 1;
22                    //disable next button if the fieldset has  wpcf7-acceptance
23                    var acceptances = jQuery(el2).find('input:checkbox.wpcf7-acceptance');
24                    if (acceptances.length) {
25                        cf7mls_toggle_next_btn(acceptances, el2);
26                    }
27                });
28                $.each(findFieldset, function(i2, el2) {
29                    if (i2 == (totalFieldset - 1)) {
30                        $(el2).find('.cf7mls_next').remove();
31                    }
32                });
33                $(el).attr('data-count-fieldset', totalFieldset);
34                //on form submit
35                $(el).submit(function(event) {
36                    var findFieldset = $(el).find('fieldset.fieldset-cf7mls.cf7mls_current_fs');
37                    if (findFieldset.data('cf7mls-order') != (totalFieldset - 1)) {
38                        findFieldset.find('.cf7mls_next').click();
39                        return false;
40                    }                
41                });
42            }
43            //answer fields
44            $(el).find('input.wpcf7-cf7_answer').each(function(njt_a_i, njt_a_e) {
45                var $this = $(njt_a_e);
46                var qf = this_form.find('[name="'+$this.data('qf')+'"]');
47                var sp = $('span.wpcf7-cf7_answer_' + $this.data('qf'));
48                qf.on('change', function(event) {
49                    event.preventDefault();
50                    var _val = $(this).val();
51                    sp.text(_val);
52                    $this.val(_val);
53                });
54            });
55        });
56
57    });
58    jQuery(document).on('click', 'form.wpcf7-form input:checkbox.wpcf7-acceptance', function(event) {
59        //event.preventDefault();
60        var $this = jQuery(this);
61        var parent_fieldset = $this.closest('fieldset.fieldset-cf7mls');
62        if (parent_fieldset.length) {
63            var acceptances = jQuery(parent_fieldset).find('input:checkbox.wpcf7-acceptance');
64            if (acceptances.length) {
65                cf7mls_toggle_next_btn(acceptances, parent_fieldset);
66            }            
67        }
68    });
69
70    $(document).on('click', '.cf7mls_next', function(event) {
71        event.preventDefault();
72        var $this = $(this);
73
74        $this.addClass('sending');
75        current_fs = $this.closest('.fieldset-cf7mls');
76        next_fs = current_fs.next();
77
78        //validation
79        var form = $this.parent().closest('form.wpcf7-form');
80        
81
82        var fd = new FormData();
83        $.each(form.find('input[type="file"]'), function(index, el) {
84            fd.append($(el).attr('name'), $(el)[0].files[0]);
85        });
86        
87        var other_data = form.serializeArray();
88        $.each(other_data,function(key, input){
89            fd.append(input.name, input.value);
90        });
91
92
93        $.ajax({
94            url: cf7mls_object.ajax_url + '?action=cf7mls_validation',
95            type: 'POST',
96            data: fd,
97            processData: false,
98            contentType: false,
99        })
100        .done(function(msg) {
101            $this.removeClass('sending');
102            var json = $.parseJSON(msg);
103
104            /*
105             * Insert _form_data_id if 'json variable' has
106             */
107            if (typeof json._cf7mls_db_form_data_id != 'undefined') {
108                if (!form.find('input[name="_cf7mls_db_form_data_id"]').length) {
109                    form.append('<input type="hidden" name="_cf7mls_db_form_data_id" value="'+json._cf7mls_db_form_data_id+'" />');
110                }
111            }            
112            
113            if (!json.success) {
114                var checkError = 0;
115                //reset error messages
116                current_fs.find('.wpcf7-form-control-wrap').removeClass('cf7mls-invalid');
117                current_fs.find('.wpcf7-form-control-wrap .wpcf7-not-valid-tip').remove();
118                if (has_response) {                    
119                    current_fs.find('.wpcf7-response-output.wpcf7-validation-errors').removeClass('wpcf7-validation-errors');
120                } else {
121                    current_fs.find('.wpcf7-response-output.wpcf7-validation-errors').remove();
122                }
123                
124                $.each(json.invalid_fields, function(index, el) {
125                    if (current_fs.find('input[name="'+index+'"]').length || 
126                        current_fs.find('input[name="'+index+'[]"]').length ||
127                        current_fs.find('select[name="'+index+'"]').length || 
128                        current_fs.find('select[name="'+index+'[]"]').length ||
129                        current_fs.find('textarea[name="'+index+'"]').length || 
130                        current_fs.find('textarea[name="'+index+'[]"]').length
131                    ) {
132                        checkError = checkError + 1;
133
134                        var controlWrap = $('.wpcf7-form-control-wrap.' + index, form);
135                        controlWrap.addClass('cf7mls-invalid');
136                        controlWrap.find('span.wpcf7-not-valid-tip').remove();
137                        controlWrap.append('<span role="alert" class="wpcf7-not-valid-tip">' + el.reason + '</span>');
138
139                        //return false;
140                    }
141                });
142
143                if (checkError == 0) {
144                    json.success = true;
145                    has_response = false;
146                } else {
147                    if (current_fs.find('.wpcf7-response-output').length) {
148                        has_response = true;
149                        current_fs.find('.wpcf7-response-output').addClass('wpcf7-validation-errors').show().text(json.message);
150                    } else {
151                        has_response = false;
152                        current_fs.append('<div class="wpcf7-response-output wpcf7-display-none wpcf7-validation-errors" style="display: block;" role="alert">' + json.message + '</div>');
153                    }
154                    
155                }
156            }
157
158            if (json.success) {
159                
160                /*
161                current_fs.fadeOut('400', function() {
162                    next_fs.fadeIn('400');
163                });
164                
165                });
166                */
167               
168                //reset error messages
169                current_fs.find('.wpcf7-form-control-wrap').removeClass('cf7mls-invalid');
170                current_fs.find('.wpcf7-form-control-wrap .wpcf7-not-valid-tip').remove();
171               
172               /*
173                * Instead of hiding current fs, we hide all
174                */
175               /*
176                current_fs.css({
177                    height: '0px',
178                    overflow: 'hidden',
179                    opacity: '0',
180                    'visibility': 'hidden'
181                }).removeClass('cf7mls_current_fs');
182                */
183
184                form.find('.cf7mls_current_fs').addClass('cf7mls_back_fs');
185
186                form.find('.fieldset-cf7mls').removeClass('cf7mls_current_fs');
187
188                next_fs.addClass('cf7mls_current_fs');
189
190                if (form.find('.cf7mls_progress_bar').length) {
191                    form.find('.cf7mls_progress_bar li').eq(form.find("fieldset.fieldset-cf7mls").index(next_fs)).addClass("active");
192                }
193
194                dhScrollTo(form);
195
196                return false;
197                
198            } else {
199
200            }
201        })
202        .fail(function() {
203            $this.removeClass('sending');
204            console.log("Validation error");
205        })
206        .always(function() {
207            $this.removeClass('sending');
208            console.log("Validation complete");
209        });
210        return false;
211    });
212
213    $(".cf7mls_back").click(function(){
214        var $this = $(this);
215        var form = $this.parent().closest('form.wpcf7-form');
216
217        $('.wpcf7-response-output.wpcf7-display-none').removeClass('wpcf7-validation-errors').html('');
218        $('.wpcf7-response-output.wpcf7-display-none.wpcf7-mail-sent-ok').hide();
219        
220        current_fs = $this.closest('.fieldset-cf7mls');
221        previous_fs = current_fs.prev();
222        
223        //reset error messages
224        current_fs.find('.wpcf7-form-control-wrap').removeClass('cf7mls-invalid');
225        current_fs.find('.wpcf7-form-control-wrap .wpcf7-not-valid-tip').remove();
226        
227        /*
228         * Instead of hide current fs, we hide all
229         */
230        /*current_fs.css({
231            height: '0px',
232            overflow: 'hidden',
233            opacity: '0',
234            'visibility': 'hidden'
235        }).removeClass('cf7mls_current_fs');*/
236        form.find('.fieldset-cf7mls').removeClass('cf7mls_current_fs');
237
238        previous_fs.addClass('cf7mls_current_fs').removeClass('cf7mls_back_fs');
239
240        if (form.find('.cf7mls_progress_bar').length) {
241            form.find('.cf7mls_progress_bar li').eq(form.find("fieldset.fieldset-cf7mls").index(current_fs)).removeClass("active");
242        }
243
244        dhScrollTo(form);
245
246        return false;
247    });
248
249    /*
250     * Preview Form Clicked
251     */
252    $(document).on('click', '.wpcf7-cf7mls_preview_step', function(event) {
253        event.preventDefault();
254        var $this = $(this);
255        var form = $this.closest('form.wpcf7-form');        
256
257        if (preview_clicked === false) {
258            form.find('.cf7mls_back').hide();
259            form.find('.cf7mls_next').hide();
260
261            form.find('.fieldset-cf7mls').css({
262                height: 'auto',
263                overflow: 'visible',
264                opacity: '1',
265                'visibility': 'visible'
266            });
267            form.find('input').attr('disabled', 'disabled');
268            form.find('button').attr('disabled', 'disabled');
269            form.find('select').attr('disabled', 'disabled');
270            form.find('textarea').attr('disabled', 'disabled');
271            form.find('.wpcf7-cf7mls_preview_step').removeAttr('disabled');
272
273            form.addClass('cf7mls_reviewing');
274            $('body').append('<div class="cf7mls_reviewing_overlay"></div>');
275        } else {
276            form.find('.fieldset-cf7mls').css({
277                height: '0px',
278                overflow: 'hidden',
279                opacity: '0',
280                'visibility': 'hidden'
281            });
282
283            form.find('.cf7mls_back').show();
284            form.find('.cf7mls_next').show();
285
286            form.find('.cf7mls_current_fs').css({
287                height: 'auto',
288                overflow: 'visible',
289                opacity: '1',
290                'visibility': 'visible'
291            });
292
293            form.find('input').removeAttr('disabled');
294            form.find('button').removeAttr('disabled');
295            form.find('select').removeAttr('disabled');
296            form.find('textarea').removeAttr('disabled');
297
298            form.removeClass('cf7mls_reviewing');
299            $('body').find('.cf7mls_reviewing_overlay').remove();
300        }        
301
302        preview_clicked = !preview_clicked;
303
304    });
305
306    $(window).on('load',function(){
307        $('.cf7mls_progress_bar li').css({
308            'width' : "calc(100% / " + $('.cf7mls_progress_bar li').length + ")"
309        });
310    })
311
312    function cf7mls_is_not_last_fieldset(fieldset, total_fieldset) {
313        var order = fieldset.data('cf7mls-order');
314        return order != total_fieldset;
315    }
316    function dhScrollTo(el) {
317        if (cf7mls_object.scroll_step == "true") {
318            $('html, body').animate({
319                scrollTop: el.offset().top
320            }, 'slow');
321        } else if (cf7mls_object.scroll_step == "scroll_to_top") {
322            $('html, body').animate({
323                scrollTop: $('body').offset().top
324            }, 'slow');
325        }
326    }
327    function cf7mls_toggle_next_btn(acceptances, fieldset) {
328        if (acceptances.length > 0) {
329            var ii = 0;
330            jQuery.each(acceptances, function(i, v) {
331                if (jQuery(v).is(':checked')) {
332                    //console.log('checked');
333                } else {
334                    ii++;
335                }
336            });
337            if (ii > 0) {
338                //console.log(ii);
339                jQuery(fieldset).find('.cf7mls_next').attr('disabled', 'disabled');
340            } else {
341                jQuery(fieldset).find('.cf7mls_next').removeAttr('disabled');
342            }
343        }
344    }
345})(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.