PageSourceSearch

https://gurus.es/wp-content/plugins/wp-freeio/assets/js/main.js?ver=20131022

js gurus.es collected 2026-10-08 23:10:43 UTC 156,296 bytes, 3,490 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    if (!$.wpfiExtensions)
5        $.wpfiExtensions = {};
6    
7    function WJBPMainCore() {
8        var self = this;
9        self.init();
10    };
11
12    WJBPMainCore.prototype = {
13        /**
14         *  Initialize
15         */
16        init: function() {
17            var self = this;
18
19            self.fileUpload();
20
21            self.userLoginRegister();
22            self.userLoginRegisterNew();
23
24            self.userChangePass();
25            
26            self.removeItem();
27
28            self.fillJob();
29
30            self.applyEmail();
31            
32            self.recaptchaCallback();
33
34            self.applyInternal();
35
36            self.applicantsInit();
37
38            self.applicationMeeting();
39
40            // favorite
41            self.jobFavorite();
42
43            self.serviceFavorite();
44
45            self.projectFavorite();
46            
47            self.employerFavorite();
48
49            self.freelancerFavorite();
50
51            //
52            self.servicePrice();
53
54            self.projectProposal();
55            
56            self.reviewInit();
57
58            self.jobAlert();
59
60            self.freelancerAlert();
61
62            self.jobSocialApply();
63
64            self.select2Init();
65
66            self.jobSubmission();
67
68            self.filterListing();
69            
70            self.employerAddEmployee();
71            
72            self.inviteFreelancer();
73
74            self.statementPayout();
75
76            self.dispute();
77
78            self.mixesFn();
79
80            self.loadExtension();
81        },
82        loadExtension: function() {
83            var self = this;
84            
85            // if ($.wpfiExtensions.ajax_upload) {
86            //     $.wpfiExtensions.ajax_upload.call(self);
87            // }
88        },
89        fileUpload: function(){
90            
91            var imagesPreview = function(input, placeToInsertImagePreview) {
92                if (input.files) {
93                    var filesAmount = input.files.length;
94                    var i;
95                    for (i = 0; i < filesAmount; i++) {
96                        var reader = new FileReader();
97                        reader.onload = function(event) {
98                            $($.parseHTML('<img>')).attr('src', event.target.result).appendTo(placeToInsertImagePreview);
99                        }
100                        reader.readAsDataURL(input.files[i]);
101                    }
102                }
103            };
104            var filesPreview = function(input, placeToInsertImagePreview) {
105                if (input.files) {
106                    var filesAmount = input.files.length;
107                    var i;
108                    for (i = 0; i < filesAmount; i++) {
109                        var html = $($.parseHTML('<div><code>'+ input.files[i].name +'</code></div>')).appendTo(placeToInsertImagePreview);
110                    }
111                }
112            };
113            $('.cmb-type-wp-freeio-file').each(function(e){
114                var $e_this = $(this);
115                $(this).find('input[type="file"]:not(.wp-freeio-file-upload)').on('change', function() {
116                    $e_this.find('.wp-freeio-uploaded-files').html('');
117
118                    // Validate type
119                    var allowed_types = $(this).data('file_types');
120
121                    if ( allowed_types ) {
122                        var acceptFileTypes = new RegExp( '(\.|\/)(' + allowed_types + ')$', 'i' );
123                        if ( this.files[0].name.length && ! acceptFileTypes.test( this.files[0].name ) ) {
124                            alert(wp_freeio_opts.not_allow);
125                            $(this).val(null);
126                            return false;
127                        }
128                    }
129
130                    var file = this.files[0];
131                    var fileType = file["type"];
132                    var validImageTypes = ["image/gif", "image/jpeg", "image/png"];
133                    if ($.inArray(fileType, validImageTypes) < 0) {
134                        filesPreview(this, $e_this.find('.wp-freeio-uploaded-files'));
135                        $e_this.find('.wp-freeio-uploaded-files').css("display","block");
136                    } else {
137                        imagesPreview(this, $e_this.find('.wp-freeio-uploaded-files'));
138                        $e_this.find('.wp-freeio-uploaded-files').css("display","block");
139                    }
140                });
141            });
142
143            $(document).on('change', '.upload-file-btn-wrapper input[type="file"]', function(){
144                var $e_this = $(this).closest('.upload-file-btn-wrapper');
145                var $text = $e_this.find('.upload-file-btn').data('text');
146                // Validate type
147                var allowed_types = $(this).data('file_types');
148
149                if( $(this).val() == '' ) {
150                    $e_this.find('.upload-file-btn span.text').html($text);
151                    $e_this.find('.label-can-drag').removeClass('has-file');
152                    return false;
153                }
154                if ( allowed_types ) {
155                    var acceptFileTypes = new RegExp( '(\.|\/)(' + allowed_types + ')$', 'i' );
156                    if ( this.files[0].name.length && ! acceptFileTypes.test( this.files[0].name ) ) {
157                        alert(wp_freeio_opts.not_allow);
158                        $(this).val(null);
159                        $e_this.find('.upload-file-btn span.text').html($text);
160                        $e_this.find('.label-can-drag').removeClass('has-file');
161                        return false;
162                    }
163                }
164
165                if (this.files) {
166                    var filesAmount = this.files.length;
167                    var i;
168                     $e_this.find('.upload-file-btn span.text').html('');
169                    for (i = 0; i < filesAmount; i++) {
170                        var $file_html = $($.parseHTML('<span class="text-inner"><span>'+ this.files[i].name +'</span></span>'));
171                        $e_this.find('.upload-file-btn span.text').append($file_html);
172                    }
173                    $e_this.find('.upload-file-btn span.text').append( $($.parseHTML('<span class="close">&times;</span>')) );
174                    $e_this.find('.label-can-drag').addClass('has-file');
175                }
176            });
177
178            $(document).on('click', '.upload-file-btn-wrapper .upload-file-btn span.close', function(e){
179                e.preventDefault();
180                var $e_this = $(this).closest('.upload-file-btn-wrapper');
181                var $file_input = $e_this.find('input[type="file"]');
182                var $text = $e_this.find('.upload-file-btn').data('text');
183                
184                $file_input.val(null);
185                $e_this.find('.upload-file-btn span.text').html($text);
186                $e_this.find('.label-can-drag').removeClass('has-file');
187            });
188
189            var isAdvancedUpload = function() {
190                var div = document.createElement('div');
191                return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
192            }();
193
194            if (isAdvancedUpload) {
195
196                var droppedFiles = false;
197                $('.label-can-drag').each(function(){
198                    var label_self = $(this);
199                    label_self.on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
200                        e.preventDefault();
201                        e.stopPropagation();
202                    }).on('dragover dragenter', function() {
203                        label_self.addClass('is-dragover');
204                    }).on('dragleave dragend drop', function() {
205                        label_self.removeClass('is-dragover');
206                    }).on('drop', function(e) {
207                        droppedFiles = e.originalEvent.dataTransfer.files;
208                        label_self.parent().find('input[type="file"]').prop('files', droppedFiles).trigger('change');
209                    });
210                });
211            }
212            $(document).on('click', '.label-can-drag:not(.has-file)', function(){
213                $(this).parent().find('input[type="file"]').trigger('click');
214            });
215        },
216        userLoginRegisterNew: function() {
217            var self = this;
218
219            $(document).on('submit', 'form._employer_register_fields, form._freelancer_register_fields', function(){
220                var $this = $(this);
221
222                if ( self.registerAjax ) {
223                    self.registerAjax.abort();
224                }
225
226                if ( $this.hasClass('loading') ) {
227                    return false;
228                }
229
230                var form_id = $(this).attr('id');
231                
232                
233                $this.find('.alert').remove();
234
235                $this.addClass('loading');
236                var form_data = new FormData( $('#' + form_id)[0] );
237                
238                self.registerAjax = $.ajax({
239                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_registernew&action=wp_freeio_ajax_registernew' ),
240                    type:'POST',
241                    dataType: 'json',
242                    data: form_data,
243                    processData: false,
244                    contentType: false,
245                }).done(function(data) {
246                    $this.removeClass('loading');
247                    if ( data.status ) {
248                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
249                        if ( data.redirect ) {
250                            setTimeout(function(){
251                                if ( data.redirect_url ) {
252                                    window.location.href = data.redirect_url;
253                                } else {
254                                    if ( data.role == 'wp_freeio_employer' ) {
255                                        window.location.href = wp_freeio_opts.after_register_page_url;
256                                    } else {
257                                        window.location.href = wp_freeio_opts.after_register_page_freelancer_url;
258                                    }
259                                }
260                            }, 500);
261                        }
262                    } else {
263                        $this.prepend( '<div class="alert alert-warning">
263'+data.msg+'</div>' );
264                        if ( wp_freeio_opts.recaptcha_enable ) {
265                            var recaptchas = document.getElementsByClassName("ga-recaptcha");
266                            for(var i=0; i<recaptchas.length; i++) {
267                                grecaptcha.reset(i);
268                            }
269                        }
270                    }
271
272                    self.registerAjax = false;
273                });
274                
275                return false;
276            });
277        },
278        userLoginRegister: function() {
279            var self = this;
280            
281            // sign in proccess
282            $('body').on('submit', 'form.login-form', function(){
283                var $this = $(this);
284                $('.alert', this).remove();
285                $this.addClass('loading');
286                $.ajax({
287                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_login' ),
288                    type:'POST',
289                    dataType: 'json',
290                    data:  $(this).serialize()+"&action=wp_freeio_ajax_login"
291                }).done(function(data) {
292                    $this.removeClass('loading');
293                    if ( data.status ) {
294                        $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' );
295                        setTimeout(function(){
296
297                            if ( data.redirect_url ) {
298                                window.location.href = data.redirect_url;
299                            } else {
300                                if ( data.role == 'wp_freeio_employer' ) {
301                                    window.location.href = wp_freeio_opts.after_login_page_url;
302                                } else {
303                                    window.location.href = wp_freeio_opts.after_login_page_freelancer_url;
304                                }
305                            }
306                            
307                        }, 500);
308                    } else {
309                        $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' );
310
311                        if ( wp_freeio_opts.recaptcha_enable ) {
312                            var recaptchas = document.getElementsByClassName("ga-recaptcha");
313                            for(var i=0; i<recaptchas.length; i++) {
314                                grecaptcha.reset(i);
315                            }
316                        }
317                    }
318                });
319                return false; 
320            } );
321            $('body').on('click', '.back-link', function(e){
322                e.preventDefault();
323                var $con = $(this).closest('.login-form-wrapper');
324                $con.find('.form-container').hide();
325                $($(this).attr('href')).show(); 
326                return false;
327            } );
328
329             // lost password in proccess
330            $('body').on('submit', 'form.forgotpassword-form', function(){
331                var $this= $(this);
332                $('.alert', this).remove();
333                $this.addClass('loading');
334                $.ajax({
335                  url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_forgotpass' ),
336                  type:'POST',
337                  dataType: 'json',
338                  data:  $(this).serialize()+"&action=wp_freeio_ajax_forgotpass"
339                }).done(function(data) {
340                     $this.removeClass('loading');
341                    if ( data.status ) {
342                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
343                        setTimeout(function(){
344                            window.location.reload(true);
345                        }, 500);
346                    } else {
347                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
348                    }
349                });
350                return false; 
351            } );
352            $('body').on('click', '#forgot-password-form-wrapper form .btn-cancel', function(e){
353                e.preventDefault();
354                $('#forgot-password-form-wrapper').hide();
355                $('#login-form-wrapper').show();
356            } );
357
358            // register
359            $('body').on('submit', 'form.register-form', function(){
360                var $this = $(this);
361                $('.alert', this).remove();
362                $this.addClass('loading');
363                $.ajax({
364                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_register' ),
365                    type:'POST',
366                    dataType: 'json',
367                    data:  $(this).serialize()+"&action=wp_freeio_ajax_register"
368                }).done(function(data) {
369                    $this.removeClass('loading');
370                    if ( data.status ) {
371                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
372                        if ( data.redirect ) {
373                            setTimeout(function(){
374                                if ( data.role == 'wp_freeio_employer' ) {
375                                    window.location.href = wp_freeio_opts.after_register_page_url;
376                                } else {
377                                    window.location.href = wp_freeio_opts.after_register_page_freelancer_url;
378                                }
379                            }, 500);
380                        }
381                    } else {
382                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
383                        if ( wp_freeio_opts.recaptcha_enable ) {
384                            var recaptchas = document.getElementsByClassName("ga-recaptcha");
385                            for(var i=0; i<recaptchas.length; i++) {
386                                grecaptcha.reset(i);
387                            }
388                        }
389                    }
390                });
391                return false;
392            } );
393
394            if ( $('form.register-form').length > 0 ) {
395                $('.role-tabs input[type=radio]').on('change', function() {
396                    var val = $(this).val();
397                    var container = $(this).closest('.register-form');
398                    if ( val == 'wp_freeio_freelancer' ) {
399                        container.find('.wp_freeio_freelancer_show').show();
400                        container.find('.wp_freeio_employer_show').hide();
401                    } else {
402                        container.find('.wp_freeio_freelancer_show').hide();
403                        container.find('.wp_freeio_employer_show').show();
404                    }
405                });
406                var val = $('.role-tabs input[type=radio]:checked').val();
407                var container = $('form.register-form').closest('.register-form');
408                if ( val == 'wp_freeio_freelancer' ) {
409                    container.find('.wp_freeio_freelancer_show').show();
410                    container.find('.wp_freeio_employer_show').hide();
411                } else {
412                    container.find('.wp_freeio_freelancer_show').hide();
413                    container.find('.wp_freeio_employer_show').show();
414                }
415            }
416            
417            // wp-freeio-resend-approve-account-btn
418            $(document).on('click', '.wp-freeio-resend-approve-account-btn', function(e) {
419                e.preventDefault();
420                var $this = $(this),
421                    $container = $(this).parent();
422                $this.addClass('loading');
423                $.ajax({
424                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_resend_approve_account' ),
425                    type:'POST',
426                    dataType: 'json',
427                    data: {
428                        action: 'wp_freeio_ajax_resend_approve_account',
429                        login: $this.data('login'),
430                    }
431                }).done(function(data) {
432                    $this.removeClass('loading');
433                    if ( data.status ) {
434                        $container.html( data.msg );
435                    } else {
436                        $container.html( data.msg );
437                    }
438                });
439            });
440            
441            $('.switch-user-role').on('click', function(e){
442                e.preventDefault();
443                var $this = $(this);
444                if ( self.switchUserRoleAjax ) {
445                    self.switchUserRoleAjax.abort();
446                }
447                $this.addClass('loading');
448                
449                self.switchUserRoleAjax = $.ajax({
450                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_switch_user_role' ),
451                    type:'POST',
452                    dataType: 'json',
453                }).done(function(data) {
454                    $this.removeClass('loading');
455                    if ( data.status ) {
456                        // self.showMessage(data.msg, data.status);
457                        setTimeout(function(){
458                            location.reload();
459                        }, 500);
460                    } else {
461                        self.showMessage(data.msg, data.status);
462                    }
463                });
464                self.switchUserRoleAjax = false;
465            });
466        },
467        userChangePass: function() {
468            var self = this;
469            $('body').on('submit', 'form.change-password-form', function(){
470                var $this = $(this);
471                $('.alert', this).remove();
472                $this.addClass('loading');
473                $.ajax({
474                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_change_password' ),
475                    type:'POST',
476                    dataType: 'json',
477                    data:  $(this).serialize()+"&action=wp_freeio_ajax_change_password"
478                }).done(function(data) {
479                    $this.removeClass('loading');
480                    if ( data.status ) {
481                        $this.prepend( '<div class="alert alert-info">' + data.msg + '</div>' );
482                        setTimeout(function(){
483                            window.location.href = wp_freeio_opts.login_register_url;
484                        }, 500);
485                    } else {
486                        $this.prepend( '<div class="alert alert-warning">' + data.msg + '</div>' );
487                    }
488                });
489                return false; 
490            } );
491        },
492        removeItem: function() {
493            var self = this;
494            $('.job-button-delete').on('click', function() {
495                var $this = $(this);
496                var r = confirm( wp_freeio_opts.rm_item_txt );
497                if ( r == true ) {
498                    $this.addClass('loading');
499                    var job_id = $(this).data('job_id');
500                    var nonce = $(this).data('nonce');
501                    $.ajax({
502                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_job' ),
503                        type:'POST',
504                        dataType: 'json',
505                        data: {
506                            'job_id': job_id,
507                            'nonce': nonce,
508                            'action': 'wp_freeio_ajax_remove_job',
509                        }
510                    }).done(function(data) {
511                        $this.removeClass('loading');
512                        if ( data.status ) {
513                            $this.closest('.my-item-wrapper').remove();
514                        }
515                        $(document).trigger( "after_remove_my_job", [$this, data] );
516
517                        self.showMessage(data.msg, data.status);
518                    });
519                }
520            });
521            // remove project
522            $('.project-button-delete').on('click', function() {
523                var $this = $(this);
524                var r = confirm( wp_freeio_opts.rm_item_txt );
525                if ( r == true ) {
526                    $this.addClass('loading');
527                    var project_id = $(this).data('project_id');
528                    var nonce = $(this).data('nonce');
529                    $.ajax({
530                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_project' ),
531                        type:'POST',
532                        dataType: 'json',
533                        data: {
534                            'project_id': project_id,
535                            'nonce': nonce,
536                            'action': 'wp_freeio_ajax_remove_project',
537                        }
538                    }).done(function(data) {
539                        $this.removeClass('loading');
540                        if ( data.status ) {
541                            $this.closest('.my-item-wrapper').remove();
542                        }
543                        $(document).trigger( "after_remove_my_project", [$this, data] );
544
545                        self.showMessage(data.msg, data.status);
546                    });
547                }
548            });
549            // remove service
550            $('.service-button-delete').on('click', function() {
551                var $this = $(this);
552                var r = confirm( wp_freeio_opts.rm_item_txt );
553                if ( r == true ) {
554                    $this.addClass('loading');
555                    var service_id = $(this).data('service_id');
556                    var nonce = $(this).data('nonce');
557                    $.ajax({
558                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_service' ),
559                        type:'POST',
560                        dataType: 'json',
561                        data: {
562                            'service_id': service_id,
563                            'nonce': nonce,
564                            'action': 'wp_freeio_ajax_remove_service',
565                        }
566                    }).done(function(data) {
567                        $this.removeClass('loading');
568                        if ( data.status ) {
569                            $this.closest('.my-item-wrapper').remove();
570                        }
571                        $(document).trigger( "after_remove_my_service", [$this, data] );
572
573                        self.showMessage(data.msg, data.status);
574                    });
575                }
576            });
577
578            // remove service
579            $('.service-addon-button-delete').on('click', function() {
580                var $this = $(this);
581                var r = confirm( wp_freeio_opts.rm_item_txt );
582                if ( r == true ) {
583                    $this.addClass('loading');
584                    var service_addon_id = $(this).data('service_addon_id');
585                    var nonce = $(this).data('nonce');
586                    $.ajax({
587                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_service_addon' ),
588                        type:'POST',
589                        dataType: 'json',
590                        data: {
591                            'service_addon_id': service_addon_id,
592                            'nonce': nonce,
593                        }
594                    }).done(function(data) {
595                        $this.removeClass('loading');
596                        if ( data.status ) {
597                            $this.closest('.my-item-wrapper').remove();
598                        }
599                        $(document).trigger( "after_remove_my_service_addon", [$this, data] );
600
601                        self.showMessage(data.msg, data.status);
602                    });
603                }
604            });
605
606            // remove proposal
607            $('.proposal-button-delete').on('click', function() {
608                var $this = $(this);
609                var r = confirm( wp_freeio_opts.rm_item_txt );
610                if ( r == true ) {
611                    $this.addClass('loading');
612                    var proposal_id = $(this).data('proposal_id');
613                    var nonce = $(this).data('nonce');
614                    $.ajax({
615                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_proposal' ),
616                        type:'POST',
617                        dataType: 'json',
618                        data: {
619                            'proposal_id': proposal_id,
620                            'nonce': nonce,
621                            'action': 'wp_freeio_ajax_remove_proposal',
622                        }
623                    }).done(function(data) {
624                        $this.removeClass('loading');
625                        if ( data.status ) {
626                            $this.closest('.my-item-wrapper').remove();
627                        }
628                        $(document).trigger( "after_remove_my_proposal", [$this, data] );
629
630                        self.showMessage(data.msg, data.status);
631                    });
632                }
633            });
634        },
635        fillJob: function() {
636            var self = this;
637            $(document).on('click', '.btn-action-icon.mark_filled', function() {
638                var $this = $(this);
639                $this.addClass('loading');
640                var job_id = $this.data('job_id');
641                var nonce = $this.data('nonce');
642                $.ajax({
643                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_mark_filled_job' ),
644                    type:'POST',
645                    dataType: 'json',
646                    data: {
647                        'job_id': job_id,
648                        'nonce': nonce,
649                        'action': 'wp_freeio_ajax_mark_filled_job',
650                    }
651                }).done(function(data) {
652                    $this.removeClass('loading');
653                    if ( data.status ) {
654                        $this.attr('title', data.title);
655                        $this.data('nonce', data.nonce);
656                        $this.removeClass('mark_filled').addClass('mark_not_filled');
657                        $this.find('i').attr('class', data.icon_class);
658
659                        $this.closest('tr').find('.job-title-wrapper .application-status-label').remove();
660                        if ( data.label ) {
661                            $this.closest('tr').find('.job-title-wrapper').append(data.label);
662                        }
663                    }
664                    self.showMessage(data.msg, data.status);
665                });
666            });
667            $(document).on('click', '.btn-action-icon.mark_not_filled', function() {
668                var $this = $(this);
669                $this.addClass('loading');
670                var job_id = $this.data('job_id');
671                var nonce = $this.data('nonce');
672                $.ajax({
673                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_mark_not_filled_job' ),
674                    type:'POST',
675                    dataType: 'json',
676                    data: {
677                        'job_id': job_id,
678                        'nonce': nonce,
679                        'action': 'wp_freeio_ajax_mark_not_filled_job',
680                    }
681                }).done(function(data) {
682                    $this.removeClass('loading');
683                    if ( data.status ) {
684                        $this.attr('title', data.title);
685                        $this.data('nonce', data.nonce);
686                        $this.removeClass('mark_not_filled').addClass('mark_filled');
687                        $this.find('i').attr('class', data.icon_class);
688
689                        $this.closest('tr').find('.job-title-wrapper .application-status-label').remove();
690                        if ( data.label ) {
691                            $this.closest('tr').find('.job-title-wrapper').append(data.label);
692                        }
693                    }
694                    self.showMessage(data.msg, data.status);
695                });
696            });
697        },
698        recaptchaCallback: function() {
699            if (!window.grecaptcha) {
700            } else {
701                setTimeout(function(){
702                    var recaptchas = document.getElementsByClassName("ga-recaptcha");
703                    for(var i=0; i<recaptchas.length; i++) {
704                        var recaptcha = recaptchas[i];
705                        var sitekey = recaptcha.dataset.sitekey;
706
707                        grecaptcha.render(recaptcha, {
708                            'sitekey' : sitekey
709                        });
710                    }
711                }, 500);
712            }
713        },
714        applyEmail: function() {
715            var self = this;
716
717            $('.btn-apply-job-email:not(.filled), .btn-apply-job-call:not(.filled)').magnificPopup({
718                mainClass: 'apus-mfp-zoom-in apus-mfp-zoom-call-in',
719                type:'inline',
720                midClick: true
721            });
722
723            $('.btn-apply-job-email:not(.filled)').magnificPopup({
724                mainClass: 'apus-mfp-zoom-in',
725                type:'inline',
726                midClick: true
727            });
728
729            $(document).on( 'click', '.btn-apply-job-email.filled', function(e){
730                e.preventDefault();
731                self.showMessage(wp_freeio_opts.job_filled, false);
732            });
733
734            $(document).on('submit', 'form.job-apply-email-form', function(){
735                var $this = $(this);
736
737                if ( self.applyEmailAjax ) {
738                    self.applyEmailAjax.abort();
739                }
740
741                if ( $this.hasClass('loading') ) {
742                    return false;
743                }
744
745                var form_id = $(this).attr('id');
746                var error = false;
747
748                if ( wp_freeio_opts.cv_required == 'on' ) {
749                    var cv_file = $this.find('input[name="cv_file"]');
750                    if (cv_file.length > 0 && cv_file.val() != '') {
751                        cv_file = cv_file.prop('files')[0];
752                        var file_size = cv_file.size;
753                        var file_type = cv_file.type;
754
755                        var allowed_types = wp_freeio_opts.cv_file_types;
756                        var filesize_allow = wp_freeio_opts.cv_file_size_allow;
757                        filesize_allow = parseInt(filesize_allow);
758
759                        if (file_size > filesize_allow) {
760                            alert(wp_freeio_opts.cv_file_size_error);
761                            error = true;
762                        }
763                        if (allowed_types.indexOf(file_type) < 0) {
764                            alert(wp_freeio_opts.cv_file_types_error);
765                            error = true;
766                        }
767                    }
768                }
769
770                if ( error == false ) {
771                    $this.find('.alert').remove();
772
773                    $this.addClass('loading');
774                    var form_data = new FormData( $('#' + form_id)[0] );
775
776                    var action = $(this).find('input[name=action]').val();
777                    self.applyEmailAjax = $.ajax({
778                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
779                        type:'POST',
780                        dataType: 'json',
781                        data: form_data,
782                        processData: false,
783                        contentType: false,
784                    }).done(function(data) {
785                        $this.removeClass('loading');
786                        
787                        if ( data.status ) {
788                            $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
789                        } else {
790                            $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
791                        }
792
793                        self.applyEmailAjax = false;
794                    });
795                } else {
796                    alert(wp_freeio_opts.choose_a_cv);
797                }
798                return false;
799            });
800        },
801        applyInternal: function() {
802            var self = this;
803            $(document).on('click', '.btn-apply-job-internal-required:not(.filled)', function() {
804                var msg = $(this).parent().find('.job-apply-internal-required-wrapper .msg-inner').text();
805                self.showMessage(msg, false);
806            });
807            $('.btn-apply-job-internal:not(.filled), .btn-apply-job-internal-without-login:not(.filled)').magnificPopup({
808                mainClass: 'apus-mfp-zoom-in',
809                type:'inline',
810                midClick: true
811            });
812
813            $(document).on( 'click', '.btn-apply-job-internal.filled, .btn-apply-job-internal-without-login.filled, .btn-apply-job-internal-required.filled', function(e){
814                e.preventDefault();
815                self.showMessage(wp_freeio_opts.job_filled, false);
816            });
817
818            $(document).on('submit', 'form.job-apply-internal-form', function(){
819                var $this = $(this);
820
821                if ( self.applyInternalAjax ) {
822                    self.applyInternalAjax.abort();
823                }
824
825                if ( $this.hasClass('loading') ) {
826                    return false;
827                }
828                var form_wrapper_id = $(this).closest('.job-apply-internal-form-wrapper').attr('id');
829                var form_id = $(this).attr('id');
830
831                
832                var error = true;
833                if ( $this.find('input[name="apply_cv_id"]:checked').val() ) {
834                    var error = false;
835                }
836
837                var cv_file = $this.find('input[name="cv_file"]');
838                if (cv_file.length > 0 && cv_file.val() != '') {
839                    var file_error = false;
840                    cv_file = cv_file.prop('files')[0];
841                    var file_size = cv_file.size;
842                    var file_type = cv_file.type;
843
844                    var allowed_types = wp_freeio_opts.cv_file_types;
845                    var filesize_allow = wp_freeio_opts.cv_file_size_allow;
846                    filesize_allow = parseInt(filesize_allow);
847
848                    if (file_size > filesize_allow) {
849                        alert(wp_freeio_opts.cv_file_size_error);
850                        file_error = true;
851                    }
852                    if (allowed_types.indexOf(file_type) < 0) {
853                        alert(wp_freeio_opts.cv_file_types_error);
854                        file_error = true;
855                    }
856
857                    if ( file_error == true ) {
858                        return false;
859                    }
860                    error = false;
861                }
862                
863                if ( wp_freeio_opts.cv_required == 'on' ) {
864
865                } else {
866                    var error = false;
867                }
868
869                if ( error == false ) {
870                    $this.find('.alert').remove();
871
872                    $this.addClass('loading');
873                    var form_data = new FormData( $('#' + form_id)[0] );
874
875                    var action = $(this).find('input[name=action]').val();
876                    self.applyInternalAjax = $.ajax({
877                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
878                        type:'POST',
879                        dataType: 'json',
880                        data: form_data,
881                        processData: false,
882                        contentType: false,
883                    }).done(function(data) {
884                        $this.removeClass('loading');
885                        
886                        if ( data.status ) {
887                            $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
888                            if ( $('a[href="#'+form_wrapper_id+'"]').length ) {
889                                $('a[href="#'+form_wrapper_id+'"]').html(data.text).removeClass('btn-apply-job-internal').addClass('btn-applied-job-internal');
890                                setTimeout(function(){
891                                    $.magnificPopup.close();
892                                }, 2000);
893                            }
894                        } else {
895                            $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
896                        }
897
898                        self.applyInternalAjax = false;
899                    });
900                } else {
901                    alert(wp_freeio_opts.choose_a_cv);
902                }
903                return false;
904            });
905
906            $(document).on('submit', 'form#_freelancer_register_fields_apply', function(){
907                var $this = $(this);
908
909                if ( self.registerAjax ) {
910                    self.registerAjax.abort();
911                }
912
913                if ( $this.hasClass('loading') ) {
914                    return false;
915                }
916
917                var form_id = $(this).attr('id');
918                
919                
920                $this.find('.alert').remove();
921
922                $this.addClass('loading');
923                var form_data = new FormData( $('#' + form_id)[0] );
924                
925                self.registerAjax = $.ajax({
926                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_register_apply&action=wp_freeio_ajax_register_apply' ),
927                    type:'POST',
928                    dataType: 'json',
929                    data: form_data,
930                    processData: false,
931                    contentType: false,
932                }).done(function(data) {
933                    $this.removeClass('loading');
934                    if ( data.status ) {
935                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
936                        setTimeout(function(){
937                            location.reload();
938                        }, 500);
939                    } else {
940                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
941                        if ( wp_freeio_opts.recaptcha_enable ) {
942                            var recaptchas = document.getElementsByClassName("ga-recaptcha");
943                            for(var i=0; i<recaptchas.length; i++) {
944                                grecaptcha.reset(i);
945                            }
946                        }
947                    }
948
949                    self.registerAjax = false;
950                });
951                
952                return false;
953            });
954        },
955        applicantsInit: function() {
956            var self = this;
957            $(document).on('click', '.btn-remove-job-applied', function(e) {
958                e.preventDefault();
959                var r = confirm( wp_freeio_opts.rm_item_txt );
960                if ( r == true ) {
961                    var $this = $(this);
962                    $this.addClass('loading');
963                    var applicant_id = $(this).data('applicant_id');
964                    var nonce = $(this).data('nonce');
965                    $.ajax({
966                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_applied' ),
967                        type:'POST',
968                        dataType: 'json',
969                        data: {
970                            'applicant_id': applicant_id,
971                            'nonce': nonce,
972                            'action': 'wp_freeio_ajax_remove_applied',
973                        }
974                    }).done(function(data) {
975                        $this.removeClass('loading');
976                        if ( data.status ) {
977                            $this.closest('.job-applied-wrapper').remove();
978                            $this.closest('.job-applicant-wrapper').remove();
979                        }
980                        self.showMessage(data.msg, data.status);
981                    });
982                }
983            });
984
985            // reject applicant
986            $(document).on('click', '.btn-reject-job-applied', function(e) {
987                e.preventDefault();
988                var $this = $(this);
989                $this.addClass('loading');
990                var applicant_id = $(this).data('applicant_id');
991                var nonce = $(this).data('nonce');
992                $.ajax({
993                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_reject_applied' ),
994                    type:'POST',
995                    dataType: 'json',
996                    data: {
997                        'applicant_id': applicant_id,
998                        'nonce': nonce,
999                        'action': 'wp_freeio_ajax_reject_applied',
1000                    }
1001                }).done(function(data) {
1002                    $this.removeClass('loading');
1003                    if ( data.status ) {
1004                        var total_rej = parseInt($this.closest('.job-applicants').find('.rejected-applicants span').text()) + 1;
1005                        $this.closest('.job-applicants').find('.rejected-applicants span').text(total_rej);
1006
1007                        if ( data.output ) {
1008                            $this.closest('.job-applicant-wrapper').replaceWith(data.output);
1009
1010                            $('.btn-create-meeting-job-applied').magnificPopup({
1011                                mainClass: 'apus-mfp-zoom-in',
1012                                type:'inline',
1013                                midClick: true,
1014                                closeBtnInside:false,
1015                            });
1016                        }
1017                    }
1018                    self.showMessage(data.msg, data.status);
1019                });
1020            });
1021
1022            // undo reject applicant
1023            $(document).on('click', '.btn-undo-reject-job-applied', function(e) {
1024                e.preventDefault();
1025                var $this = $(this);
1026                $this.addClass('loading');
1027                var applicant_id = $(this).data('applicant_id');
1028                var nonce = $(this).data('nonce');
1029                $.ajax({
1030                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_undo_reject_applied' ),
1031                    type:'POST',
1032                    dataType: 'json',
1033                    data: {
1034                        'applicant_id': applicant_id,
1035                        'nonce': nonce,
1036                        'action': 'wp_freeio_ajax_undo_reject_applied',
1037                    }
1038                }).done(function(data) {
1039                    $this.removeClass('loading');
1040                    if ( data.status ) {
1041                        var total_rej = parseInt($this.closest('.job-applicants').find('.rejected-applicants span').text()) - 1;
1042                        $this.closest('.job-applicants').find('.rejected-applicants span').text(total_rej);
1043
1044                        if ( $this.closest('.job-applicants').find('.rejected-applicants').hasClass('active') ) {
1045                            
1046                            $this.closest('.job-applied-wrapper').remove();
1047                            $this.closest('.job-applicant-wrapper').remove();
1048                        } else {
1049                            if ( data.output ) {
1050                                $this.closest('.job-applicant-wrapper').replaceWith(data.output);
1051
1052                                $('.btn-create-meeting-job-applied').magnificPopup({
1053                                    mainClass: 'apus-mfp-zoom-in',
1054                                    type:'inline',
1055                                    midClick: true,
1056                                    closeBtnInside:false,
1057                                });
1058                            }
1059                        }
1060                    }
1061                    self.showMessage(data.msg, data.status);
1062                });
1063            });
1064
1065            // show reject applicants
1066            $(document).on('click', '.show-rejected-applicants', function(e) {
1067                e.preventDefault();
1068                var $this = $(this),
1069                    $con = $this.closest('.job-applicants');
1070                
1071                if ( $this.hasClass('active') || $this.hasClass('loading') ) {
1072                    return false;
1073                }
1074
1075                $this.addClass('loading');
1076                var job_id = $(this).data('job_id');
1077                var nonce = $(this).data('nonce');
1078                $.ajax({
1079                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_show_rejected_applicants' ),
1080                    type:'POST',
1081                    dataType: 'json',
1082                    data: {
1083                        'job_id': job_id,
1084                        'nonce': nonce,
1085                        'action': 'wp_freeio_ajax_show_rejected_applicants'
1086                    }
1087                }).done(function(data) {
1088                    $this.removeClass('loading');
1089                    if ( data.status ) {
1090                        $con.find('.applicants-wrapper').html(data.output);
1091                        $con.find('.show-total-applicants').removeClass('active');
1092                        $con.find('.show-approved-applicants').removeClass('active');
1093                        $this.addClass('active');
1094
1095                        $('.btn-create-meeting-job-applied').magnificPopup({
1096                            mainClass: 'apus-mfp-zoom-in',
1097                            type:'inline',
1098                            midClick: true,
1099                            closeBtnInside:false,
1100                        });
1101                    }
1102                    self.showMessage(data.msg, data.status);
1103                });
1104            });
1105
1106            // approve applicant
1107            $(document).on('click', '.btn-approve-job-applied', function(e) {
1108                e.preventDefault();
1109                var $this = $(this);
1110                $this.addClass('loading');
1111                var applicant_id = $(this).data('applicant_id');
1112                var nonce = $(this).data('nonce');
1113                $.ajax({
1114                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_approve_applied' ),
1115                    type:'POST',
1116                    dataType: 'json',
1117                    data: {
1118                        'applicant_id': applicant_id,
1119                        'nonce': nonce,
1120                        'action': 'wp_freeio_ajax_approve_applied',
1121                    }
1122                }).done(function(data) {
1123                    $this.removeClass('loading');
1124                    if ( data.status ) {
1125                        var total_app = parseInt($this.closest('.job-applicants').find('.approved-applicants span').text()) + 1;
1126                        $this.closest('.job-applicants').find('.approved-applicants span').text(total_app);
1127                        
1128                        if ( data.output ) {
1129                            $this.closest('.job-applicant-wrapper').replaceWith(data.output);
1130
1131                            $('.btn-create-meeting-job-applied').magnificPopup({
1132                                mainClass: 'apus-mfp-zoom-in',
1133                                type:'inline',
1134                                midClick: true,
1135                                closeBtnInside:false,
1136                            });
1137                        }
1138
1139                    }
1140                    self.showMessage(data.msg, data.status);
1141                });
1142            });
1143
1144            // undo approved applicant
1145            $(document).on('click', '.btn-undo-approve-job-applied', function(e) {
1146                e.preventDefault();
1147                var $this = $(this);
1148                $this.addClass('loading');
1149                var applicant_id = $(this).data('applicant_id');
1150                var nonce = $(this).data('nonce');
1151                $.ajax({
1152                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_undo_approve_applied' ),
1153                    type:'POST',
1154                    dataType: 'json',
1155                    data: {
1156                        'applicant_id': applicant_id,
1157                        'nonce': nonce,
1158                        'action': 'wp_freeio_ajax_undo_approve_applied',
1159                    }
1160                }).done(function(data) {
1161                    $this.removeClass('loading');
1162                    if ( data.status ) {
1163
1164                        var total_approve = parseInt($this.closest('.job-applicants').find('.approved-applicants span').text()) - 1;
1165                        $this.closest('.job-applicants').find('.approved-applicants span').text(total_approve);
1166
1167                        if ( $this.closest('.job-applicants').find('.approved-applicants').hasClass('active') ) {
1168                            $this.closest('.job-applied-wrapper').remove();
1169                            $this.closest('.job-applicant-wrapper').remove();
1170                        } else {
1171                            if ( data.output ) {
1172                                $this.closest('.job-applicant-wrapper').replaceWith(data.output);
1173
1174                                $('.btn-create-meeting-job-applied').magnificPopup({
1175                                    mainClass: 'apus-mfp-zoom-in',
1176                                    type:'inline',
1177                                    midClick: true,
1178                                    closeBtnInside:false,
1179                                });
1180                            }
1181                        }
1182                    }
1183                    self.showMessage(data.msg, data.status);
1184                });
1185            });
1186
1187            // show approved applicants
1188            $(document).on('click', '.show-approved-applicants', function(e) {
1189                e.preventDefault();
1190                var $this = $(this),
1191                    $con = $this.closest('.job-applicants');
1192                
1193                if ( $this.hasClass('active') || $this.hasClass('loading') ) {
1194                    return false;
1195                }
1196
1197                $this.addClass('loading');
1198                var job_id = $(this).data('job_id');
1199                var nonce = $(this).data('nonce');
1200                $.ajax({
1201                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_show_approved_applicants' ),
1202                    type:'POST',
1203                    dataType: 'json',
1204                    data: {
1205                        'job_id': job_id,
1206                        'nonce': nonce,
1207                        'action': 'wp_freeio_ajax_show_approved_applicants'
1208                    }
1209                }).done(function(data) {
1210                    $this.removeClass('loading');
1211                    if ( data.status ) {
1212                        $con.find('.applicants-wrapper').html(data.output);
1213                        $con.find('.show-total-applicants').removeClass('active');
1214                        $con.find('.show-rejected-applicants').removeClass('active');
1215                        $this.addClass('active');
1216
1217                        $('.btn-create-meeting-job-applied').magnificPopup({
1218                            mainClass: 'apus-mfp-zoom-in',
1219                            type:'inline',
1220                            midClick: true,
1221                            closeBtnInside:false,
1222                        });
1223                    }
1224                    self.showMessage(data.msg, data.status);
1225                });
1226            });
1227
1228            // show applicants
1229            $(document).on('click', '.show-total-applicants', function(e) {
1230                e.preventDefault();
1231                var $this = $(this),
1232                    $con = $this.closest('.job-applicants');
1233
1234                if ( $this.hasClass('active') || $this.hasClass('loading') ) {
1235                    return false;
1236                }
1237                $this.addClass('loading');
1238                var job_id = $(this).data('job_id');
1239                var nonce = $(this).data('nonce');
1240                $.ajax({
1241                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_show_applicants' ),
1242                    type:'POST',
1243                    dataType: 'json',
1244                    data: {
1245                        'job_id': job_id,
1246                        'nonce': nonce,
1247                        'action': 'wp_freeio_ajax_show_applicants'
1248                    }
1249                }).done(function(data) {
1250                    $this.removeClass('loading');
1251                    if ( data.status ) {
1252                        $con.find('.applicants-wrapper').html(data.output);
1253                        $con.find('.show-rejected-applicants').removeClass('active');
1254                        $con.find('.show-approved-applicants').removeClass('active');
1255                        $this.addClass('active');
1256
1257                        $('.btn-create-meeting-job-applied').magnificPopup({
1258                            mainClass: 'apus-mfp-zoom-in',
1259                            type:'inline',
1260                            midClick: true,
1261                            closeBtnInside:false,
1262                        });
1263                    }
1264                    self.showMessage(data.msg, data.status);
1265                });
1266            });
1267
1268            // pagination
1269            $(document).on('submit', 'form.applicants-pagination-form', function(e){
1270                e.preventDefault();
1271                var $this = $(this);
1272                var $container = $(this).closest('.applicants-wrapper');
1273                if ( $this.hasClass('loading') ) {
1274                    return false;
1275                }
1276                $this.addClass('loading');
1277                $.ajax({
1278                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_applicants_pagination' ),
1279                    type:'POST',
1280                    dataType: 'json',
1281                    data: $this.serialize()
1282                }).done(function(data) {
1283                    $this.removeClass('loading');
1284                    if ( data.status ) {
1285                        $container.find('.applicants-inner').append(data.output);
1286                        if ( data.paged > 0 ) {
1287                            $this.find('input[name=paged]').val(data.paged);
1288                        } else {
1289                            $this.remove();
1290                        }
1291
1292                        $('.btn-create-meeting-job-applied').magnificPopup({
1293                            mainClass: 'apus-mfp-zoom-in',
1294                            type:'inline',
1295                            midClick: true,
1296                            closeBtnInside:false,
1297                        });
1298                    } else {
1299                        self.showMessage(data.msg, data.status);
1300                    }
1301                });
1302                return false;
1303            });
1304
1305        },
1306        applicationMeeting: function() {
1307            if ( $('input.datetimepicker-date').length ) {
1308                $( "input.datetimepicker-date" ).each(function(){
1309                    $(this).datepicker({
1310                        dateFormat: $(this).data('date_format'),
1311                        altField: $(this).data('id'),
1312                        altFormat: 'yy-mm-dd'
1313                    });
1314                });
1315            }
1316
1317            if ( $.isFunction( $.fn.select2 ) && typeof wp_freeio_select2_opts !== 'undefined' ) {
1318                var select2_args = wp_freeio_select2_opts;
1319                select2_args['allowClear']              = false;
1320                select2_args['minimumResultsForSearch'] = -1;
1321                select2_args['width'] = '100%';
1322                if ( typeof wp_freeio_select2_opts.language_result !== 'undefined' ) {
1323                    select2_args['language'] = {
1324                        noResults: function (params) {
1325                            return wp_freeio_select2_opts['language_result'];
1326                        }
1327                    }
1328                }
1329                $('select.select-time-hour').select2( select2_args );
1330            }
1331
1332
1333            $('.btn-create-meeting-job-applied, .btn-messages-job-meeting, .btn-reschedule-job-meeting, .employer-meeting-zoom-settings').magnificPopup({
1334                mainClass: 'apus-mfp-zoom-in',
1335                type:'inline',
1336                midClick: true,
1337                closeBtnInside:false,
1338            });
1339
1340            $(document).on('click', '.close-popup', function(){
1341                $.magnificPopup.close()
1342            });
1343
1344            $(document).on('submit', 'form.create-meeting-form', function(e){
1345                e.preventDefault();
1346                var $this = $(this);
1347
1348                if ( self.createMeetingAjax ) {
1349                    self.createMeetingAjax.abort();
1350                }
1351
1352                if ( $this.hasClass('loading') ) {
1353                    return false;
1354                }
1355                var form_id = $(this).attr('id');
1356                
1357                
1358                $this.find('.alert').remove();
1359
1360                $this.addClass('loading');
1361                var form_data = new FormData( $('#' + form_id)[0] );
1362
1363                var action = $(this).find('input[name=action]').val();
1364                self.createMeetingAjax = $.ajax({
1365                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
1366                    type:'POST',
1367                    dataType: 'json',
1368                    data: form_data,
1369                    processData: false,
1370                    contentType: false,
1371                }).done(function(data) {
1372                    $this.removeClass('loading');
1373                    
1374                    if ( data.status ) {
1375                        $this.prepend( '<div class="alert alert-info">
1375'+data.msg+'</div>' );
1376
1377                        setTimeout(function(){
1378                            $.magnificPopup.close();
1379                        }, 2000);
1380
1381                    } else {
1382                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
1383                    }
1384
1385                    self.createMeetingAjax = false;
1386                });
1387                
1388            });
1389
1390            $(document).on('submit', 'form.reschedule-meeting-form', function(e){
1391                e.preventDefault();
1392                var $this = $(this);
1393
1394                if ( self.rescheduleMeetingAjax ) {
1395                    self.rescheduleMeetingAjax.abort();
1396                }
1397
1398                if ( $this.hasClass('loading') ) {
1399                    return false;
1400                }
1401                var form_id = $(this).attr('id');
1402                
1403                
1404                $this.find('.alert').remove();
1405
1406                $this.addClass('loading');
1407                var form_data = new FormData( $('#' + form_id)[0] );
1408
1409                var action = $(this).find('input[name=action]').val();
1410                self.rescheduleMeetingAjax = $.ajax({
1411                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
1412                    type:'POST',
1413                    dataType: 'json',
1414                    data: form_data,
1415                    processData: false,
1416                    contentType: false,
1417                }).done(function(data) {
1418                    $this.removeClass('loading');
1419                    
1420                    if ( data.status ) {
1421                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
1422                        location.reload();
1423                        setTimeout(function(){
1424                            $.magnificPopup.close();
1425                        }, 2000);
1426
1427                    } else {
1428                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
1429                    }
1430
1431                    self.rescheduleMeetingAjax = false;
1432                });
1433                
1434            });
1435
1436            $(document).on('click', '.btn-remove-job-meeting', function(e){
1437                e.preventDefault();
1438                var r = confirm( wp_freeio_opts.rm_item_txt );
1439                if ( r == true ) {
1440                    var $this = $(this),
1441                        $con = $this.closest('.meetings-list-inner');
1442
1443                    if ( $this.hasClass('loading') ) {
1444                        return false;
1445                    }
1446                    $this.addClass('loading');
1447                    var meeting_id = $(this).data('meeting_id');
1448                    var nonce = $(this).data('nonce');
1449                    $.ajax({
1450                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_meeting' ),
1451                        type:'POST',
1452                        dataType: 'json',
1453                        data: {
1454                            'meeting_id': meeting_id,
1455                            'nonce': nonce
1456                        }
1457                    }).done(function(data) {
1458                        $this.removeClass('loading');
1459                        if ( data.status ) {
1460                            if ( $con.find('.meeting-wrapper').length > 1 ) {
1461                                $this.closest('.meeting-wrapper').remove();
1462                            } else {
1463                                location.reload();
1464                            }
1465                        }
1466                        self.showMessage(data.msg, data.status);
1467                    });
1468                }
1469            });
1470
1471            $(document).on('click', '.btn-cancel-job-meeting', function(e){
1472                e.preventDefault();
1473                var r = confirm( wp_freeio_opts.rm_item_txt );
1474                if ( r == true ) {
1475                    var $this = $(this),
1476                        $con = $this.closest('.meetings-list-inner');
1477
1478                    if ( $this.hasClass('loading') ) {
1479                        return false;
1480                    }
1481                    $this.addClass('loading');
1482                    var meeting_id = $(this).data('meeting_id');
1483                    var nonce = $(this).data('nonce');
1484                    $.ajax({
1485                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_cancel_meeting' ),
1486                        type:'POST',
1487                        dataType: 'json',
1488                        data: {
1489                            'meeting_id': meeting_id,
1490                            'nonce': nonce
1491                        }
1492                    }).done(function(data) {
1493                        $this.removeClass('loading');
1494                        if ( data.status ) {
1495                            location.reload();
1496                        }
1497                        self.showMessage(data.msg, data.status);
1498                    });
1499                }
1500            });
1501
1502            // zoom settings
1503            $(document).on('submit', 'form.zoom-meeting-settings-form', function(e){
1504                e.preventDefault();
1505
1506                var $this = $(this);
1507
1508                if ( self.zoomSettingAjax ) {
1509                    self.zoomSettingAjax.abort();
1510                }
1511
1512                if ( $this.hasClass('loading') ) {
1513                    return false;
1514                }
1515                var form_id = $(this).attr('id');
1516                
1517                
1518                $this.find('.alert').remove();
1519
1520                $this.addClass('loading');
1521                var form_data = new FormData( $('#' + form_id)[0] );
1522
1523                var action = $(this).find('input[name=action]').val();
1524                self.zoomSettingAjax = $.ajax({
1525                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', action ),
1526                    type:'POST',
1527                    dataType: 'json',
1528                    data: form_data,
1529                    processData: false,
1530                    contentType: false,
1531                }).done(function(data) {
1532                    $this.removeClass('loading');
1533                    
1534                    // if ( data.status ) {
1535                        $this.prepend( '<div class="data">'+data.html+'</div>' );
1536                        
1537                        // setTimeout(function(){
1538                        //     $.magnificPopup.close();
1539                        // }, 2000);
1540
1541                    // } else {
1542                    //     $this.prepend( '<div class="alert alert-warning">'+data.html+'</div>' );
1543                    // }
1544
1545                    self.zoomSettingAjax = false;
1546                });
1547            });
1548        },
1549        
1550        jobFavorite: function() {
1551            var self = this;
1552            $(document).on('click', '.btn-add-job-favorite', function() {
1553                var $this = $(this);
1554                $this.addClass('loading');
1555                var job_id = $(this).data('job_id');
1556                var nonce = $(this).data('nonce');
1557                $.ajax({
1558                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_job_favorite' ),
1559                    type:'POST',
1560                    dataType: 'json',
1561                    data: {
1562                        'job_id': job_id,
1563                        'nonce': nonce,
1564                        'action': 'wp_freeio_ajax_add_job_favorite',
1565                    }
1566                }).done(function(data) {
1567                    $this.removeClass('loading');
1568                    if ( data.status ) {
1569                        $this.removeClass('btn-add-job-favorite').addClass('btn-added-job-favorite');
1570                        $this.data('nonce', data.nonce);
1571
1572                        $(document).trigger( "after_add_job_favorite", [$this, data] );
1573                    }
1574                    self.showMessage(data.msg, data.status);
1575                });
1576            });
1577            
1578            // remove
1579            $(document).on('click', '.btn-added-job-favorite', function() {
1580                var $this = $(this);
1581                $this.addClass('loading');
1582                var job_id = $(this).data('job_id');
1583                var nonce = $(this).data('nonce');
1584                $.ajax({
1585                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_job_favorite' ),
1586                    type:'POST',
1587                    dataType: 'json',
1588                    data: {
1589                        'job_id': job_id,
1590                        'nonce': nonce,
1591                        'action': 'wp_freeio_ajax_remove_job_favorite',
1592                    }
1593                }).done(function(data) {
1594                    $this.removeClass('loading');
1595                    if ( data.status ) {
1596                        $this.removeClass('btn-added-job-favorite').addClass('btn-add-job-favorite');
1597                        $this.data('nonce', data.nonce);
1598
1599                        $(document).trigger( "after_remove_job_favorite", [$this, data] );
1600                    }
1601                    self.showMessage(data.msg, data.status);
1602                });
1603            });
1604
1605            $('.btn-remove-job-favorite').on('click', function() {
1606                var $this = $(this);
1607                $this.addClass('loading');
1608                var job_id = $(this).data('job_id');
1609                var nonce = $(this).data('nonce');
1610                $.ajax({
1611                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_job_favorite' ),
1612                    type:'POST',
1613                    dataType: 'json',
1614                    data: {
1615                        'job_id': job_id,
1616                        'nonce': nonce,
1617                        'action': 'wp_freeio_ajax_remove_job_favorite',
1618                    }
1619                }).done(function(data) {
1620                    $this.removeClass('loading');
1621                    if ( data.status ) {
1622                        $this.closest('.job-favorite-wrapper').remove();
1623
1624                        $(document).trigger( "after_remove_job_favorite", [$this, data] );
1625                    }
1626                    self.showMessage(data.msg, data.status);
1627                });
1628            });
1629        },
1630        serviceFavorite: function() {
1631            var self = this;
1632            $(document).on('click', '.btn-add-service-favorite', function() {
1633                var $this = $(this);
1634                $this.addClass('loading');
1635                var service_id = $(this).data('service_id');
1636                var nonce = $(this).data('nonce');
1637                $.ajax({
1638                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_service_favorite' ),
1639                    type:'POST',
1640                    dataType: 'json',
1641                    data: {
1642                        'service_id': service_id,
1643                        'nonce': nonce,
1644                        'action': 'wp_freeio_ajax_add_service_favorite',
1645                    }
1646                }).done(function(data) {
1647                    $this.removeClass('loading');
1648                    if ( data.status ) {
1649                        $this.removeClass('btn-add-service-favorite').addClass('btn-added-service-favorite');
1650                        $this.data('nonce', data.nonce);
1651
1652                        $(document).trigger( "after_add_service_favorite", [$this, data] );
1653                    }
1654                    self.showMessage(data.msg, data.status);
1655                });
1656            });
1657            
1658            // remove
1659            $(document).on('click', '.btn-added-service-favorite', function() {
1660                var $this = $(this);
1661                $this.addClass('loading');
1662                var service_id = $(this).data('service_id');
1663                var nonce = $(this).data('nonce');
1664                $.ajax({
1665                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_service_favorite' ),
1666                    type:'POST',
1667                    dataType: 'json',
1668                    data: {
1669                        'service_id': service_id,
1670                        'nonce': nonce,
1671                        'action': 'wp_freeio_ajax_remove_service_favorite',
1672                    }
1673                }).done(function(data) {
1674                    $this.removeClass('loading');
1675                    if ( data.status ) {
1676                        $this.removeClass('btn-added-service-favorite').addClass('btn-add-service-favorite');
1677                        $this.data('nonce', data.nonce);
1678
1679                        $(document).trigger( "after_remove_service_favorite", [$this, data] );
1680                    }
1681                    self.showMessage(data.msg, data.status);
1682                });
1683            });
1684
1685            $('.btn-remove-service-favorite').on('click', function() {
1686                var $this = $(this);
1687                $this.addClass('loading');
1688                var service_id = $(this).data('service_id');
1689                var nonce = $(this).data('nonce');
1690                $.ajax({
1691                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_service_favorite' ),
1692                    type:'POST',
1693                    dataType: 'json',
1694                    data: {
1695                        'service_id': service_id,
1696                        'nonce': nonce,
1697                        'action': 'wp_freeio_ajax_remove_service_favorite',
1698                    }
1699                }).done(function(data) {
1700                    $this.removeClass('loading');
1701                    if ( data.status ) {
1702                        $this.closest('.service-favorite-wrapper').remove();
1703
1704                        $(document).trigger( "after_remove_service_favorite", [$this, data] );
1705                    }
1706                    self.showMessage(data.msg, data.status);
1707                });
1708            });
1709        },
1710        projectFavorite: function() {
1711            var self = this;
1712            $(document).on('click', '.btn-add-project-favorite', function() {
1713                var $this = $(this);
1714                $this.addClass('loading');
1715                var project_id = $(this).data('project_id');
1716                var nonce = $(this).data('nonce');
1717                $.ajax({
1718                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_project_favorite' ),
1719                    type:'POST',
1720                    dataType: 'json',
1721                    data: {
1722                        'project_id': project_id,
1723                        'nonce': nonce,
1724                        'action': 'wp_freeio_ajax_add_project_favorite',
1725                    }
1726                }).done(function(data) {
1727                    $this.removeClass('loading');
1728                    if ( data.status ) {
1729                        $this.removeClass('btn-add-project-favorite').addClass('btn-added-project-favorite');
1730                        $this.data('nonce', data.nonce);
1731
1732                        $(document).trigger( "after_add_project_favorite", [$this, data] );
1733                    }
1734                    self.showMessage(data.msg, data.status);
1735                });
1736            });
1737            
1738            // remove
1739            $(document).on('click', '.btn-added-project-favorite', function() {
1740                var $this = $(this);
1741                $this.addClass('loading');
1742                var project_id = $(this).data('project_id');
1743                var nonce = $(this).data('nonce');
1744                $.ajax({
1745                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_project_favorite' ),
1746                    type:'POST',
1747                    dataType: 'json',
1748                    data: {
1749                        'project_id': project_id,
1750                        'nonce': nonce,
1751                        'action': 'wp_freeio_ajax_remove_project_favorite',
1752                    }
1753                }).done(function(data) {
1754                    $this.removeClass('loading');
1755                    if ( data.status ) {
1756                        $this.removeClass('btn-added-project-favorite').addClass('btn-add-project-favorite');
1757                        $this.data('nonce', data.nonce);
1758
1759                        $(document).trigger( "after_remove_project_favorite", [$this, data] );
1760                    }
1761                    self.showMessage(data.msg, data.status);
1762                });
1763            });
1764
1765            $('.btn-remove-project-favorite').on('click', function() {
1766                var $this = $(this);
1767                $this.addClass('loading');
1768                var project_id = $(this).data('project_id');
1769                var nonce = $(this).data('nonce');
1770                $.ajax({
1771                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_project_favorite' ),
1772                    type:'POST',
1773                    dataType: 'json',
1774                    data: {
1775                        'project_id': project_id,
1776                        'nonce': nonce,
1777                        'action': 'wp_freeio_ajax_remove_project_favorite',
1778                    }
1779                }).done(function(data) {
1780                    $this.removeClass('loading');
1781                    if ( data.status ) {
1782                        $this.closest('.project-favorite-wrapper').remove();
1783
1784                        $(document).trigger( "after_remove_project_favorite", [$this, data] );
1785                    }
1786                    self.showMessage(data.msg, data.status);
1787                });
1788            });
1789        },
1790        employerFavorite: function() {
1791            var self = this;
1792            $(document).on('click', '.btn-add-employer-favorite', function() {
1793                var $this = $(this);
1794                $this.addClass('loading');
1795                var employer_id = $(this).data('employer_id');
1796                var nonce = $(this).data('nonce');
1797                $.ajax({
1798                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_employer_favorite' ),
1799                    type:'POST',
1800                    dataType: 'json',
1801                    data: {
1802                        'employer_id': employer_id,
1803                        'nonce': nonce,
1804                        'action': 'wp_freeio_ajax_add_employer_favorite',
1805                    }
1806                }).done(function(data) {
1807                    $this.removeClass('loading');
1808                    if ( data.status ) {
1809                        $this.removeClass('btn-add-employer-favorite').addClass('btn-added-employer-favorite');
1810                        $this.data('nonce', data.nonce);
1811
1812                        $(document).trigger( "after_add_employer_favorite", [$this, data] );
1813                    }
1814                    self.showMessage(data.msg, data.status);
1815                });
1816            });
1817            
1818            // remove
1819            $(document).on('click', '.btn-added-employer-favorite', function() {
1820                var $this = $(this);
1821                $this.addClass('loading');
1822                var employer_id = $(this).data('employer_id');
1823                var nonce = $(this).data('nonce');
1824                $.ajax({
1825                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_employer_favorite' ),
1826                    type:'POST',
1827                    dataType: 'json',
1828                    data: {
1829                        'employer_id': employer_id,
1830                        'nonce': nonce,
1831                        'action': 'wp_freeio_ajax_remove_employer_favorite',
1832                    }
1833                }).done(function(data) {
1834                    $this.removeClass('loading');
1835                    if ( data.status ) {
1836                        $this.removeClass('btn-added-employer-favorite').addClass('btn-add-employer-favorite');
1837                        $this.data('nonce', data.nonce);
1838
1839                        $(document).trigger( "after_remove_employer_favorite", [$this, data] );
1840                    }
1841                    self.showMessage(data.msg, data.status);
1842                });
1843            });
1844
1845            $('.btn-remove-employer-favorite').on('click', function() {
1846                var $this = $(this);
1847                $this.addClass('loading');
1848                var employer_id = $(this).data('employer_id');
1849                var nonce = $(this).data('nonce');
1850                $.ajax({
1851                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_employer_favorite' ),
1852                    type:'POST',
1853                    dataType: 'json',
1854                    data: {
1855                        'employer_id': employer_id,
1856                        'nonce': nonce,
1857                        'action': 'wp_freeio_ajax_remove_employer_favorite',
1858                    }
1859                }).done(function(data) {
1860                    $this.removeClass('loading');
1861                    if ( data.status ) {
1862                        $this.closest('.employer-favorite-wrapper').remove();
1863
1864                        $(document).trigger( "after_remove_employer_favorite", [$this, data] );
1865                    }
1866                    self.showMessage(data.msg, data.status);
1867                });
1868            });
1869        },
1870        freelancerFavorite: function() {
1871            var self = this;
1872            $(document).on('click', '.btn-add-freelancer-favorite', function() {
1873                var $this = $(this);
1874                $this.addClass('loading');
1875                var freelancer_id = $(this).data('freelancer_id');
1876                var nonce = $(this).data('nonce');
1877                $.ajax({
1878                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_freelancer_favorite' ),
1879                    type:'POST',
1880                    dataType: 'json',
1881                    data: {
1882                        'freelancer_id': freelancer_id,
1883                        'nonce': nonce,
1884                        'action': 'wp_freeio_ajax_add_freelancer_favorite',
1885                    }
1886                }).done(function(data) {
1887                    $this.removeClass('loading');
1888                    if ( data.status ) {
1889                        $this.removeClass('btn-add-freelancer-favorite').addClass('btn-added-freelancer-favorite');
1890                        $this.data('nonce', data.nonce);
1891
1892                        $(document).trigger( "after_add_freelancer_favorite", [$this, data] );
1893                    }
1894                    self.showMessage(data.msg, data.status);
1895                });
1896            });
1897            
1898            // remove
1899            $(document).on('click', '.btn-added-freelancer-favorite', function() {
1900                var $this = $(this);
1901                $this.addClass('loading');
1902                var freelancer_id = $(this).data('freelancer_id');
1903                var nonce = $(this).data('nonce');
1904                $.ajax({
1905                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_freelancer_favorite' ),
1906                    type:'POST',
1907                    dataType: 'json',
1908                    data: {
1909                        'freelancer_id': freelancer_id,
1910                        'nonce': nonce,
1911                        'action': 'wp_freeio_ajax_remove_freelancer_favorite',
1912                    }
1913                }).done(function(data) {
1914                    $this.removeClass('loading');
1915                    if ( data.status ) {
1916                        $this.removeClass('btn-added-freelancer-favorite').addClass('btn-add-freelancer-favorite');
1917                        $this.data('nonce', data.nonce);
1918
1919                        $(document).trigger( "after_remove_freelancer_favorite", [$this, data] );
1920                    }
1921                    self.showMessage(data.msg, data.status);
1922                });
1923            });
1924
1925            $('.btn-remove-freelancer-favorite').on('click', function() {
1926                var $this = $(this);
1927                $this.addClass('loading');
1928                var freelancer_id = $(this).data('freelancer_id');
1929                var nonce = $(this).data('nonce');
1930                $.ajax({
1931                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_freelancer_favorite' ),
1932                    type:'POST',
1933                    dataType: 'json',
1934                    data: {
1935                        'freelancer_id': freelancer_id,
1936                        'nonce': nonce,
1937                        'action': 'wp_freeio_ajax_remove_freelancer_favorite',
1938                    }
1939                }).done(function(data) {
1940                    $this.removeClass('loading');
1941                    if ( data.status ) {
1942                        $this.closest('.freelancer-favorite-wrapper').remove();
1943
1944                        $(document).trigger( "after_remove_freelancer_favorite", [$this, data] );
1945                    }
1946                    self.showMessage(data.msg, data.status);
1947                });
1948            });
1949        },
1950        servicePrice: function() {
1951            var self = this;
1952
1953            $(document).on('submit', 'form.submit-service-addon-form', function(){
1954                var $this = $(this);
1955
1956                if ( self.registerAjax ) {
1957                    self.registerAjax.abort();
1958                }
1959
1960                if ( $this.hasClass('loading') ) {
1961                    return false;
1962                }
1963
1964                var form_id = $this.attr('id');
1965                
1966                $this.find('.alert').remove();
1967
1968                $this.addClass('loading');
1969                var form_data = new FormData( $('#' + form_id)[0] );
1970                
1971                self.registerAjax = $.ajax({
1972                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_submit_service_addon' ),
1973                    type:'POST',
1974                    dataType: 'json',
1975                    data: form_data,
1976                    processData: false,
1977                    contentType: false,
1978                }).done(function(data) {
1979                    $this.removeClass('loading');
1980                    if ( data.status ) {
1981                        self.showMessage(data.msg, data.status);
1982                        setTimeout(function(){
1983                            location.reload();
1984                        }, 1000);
1985                    } else {
1986                        self.showMessage(data.msg, data.status);
1987                    }
1988                    self.registerAjax = false;
1989                });
1990                
1991                return false;
1992            });
1993
1994            $(document).on('change', 'form.service-add-to-cart .service-price-addons .addon-item input', function(){
1995                var $this = $(this);
1996
1997                if ( self.registerAjax ) {
1998                    self.registerAjax.abort();
1999                }
2000
2001                var form_container = $(this).closest('form.service-add-to-cart');
2002                var form_id = form_container.attr('id');
2003
2004                if ( form_container.hasClass('loading') ) {
2005                    return false;
2006                }
2007
2008                form_container.addClass('loading');
2009                var form_data = new FormData( $('#' + form_id)[0] );
2010                
2011                self.registerAjax = $.ajax({
2012                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_change_service_addon' ),
2013                    type:'POST',
2014                    dataType: 'json',
2015                    data: form_data,
2016                    processData: false,
2017                    contentType: false,
2018                }).done(function(data) {
2019                    form_container.removeClass('loading');
2020                    if ( data.status ) {
2021                        form_container.find('.service-price-inner').html(data.price);
2022                        form_container.find('button span').html(data.price_without_html);
2023                    } else {
2024                        self.showMessage(data.msg, data.status);
2025                    }
2026                    self.registerAjax = false;
2027                });
2028                
2029                return false;
2030            });
2031
2032            $(document).on('submit', 'form.service-add-to-cart', function(){
2033                var $this = $(this);
2034
2035                if ( self.registerAjax ) {
2036                    self.registerAjax.abort();
2037                }
2038
2039                if ( $this.hasClass('loading') ) {
2040                    return false;
2041                }
2042
2043                var form_id = $this.attr('id');
2044                
2045                $this.find('.alert').remove();
2046
2047                $this.addClass('loading');
2048                var form_data = new FormData( $('#' + form_id)[0] );
2049                
2050                self.registerAjax = $.ajax({
2051                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_hire_service' ),
2052                    type:'POST',
2053                    dataType: 'json',
2054                    data: form_data,
2055                    processData: false,
2056                    contentType: false,
2057                }).done(function(data) {
2058                    $this.removeClass('loading');
2059                    if ( data.status ) {
2060                        self.showMessage(data.msg, data.status);
2061                        window.location.href = data.checkout_url;
2062                    } else {
2063                        self.showMessage(data.msg, data.status);
2064                    }
2065                    self.registerAjax = false;
2066
2067                    $(document).trigger( "after_change_service_add_to_cart", [$this, data] );
2068                });
2069                
2070                return false;
2071            });
2072
2073            $(document).on('submit', 'form.service-order-message-form', function(){
2074                var $this = $(this);
2075
2076                if ( self.applyEmailAjax ) {
2077                    self.applyEmailAjax.abort();
2078                }
2079
2080                if ( $this.hasClass('loading') ) {
2081                    return false;
2082                }
2083
2084                var form_id = $(this).attr('id');
2085                var error = false;
2086
2087                
2088                var attachments = $this.find('input[name="attachments"]');
2089                if (attachments.length > 0 && attachments.val() != '') {
2090                    attachments = attachments.prop('files')[0];
2091
2092                    var file_size = attachments.size;
2093                    var file_type = attachments.type;
2094
2095                    var allowed_types = wp_freeio_opts.cv_file_types;
2096                    var filesize_allow = wp_freeio_opts.cv_file_size_allow;
2097                    filesize_allow = parseInt(filesize_allow);
2098
2099                    if (file_size > filesize_allow) {
2100                        alert(wp_freeio_opts.cv_file_size_error);
2101                        error = true;
2102                    }
2103                    if (allowed_types.indexOf(file_type) < 0) {
2104                        alert(wp_freeio_opts.cv_file_types_error);
2105                        error = true;
2106                    }
2107                }
2108
2109                if ( error == false ) {
2110                    $this.find('.alert').remove();
2111
2112                    $this.addClass('loading');
2113                    var form_data = new FormData( $('#' + form_id)[0] );
2114                    
2115                    self.applyEmailAjax = $.ajax({
2116                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_send_service_order_message' ),
2117                        type:'POST',
2118                        dataType: 'json',
2119                        data: form_data,
2120                        processData: false,
2121                        contentType: false,
2122                    }).done(function(data) {
2123                        $this.removeClass('loading');
2124                        
2125                        if ( data.status ) {
2126                            if ( data.html ) {
2127                                $('.messages-list').html(data.html);
2128                                $(".list-replies").scrollTop( $( ".list-replies" ).prop( "scrollHeight" ) );
2129
2130                                $this.trigger("reset");
2131                            }
2132                        }
2133                        self.showMessage(data.msg, data.status);
2134
2135                        self.applyEmailAjax = false;
2136                    });
2137                } else {
2138                    alert(wp_freeio_opts.choose_a_cv);
2139                }
2140                return false;
2141            });
2142
2143            $('.update-service-order-status').on('click', function() {
2144                var $this = $(this);
2145                
2146                $this.addClass('loading');
2147                var service_order_id = $(this).data('service_order_id');
2148                var nonce = $(this).data('nonce');
2149                var status = $('#service_order_status').val();
2150                $.ajax({
2151                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_change_service_order_status' ),
2152                    type:'POST',
2153                    dataType: 'json',
2154                    data: {
2155                        'service_order_id': service_order_id,
2156                        'nonce': nonce,
2157                        'status': status
2158                    }
2159                }).done(function(data) {
2160                    $this.removeClass('loading');
2161                    
2162                    $(document).trigger( "after_change_service_order_status", [$this, data] );
2163
2164                    self.showMessage(data.msg, data.status);
2165                });
2166            });
2167        },
2168        projectProposal: function() {
2169            var self = this;
2170            
2171            $(document).on('submit', 'form.project-proposal-form', function(){
2172                var $this = $(this);
2173
2174                if ( self.registerAjax ) {
2175                    self.registerAjax.abort();
2176                }
2177
2178                if ( $this.hasClass('loading') ) {
2179                    return false;
2180                }
2181
2182                var form_id = $this.attr('id');
2183                
2184                $this.find('.alert').remove();
2185
2186                $this.addClass('loading');
2187                var form_data = new FormData( $('#' + form_id)[0] );
2188                
2189                self.registerAjax = $.ajax({
2190                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_project_proposal' ),
2191                    type:'POST',
2192                    dataType: 'json',
2193                    data: form_data,
2194                    processData: false,
2195                    contentType: false,
2196                }).done(function(data) {
2197                    $this.removeClass('loading');
2198                    if ( data.status ) {
2199                        self.showMessage(data.msg, data.status);
2200                        if ( data.edit ) {
2201                            setTimeout(function(){
2202                                location.reload();    
2203                            }, 1000);
2204                        } else {
2205                            if ( data.html ) {
2206                                $('.project-detail-proposals').html(data.html);
2207                            }
2208                        }
2209                    } else {
2210                        self.showMessage(data.msg, data.status);
2211                    }
2212                    self.registerAjax = false;
2213                });
2214                
2215                return false;
2216            });
2217
2218            // hire
2219            $('.proposal-button-hire-now').on('click', function() {
2220                var $this = $(this);
2221                var r = confirm( wp_freeio_opts.rm_item_txt );
2222                if ( r == true ) {
2223                    $this.addClass('loading');
2224                    var proposal_id = $(this).data('proposal_id');
2225                    var nonce = $(this).data('nonce');
2226                    $.ajax({
2227                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_hire_proposal' ),
2228                        type:'POST',
2229                        dataType: 'json',
2230                        data: {
2231                            'proposal_id': proposal_id,
2232                            'nonce': nonce,
2233                            'action': 'wp_freeio_ajax_hire_proposal',
2234                        }
2235                    }).done(function(data) {
2236                        $this.removeClass('loading');
2237                        
2238                        self.showMessage(data.msg, data.status);
2239                        if ( data.status ) {
2240                            window.location.href = data.checkout_url;
2241                        }
2242                        
2243                        $(document).trigger( "after_hire_project_proposal", [$this, data] );
2244
2245                        self.showMessage(data.msg, data.status);
2246                    });
2247                }
2248            });
2249
2250            if ( $(".messages-list .list-replies") ) {
2251                $(".messages-list .list-replies").scrollTop( $( ".messages-list .list-replies" ).prop( "scrollHeight" ) );
2252            }
2253            $(document).on('submit', 'form.proposal-message-form', function(){
2254                var $this = $(this);
2255
2256                if ( self.applyEmailAjax ) {
2257                    self.applyEmailAjax.abort();
2258                }
2259
2260                if ( $this.hasClass('loading') ) {
2261                    return false;
2262                }
2263
2264                var form_id = $(this).attr('id');
2265                var error = false;
2266
2267                
2268                var attachments = $this.find('input[name="attachments"]');
2269                if (attachments.length > 0 && attachments.val() != '') {
2270                    attachments = attachments.prop('files')[0];
2271
2272                    var file_size = attachments.size;
2273                    var file_type = attachments.type;
2274
2275                    var allowed_types = wp_freeio_opts.cv_file_types;
2276                    var filesize_allow = wp_freeio_opts.cv_file_size_allow;
2277                    filesize_allow = parseInt(filesize_allow);
2278
2279                    if (file_size > filesize_allow) {
2280                        alert(wp_freeio_opts.cv_file_size_error);
2281                        error = true;
2282                    }
2283                    if (allowed_types.indexOf(file_type) < 0) {
2284                        alert(wp_freeio_opts.cv_file_types_error);
2285                        error = true;
2286                    }
2287                }
2288
2289                if ( error == false ) {
2290                    $this.find('.alert').remove();
2291
2292                    $this.addClass('loading');
2293                    var form_data = new FormData( $('#' + form_id)[0] );
2294                    
2295                    self.applyEmailAjax = $.ajax({
2296                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_send_proposal_message' ),
2297                        type:'POST',
2298                        dataType: 'json',
2299                        data: form_data,
2300                        processData: false,
2301                        contentType: false,
2302                    }).done(function(data) {
2303                        $this.removeClass('loading');
2304                        
2305                        if ( data.status ) {
2306                            if ( data.html ) {
2307                                $('.messages-list').html(data.html);
2308
2309                                $(".list-replies").scrollTop( $( ".list-replies" ).prop( "scrollHeight" ) );
2310
2311                                $this.trigger("reset");
2312                            }
2313                        }
2314                        self.showMessage(data.msg, data.status);
2315
2316                        self.applyEmailAjax = false;
2317                    });
2318                } else {
2319                    alert(wp_freeio_opts.choose_a_cv);
2320                }
2321                return false;
2322            });
2323
2324            $('.update-proposal-status').on('click', function() {
2325                var $this = $(this);
2326                
2327                $this.addClass('loading');
2328                var proposal_id = $(this).data('proposal_id');
2329                var nonce = $(this).data('nonce');
2330                var status = $('#proposal_status').val();
2331                $.ajax({
2332                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_change_proposal_status' ),
2333                    type:'POST',
2334                    dataType: 'json',
2335                    data: {
2336                        'proposal_id': proposal_id,
2337                        'nonce': nonce,
2338                        'status': status
2339                    }
2340                }).done(function(data) {
2341                    $this.removeClass('loading');
2342                    
2343                    $(document).trigger( "after_change_proposal_status", [$this, data] );
2344
2345                    self.showMessage(data.msg, data.status);
2346                });
2347            });
2348        },
2349        reviewInit: function() {
2350            var self = this;
2351            if ( $('.comment-form-rating').length > 0 ) {
2352                var $star = $('.comment-form-rating .filled');
2353                var $review = $('#_input_rating');
2354                $star.find('li').on('mouseover', function () {
2355                    $(this).nextAll().addClass('active');
2356                    $(this).prevAll().removeClass('active');
2357                    $(this).removeClass('active');
2358                });
2359                $star.on('mouseout', function(){
2360                    var current = $review.val() - 1;
2361                    var current_e = $star.find('li').eq(current);
2362
2363                    current_e.nextAll().addClass('active');
2364                    current_e.prevAll().removeClass('active');
2365                    current_e.removeClass('active');
2366                });
2367                $star.find('li').on('click', function () {
2368                    $(this).nextAll().addClass('active');
2369                    $(this).prevAll().removeClass('active');
2370                    $(this).removeClass('active');
2371                    
2372                    $review.val($(this).index() + 1);
2373                } );
2374            }
2375        },
2376        jobAlert: function() {
2377            var self = this;
2378            $(document).on('click', '.btn-job-alert', function() {
2379                var form_html = $('.job-alert-form-wrapper').html();
2380                $.magnificPopup.open({
2381                    mainClass: 'wp-freeio-mfp-container',
2382                    items    : {
2383                        src : form_html,
2384                        type: 'inline'
2385                    }
2386                });
2387            });
2388            $(document).on('submit', 'form.job-alert-form', function() {
2389                var $this = $(this);
2390                $this.addClass('loading');
2391                $this.find('.alert').remove();
2392                var url_vars = self.getUrlVars();
2393                $.ajax({
2394                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_job_alert' ),
2395                    type:'POST',
2396                    dataType: 'json',
2397                    data: $this.serialize() + '&action=wp_freeio_ajax_add_job_alert' + url_vars
2398                }).done(function(data) {
2399                    $this.removeClass('loading');
2400                    if ( data.status ) {
2401                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
2402                        setTimeout(function(){
2403                            $.magnificPopup.close();
2404                        }, 1500);
2405                    } else {
2406                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
2407                    }
2408                });
2409
2410                return false;
2411            });
2412
2413            // Remove job alert
2414            $(document).on('click', '.btn-remove-job-alert', function() {
2415                var $this = $(this);
2416                var r = confirm( wp_freeio_opts.rm_item_txt );
2417                if ( r == true ) {
2418                    $this.addClass('loading');
2419                    var alert_id = $(this).data('alert_id');
2420                    var nonce = $(this).data('nonce');
2421                    $.ajax({
2422                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_job_alert' ),
2423                        type:'POST',
2424                        dataType: 'json',
2425                        data: {
2426                            'alert_id': alert_id,
2427                            'nonce': nonce,
2428                            'action': 'wp_freeio_ajax_remove_job_alert',
2429                        }
2430                    }).done(function(data) {
2431                        $this.removeClass('loading');
2432                        if ( data.status ) {
2433                            $this.closest('.job-alert-wrapper').remove();
2434                        }
2435                        self.showMessage(data.msg, data.status);
2436                    });
2437                }
2438            });
2439        },
2440        freelancerAlert: function() {
2441            var self = this;
2442            $(document).on('click', '.btn-freelancer-alert', function() {
2443                var form_html = $('.freelancer-alert-form-wrapper').html();
2444                $.magnificPopup.open({
2445                    mainClass: 'wp-freeio-mfp-container',
2446                    items    : {
2447                        src : form_html,
2448                        type: 'inline'
2449                    }
2450                });
2451            });
2452            $(document).on('submit', 'form.freelancer-alert-form', function() {
2453                var $this = $(this);
2454                $this.addClass('loading');
2455                var url_vars = self.getUrlVars();
2456                $.ajax({
2457                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_add_freelancer_alert' ),
2458                    type:'POST',
2459                    dataType: 'json',
2460                    data: $this.serialize() + '&action=wp_freeio_ajax_add_freelancer_alert' + url_vars
2461                }).done(function(data) {
2462                    $this.removeClass('loading');
2463                    if ( data.status ) {
2464                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
2465                        setTimeout(function(){
2466                            $.magnificPopup.close();
2467                        }, 1500);
2468                    } else {
2469                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
2470                    }
2471                });
2472
2473                return false;
2474            });
2475
2476            // Remove freelancer alert
2477            $(document).on('click', '.btn-remove-freelancer-alert', function() {
2478                var $this = $(this);
2479                var r = confirm( wp_freeio_opts.rm_item_txt );
2480                if ( r == true ) {
2481                    $this.addClass('loading');
2482                    var alert_id = $(this).data('alert_id');
2483                    var nonce = $(this).data('nonce');
2484                    $.ajax({
2485                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_freelancer_alert' ),
2486                        type:'POST',
2487                        dataType: 'json',
2488                        data: {
2489                            'alert_id': alert_id,
2490                            'nonce': nonce,
2491                            'action': 'wp_freeio_ajax_remove_freelancer_alert',
2492                        }
2493                    }).done(function(data) {
2494                        $this.removeClass('loading');
2495                        if ( data.status ) {
2496                            $this.closest('.freelancer-alert-wrapper').remove();
2497                        }
2498                        self.showMessage(data.msg, data.status);
2499                    });
2500                }
2501            });
2502        },
2503        getUrlVars: function() {
2504            var self = this;
2505            var vars = '';
2506            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
2507            for(var i = 0; i < hashes.length; i++) {
2508                vars += '&' +hashes[i];
2509            }
2510            return vars;
2511        },
2512        jobSocialApply: function() {
2513            var self = this;
2514            $('.facebook-apply-btn').on('click', function(){
2515                var job_id = $(this).data('job_id');
2516                var facebook_login_url = $(this).attr('href');
2517                self.setCookie('wp_freeio_facebook_job_id', job_id, 1);
2518                window.location.href = facebook_login_url;
2519            });
2520            
2521            // google
2522            $('.google-apply-btn').on('click', function(){
2523                var job_id = $(this).data('job_id');
2524                var google_login_url = $(this).attr('href');
2525                self.setCookie('wp_freeio_google_job_id', job_id, 1);
2526                window.location.href = google_login_url;
2527            });
2528
2529            // linkedin
2530            $('.linkedin-apply-btn').on('click', function(){
2531                var job_id = $(this).data('job_id');
2532                var linkedin_login_url = $(this).attr('href');
2533                self.setCookie('wp_freeio_linkedin_job_id', job_id, 1);
2534                window.location.href = linkedin_login_url;
2535            });
2536
2537            // twitter
2538            $('.twitter-apply-btn').on('click', function(){
2539                var job_id = $(this).data('job_id');
2540                var twitter_login_url = $(this).attr('href');
2541                self.setCookie('wp_freeio_twitter_job_id', job_id, 1);
2542                window.location.href = twitter_login_url;
2543            });
2544        },
2545        select2Init: function() {
2546            var self = this;
2547            if ( $.isFunction( $.fn.select2 ) && typeof wp_freeio_select2_opts !== 'undefined' ) {
2548                var select2_args = wp_freeio_select2_opts;
2549                select2_args['allowClear']              = false;
2550                select2_args['minimumResultsForSearch'] = 10;
2551                select2_args['width'] = 'auto';
2552                if ( typeof wp_freeio_select2_opts.language_result !== 'undefined' ) {
2553                    select2_args['language'] = {
2554                        noResults: function (params) {
2555                            return wp_freeio_select2_opts['language_result'];
2556                        }
2557                    }
2558                }
2559                if( $('.woocommerce-ordering select.orderby').length ){
2560                    var woo_select2_args = select2_args;
2561                    woo_select2_args.theme = 'default orderby';
2562                    $('.woocommerce-ordering select.orderby').select2( woo_select2_args );
2563                }
2564                $('select.orderby').select2( select2_args );
2565                $('select.job_id').select2( select2_args );
2566            }
2567        },
2568        jobSubmission: function() {
2569            var self = this;
2570            // select2
2571            if ( $.isFunction( $.fn.select2 ) && typeof wp_freeio_select2_opts !== 'undefined' ) {
2572                var select2_args = wp_freeio_select2_opts;
2573                select2_args['allowClear']              = false;
2574                if ( typeof wp_freeio_select2_opts.language_result !== 'undefined' ) {
2575                    select2_args['language'] = {
2576                        noResults: function (params) {
2577                            return select2_args['language_result'];
2578                        }
2579                    }
2580                }
2581                select2_args['minimumResultsForSearch'] = 10;
2582                
2583                $( 'select.cmb2_select' ).select2( select2_args );
2584            }
2585
2586            $('.cmb-repeatable-group').on('cmb2_add_group_row_start', function (event, instance) {
2587                var $table = $(document.getElementById($(instance).data('selector')));
2588                var $oldRow = $table.find('.cmb-repeatable-grouping').last();
2589
2590                $oldRow.find('select.cmb2_select').each(function () {
2591                    $(this).select2('destroy');
2592                });
2593            });
2594
2595            $('.cmb-repeatable-group').on('cmb2_add_row', function (event, newRow) {
2596                $(newRow).find('select.cmb2_select').each(function () {
2597                    $('option:selected', this).removeAttr("selected");
2598                    $(this).select2(select2_args);
2599                });
2600
2601                // Reinitialise the field we previously destroyed
2602                $(newRow).prev().find('select.cmb2_select').each(function () {
2603                    $(this).select2(select2_args);
2604                });
2605            });
2606            
2607            ///
2608            $('.cmb-add-row-button').on('click', function (event) {
2609                var $table = $(document.getElementById($(event.target).data('selector')));
2610                var $oldRow = $table.find('.cmb-row').last();
2611
2612                $oldRow.find('select.cmb2_select').each(function () {
2613                    $(this).select2('destroy');
2614                });
2615            });
2616
2617            $('.cmb-repeat-table').on('cmb2_add_row', function (event, newRow) {
2618                // Reinitialise the field we previously destroyed
2619                $(newRow).prev().find('select.cmb2_select').each(function () {
2620                    $('option:selected', this).removeAttr("selected");
2621                    $(this).select2(select2_args);
2622                });
2623            });
2624
2625            //
2626            var apply_type = $('#_job_apply_type').val();
2627            if ( apply_type == 'internal' ) {
2628                $('.cmb2-id--job-apply-url').hide();
2629                $('.cmb2-id--job-apply-email').hide();
2630                $('.cmb2-id--job-phone').hide();
2631            } else if ( apply_type == 'external' ) {
2632                $('.cmb2-id--job-apply-url').show();
2633                $('.cmb2-id--job-apply-email').hide();
2634                $('.cmb2-id--job-phone').hide();
2635            } else if ( apply_type == 'with_email' ) {
2636                $('.cmb2-id--job-apply-url').hide();
2637                $('.cmb2-id--job-phone').hide();
2638                $('.cmb2-id--job-apply-email').show();
2639            } else if ( apply_type == 'call' ) {
2640                $('.cmb2-id--job-apply-url').hide();
2641                $('.cmb2-id--job-apply-email').hide();
2642                $('.cmb2-id--job-phone').show();
2643            }
2644            $('#_job_apply_type').change(function(){
2645                var apply_type = $(this).val();
2646                if ( apply_type == 'internal' ) {
2647                    $('.cmb2-id--job-apply-url').hide();
2648                    $('.cmb2-id--job-apply-email').hide();
2649                    $('.cmb2-id--job-phone').hide();
2650                } else if ( apply_type == 'external' ) {
2651                    $('.cmb2-id--job-apply-url').show();
2652                    $('.cmb2-id--job-apply-email').hide();
2653                    $('.cmb2-id--job-phone').hide();
2654                } else if ( apply_type == 'with_email' ) {
2655                    $('.cmb2-id--job-apply-url').hide();
2656                    $('.cmb2-id--job-phone').hide();
2657                    $('.cmb2-id--job-apply-email').show();
2658                } else if ( apply_type == 'call' ) {
2659                    $('.cmb2-id--job-apply-url').hide();
2660                    $('.cmb2-id--job-apply-email').hide();
2661                    $('.cmb2-id--job-phone').show();
2662                }
2663            });
2664            var price_type = $('#_service_price_type').val();
2665            if ( price_type == 'package' ) {
2666                $('.cmb-row.cmb2-id--service-price').hide();
2667                $('.cmb-row.cmb2-id--service-price-packages').show();
2668            } else {
2669                $('.cmb-row.cmb2-id--service-price').show();
2670                $('.cmb-row.cmb2-id--service-price-packages').hide();
2671            }
2672            $('#_service_price_type').change(function(){
2673                var price_type = $(this).val();
2674                if ( price_type == 'package' ) {
2675                    $('.cmb-row.cmb2-id--service-price').hide();
2676                    $('.cmb-row.cmb2-id--service-price-packages').show();
2677                } else {
2678                    $('.cmb-row.cmb2-id--service-price').show();
2679                    $('.cmb-row.cmb2-id--service-price-packages').hide();
2680                }
2681            });
2682        },
2683        filterListing: function() {
2684            var self = this;
2685
2686            $(document).on('click', 'form .toggle-field .heading-label', function(){
2687                var container = $(this).closest('.form-group');
2688                container.find('.form-group-inner').slideToggle();
2689                if ( container.hasClass('hide-content') ) {
2690                    container.removeClass('hide-content');
2691                } else {
2692                    container.addClass('hide-content');
2693                }
2694            });
2695            $(document).on('click', '.toggle-filter-list', function() {
2696                var $this = $(this);
2697                var container = $(this).closest('.form-group');
2698                container.find('.terms-list .more-fields').each(function(){
2699                    if ( $(this).hasClass('active') ) {
2700                        $(this).removeClass('active');
2701                        $this.find('.text').text(wp_freeio_opts.show_more);
2702                    } else {
2703                        $(this).addClass('active');
2704                        $this.find('.text').text(wp_freeio_opts.show_less);
2705                    }
2706                });
2707            });
2708
2709            if ( $.isFunction( $.fn.slider ) ) {
2710                $('.search-distance-slider').each(function(){
2711                    var $this = $(this);
2712                    var search_distance = $this.closest('.search-distance-wrapper').find('input[name^=filter-distance]');
2713                    var search_wrap = $this.closest('.search_distance_wrapper');
2714                    $(this).slider({
2715                        range: "min",
2716                        value: search_distance.val(),
2717                        min: 0,
2718                        max: 100,
2719                        slide: function( event, ui ) {
2720                            search_distance.val( ui.value );
2721                            $('.text-distance', search_wrap).text( ui.value );
2722                            $('.distance-custom-handle', $this).attr( "data-value", ui.value );
2723                            search_distance.trigger('change');
2724                        },
2725                        create: function() {
2726                            $('.distance-custom-handle', $this).attr( "data-value", $( this ).slider( "value" ) );
2727                        }
2728                    } );
2729                } );
2730
2731                $('.main-range-slider').each(function(){
2732                    var $this = $(this);
2733                    $this.slider({
2734                        range: true,
2735                        min: $this.data('min'),
2736                        max: $this.data('max'),
2737                        values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ],
2738                        slide: function( event, ui ) {
2739                            $this.parent().find('.from-text').text( ui.values[ 0 ] );
2740                            $this.parent().find('.filter-from').val( ui.values[ 0 ] )
2741                            $this.parent().find('.to-text').text( ui.values[ 1 ] );
2742                            $this.parent().find('.filter-to').val( ui.values[ 1 ] );
2743                            $this.parent().find('.filter-to').trigger('change');
2744                        }
2745                    } );
2746                });
2747
2748                $('.salary-range-slider').each(function(){
2749                    var $this = $(this);
2750                    $this.slider({
2751                        range: true,
2752                        min: $this.data('min'),
2753                        max: $this.data('max'),
2754                        values: [ $this.parent().find('.filter-from').val(), $this.parent().find('.filter-to').val() ],
2755                        slide: function( event, ui ) {
2756                            $this.parent().find('.from-text .price-text').text( self.addCommas(ui.values[ 0 ]) );
2757                            $this.parent().find('.filter-from').val( ui.values[ 0 ] )
2758                            $this.parent().find('.to-text .price-text').text( self.addCommas(ui.values[ 1 ]) );
2759                            $this.parent().find('.filter-to').val( ui.values[ 1 ] );
2760                            $this.parent().find('.filter-to').trigger('change');
2761                        }
2762                    } );
2763                });
2764            }
2765
2766            $('.find-me').on('click', function() {
2767                $(this).addClass('loading');
2768                var this_e = $(this);
2769                var container = $(this).closest('.form-group');
2770
2771                navigator.geolocation.getCurrentPosition(function (position) {
2772                    container.find('input[name="filter-center-latitude"]').val(position.coords.latitude);
2773                    container.find('input[name="filter-center-longitude"]').val(position.coords.longitude);
2774                    container.find('input[name="filter-center-location"]').val('Location');
2775                    container.find('.clear-location').removeClass('hidden');
2776                    container.find('.leaflet-geocode-container').html('').removeClass('active');
2777                    var position = [position.coords.latitude, position.coords.longitude];
2778
2779                    if ( typeof L.esri.Geocoding.geocodeService != 'undefined' ) {
2780                    
2781                        var geocodeService = L.esri.Geocoding.geocodeService();
2782                        geocodeService.reverse().latlng(position).run(function(error, result) {
2783                            container.find('input[name="filter-center-location"]').val(result.address.Match_addr);
2784                        });
2785                    }
2786
2787                    return this_e.removeClass('loading');
2788                }, function (e) {
2789                    return this_e.removeClass('loading');
2790                }, {
2791                    enableHighAccuracy: true
2792                });
2793            });
2794
2795            $('.clear-location').on('click', function() {
2796                var container = $(this).closest('.form-group');
2797
2798                container.find('input[name="filter-center-latitude"]').val('');
2799                container.find('input[name="filter-center-longitude"]').val('');
2800                container.find('input[name="filter-center-location"]').val('').trigger('keyup');
2801                container.find('.clear-location').addClass('hidden');
2802            });
2803            $('input[name="filter-center-location"]').on('keyup', function(){
2804                var container = $(this).closest('.form-group');
2805                var val = $(this).val();
2806                if ( $(this).val() !== '' ) {
2807                    container.find('.clear-location').removeClass('hidden');
2808                } else {
2809                    container.find('.clear-location').removeClass('hidden').addClass('hidden');
2810                }
2811            });
2812            
2813            // search autocomplete location
2814            if ( wp_freeio_opts.map_service == 'google-map' ) {
2815                if (typeof google === 'object' && typeof google.maps === 'object') {
2816                    function search_location_initialize() {
2817                        
2818                        $('input[name="filter-center-location"]').each(function(){
2819                            var $id = $(this).attr('id');
2820                            
2821                            if ( typeof $id !== 'undefined' ) {
2822                                var container = $('#'+$id).closest('.form-group-inner');
2823                                var input = document.getElementById($id);
2824                                var autocomplete = new google.maps.places.Autocomplete(input);
2825                                autocomplete.setTypes([]);
2826
2827                                if ( wp_freeio_opts.geocoder_country ) {
2828                                    autocomplete.setComponentRestrictions({
2829                                        country: [wp_freeio_opts.geocoder_country],
2830                                    });
2831                                }
2832
2833                                autocomplete.addListener( 'place_changed', function () {
2834                                    var place = autocomplete.getPlace();
2835                                    place.toString();
2836
2837                                    if (!place.geometry) {
2838                                        window.alert("No details available for input: '" + place.name + "'");
2839                                        return;
2840                                    }
2841
2842                                    container.find('input[name=filter-center-latitude]').val(place.geometry.location.lat());
2843                                    container.find('input[name=filter-center-longitude]').val(place.geometry.location.lng());
2844                                    
2845                                });
2846                            }
2847                        });
2848                    }
2849                    google.maps.event.addDomListener(window, 'load', search_location_initialize);
2850                }
2851            } else {
2852                if ( typeof L.Control.Geocoder.Nominatim != 'undefined' ) {
2853                    if ( wp_freeio_opts.geocoder_country ) {
2854                        var geocoder = new L.Control.Geocoder.Nominatim({
2855                            geocodingQueryParams: {countrycodes: wp_freeio_opts.geocoder_country, lang: wp_freeio_opts.geocoder_country}
2856                        });
2857                    } else {
2858                        var geocoder = new L.Control.Geocoder.Nominatim();
2859                    }
2860
2861                    function delay(fn, ms) {
2862                        let timer = 0
2863                        return function(...args) {
2864                            clearTimeout(timer)
2865                            timer = setTimeout(fn.bind(this, ...args), ms || 0)
2866                        }
2867                    }
2868
2869                    $("input[name=filter-center-location]").attr('autocomplete', 'off').after('<div class="leaflet-geocode
2869-container"></div>');
2870                    $("input[name=filter-center-location]").on("keyup", delay(function (e) {
2871                        var s = $(this).val(), $this = $(this), container = $(this).closest('.form-group-inner');
2872                        if (s && s.length >= 3) {
2873                            
2874                            $this.parent().addClass('loading');
2875                            geocoder.geocode(s, function(results) {
2876                                var output_html = '';
2877                                for (var i = 0; i < results.length; i++) {
2878                                    output_html += '<li class="result-item" data-latitude="'+results[i].center.lat+'" data-longitude="'+results[i].center.lng+'" ><i class="fa fa-map-marker" aria-hidden="true"></i> '+results[i].name+'</li>';
2879                                }
2880                                if ( output_html ) {
2881                                    output_html = '<ul>'+ output_html +'</ul>';
2882                                }
2883
2884                                container.find('.leaflet-geocode-container').html(output_html).addClass('active');
2885
2886                                var highlight_texts = s.split(' ');
2887
2888                                highlight_texts.forEach(function (item) {
2889                                    container.find('.leaflet-geocode-container').highlight(item);
2890                                });
2891
2892                                $this.parent().removeClass('loading');
2893                            });
2894                        } else {
2895                            container.find('.leaflet-geocode-container').html('').removeClass('active');
2896                        }
2897                    }, 500));
2898                    $('.form-group-inner').on('click', '.leaflet-geocode-container ul li', function() {
2899                        var container = $(this).closest('.form-group-inner');
2900                        container.find('input[name=filter-center-latitude]').val($(this).data('latitude'));
2901                        container.find('input[name=filter-center-longitude]').val($(this).data('longitude'));
2902                        container.find('input[name=filter-center-location]').val($(this).text());
2903                        container.find('.leaflet-geocode-container').removeClass('active').html('');
2904                    });
2905                }
2906            }
2907
2908        },
2909        employerAddEmployee: function() {
2910            var self = this;
2911            
2912            // add
2913            $(document).on('submit', 'form.employer-add-employees-form', function(e) {
2914                e.preventDefault();
2915                var $this = $(this);
2916                if ( $this.hasClass('loading') ) {
2917                    return false;
2918                }
2919                $this.addClass('loading');
2920                $.ajax({
2921                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_employer_add_employee' ),
2922                    type:'POST',
2923                    dataType: 'json',
2924                    data: $this.serialize() + '&action=wp_freeio_ajax_employer_add_employee'
2925                }).done(function(data) {
2926                    $this.removeClass('loading');
2927                    if ( data.status ) {
2928                        $('.employer-employees-list-inner').prepend(data.html);
2929                        if ( $('.employer-employees-list-inner .not-found').length ) {
2930                            $('.employer-employees-list-inner .not-found').remove();
2931                        }
2932                        $this.find('.team-employee-inner').remove();
2933                    }
2934                    self.showMessage(data.msg, data.status);
2935                });
2936                return false;
2937            });
2938            // remove
2939            $(document).on('click', '.btn-employer-remove-employee', function() {
2940                var $this = $(this);
2941                var r = confirm( wp_freeio_opts.rm_item_txt );
2942                if ( r == true ) {
2943                    $this.addClass('loading');
2944                    var employee_id = $(this).data('employee_id');
2945                    var nonce = $(this).data('nonce');
2946                    $.ajax({
2947                        url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_employer_remove_employee' ),
2948                        type:'POST',
2949                        dataType: 'json',
2950                        data: {
2951                            'employee_id': employee_id,
2952                            'nonce': nonce,
2953                            'action': 'wp_freeio_ajax_employer_remove_employee',
2954                        }
2955                    }).done(function(data) {
2956                        $this.removeClass('loading');
2957                        if ( data.status ) {
2958                            $this.closest('article.employee-team-wrapper').remove();
2959                        }
2960                        self.showMessage(data.msg, data.status);
2961                    });
2962                }
2963            });
2964        },
2965        inviteFreelancer: function() {
2966            var self = this;
2967            
2968            $(document).on('click', '.cannot-download-cv-btn', function() {
2969                var msg = $(this).data('msg');
2970                self.showMessage(msg, false);
2971            });
2972            $('.btn-invite-freelancer:not(.cannot-download-cv-btn)').magnificPopup({
2973                mainClass: 'apus-mfp-zoom-in',
2974                type:'inline',
2975                midClick: true
2976            });
2977
2978            // add
2979            $(document).on('submit', 'form.invite-freelancer-form', function(e) {
2980                e.preventDefault();
2981                var $this = $(this);
2982                if ( $this.hasClass('loading') ) {
2983                    return false;
2984                }
2985                if ( self.inviteAjax ) {
2986                    self.inviteAjax.abort();
2987                }
2988
2989                $this.find('.alert').remove();
2990                $this.addClass('loading');
2991                self.inviteAjax = $.ajax({
2992                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_invite_freelancer' ),
2993                    type:'POST',
2994                    dataType: 'json',
2995                    data: $this.serialize()
2996                }).done(function(data) {
2997                    $this.removeClass('loading');
2998
2999                    if ( data.status ) {
3000                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3001                    } else {
3002                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3003                    }
3004
3005                    self.inviteAjax = false;
3006                });
3007                return false;
3008            });
3009        },
3010        statementPayout: function() {
3011            var self = this;
3012
3013            $(document).on('submit', 'form.payouts-withdraw-settings-form', function(e) {
3014                e.preventDefault();
3015                var $this = $(this);
3016                if ( $this.hasClass('loading') ) {
3017                    return false;
3018                }
3019                if ( self.inviteAjax ) {
3020                    self.inviteAjax.abort();
3021                }
3022
3023                $this.find('.alert').remove();
3024                $this.addClass('loading');
3025                self.inviteAjax = $.ajax({
3026                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_save_withdraw_settings' ),
3027                    type:'POST',
3028                    dataType: 'json',
3029                    data: $this.serialize()
3030                }).done(function(data) {
3031                    $this.removeClass('loading');
3032
3033                    if ( data.status ) {
3034                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3035                    } else {
3036                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3037                    }
3038
3039                    self.inviteAjax = false;
3040                });
3041                return false;
3042            });
3043
3044            $(document).on('submit', 'form.withdraw-form', function(e) {
3045                e.preventDefault();
3046                var $this = $(this);
3047                if ( $this.hasClass('loading') ) {
3048                    return false;
3049                }
3050                if ( self.inviteAjax ) {
3051                    self.inviteAjax.abort();
3052                }
3053
3054                $this.find('.alert').remove();
3055                $this.addClass('loading');
3056                self.inviteAjax = $.ajax({
3057                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_save_withdraw' ),
3058                    type:'POST',
3059                    dataType: 'json',
3060                    data: $this.serialize()
3061                }).done(function(data) {
3062                    $this.removeClass('loading');
3063
3064                    if ( data.status ) {
3065                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3066                        setTimeout(function(){
3067                            window.location.reload(true);
3068                        }, 2000);
3069                    } else {
3070                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3071                    }
3072
3073                    self.inviteAjax = false;
3074                });
3075                return false;
3076            });
3077        },
3078        dispute: function() {
3079            var self = this;
3080            $(document).on('submit', 'form.create-dispute-form', function(e) {
3081                e.preventDefault();
3082                var $this = $(this);
3083                if ( $this.hasClass('loading') ) {
3084                    return false;
3085                }
3086                if ( self.disputeAjax ) {
3087                    self.disputeAjax.abort();
3088                }
3089
3090                $this.find('.alert').remove();
3091                $this.addClass('loading');
3092                self.disputeAjax = $.ajax({
3093                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_save_dispute' ),
3094                    type:'POST',
3095                    dataType: 'json',
3096                    data: $this.serialize()
3097                }).done(function(data) {
3098                    $this.removeClass('loading');
3099
3100                    if ( data.status ) {
3101                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3102                        setTimeout(function(){
3103                            window.location.reload(true);
3104                        }, 2000);
3105                    } else {
3106                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3107                    }
3108
3109                    self.disputeAjax = false;
3110                });
3111                return false;
3112            });
3113
3114            $(document).on('submit', 'form.dispute-message-form', function(){
3115                var $this = $(this);
3116
3117                if ( self.disputeMessageAjax ) {
3118                    self.disputeMessageAjax.abort();
3119                }
3120
3121                if ( $this.hasClass('loading') ) {
3122                    return false;
3123                }
3124
3125                var form_id = $(this).attr('id');
3126                
3127                $this.find('.alert').remove();
3128
3129                $this.addClass('loading');
3130                var form_data = new FormData( $('#' + form_id)[0] );
3131                
3132                self.disputeMessageAjax = $.ajax({
3133                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_send_dispute_message' ),
3134                    type:'POST',
3135                    dataType: 'json',
3136                    data: form_data,
3137                    processData: false,
3138                    contentType: false,
3139                }).done(function(data) {
3140                    $this.removeClass('loading');
3141                    
3142                    if ( data.status ) {
3143                        if ( data.html ) {
3144                            $('.messages-list').html(data.html);
3145
3146                            $(".list-replies").scrollTop( $( ".list-replies" ).prop( "scrollHeight" ) );
3147
3148                            $this.trigger("reset");
3149                        }
3150                    }
3151                    self.showMessage(data.msg, data.status);
3152
3153                    self.disputeMessageAjax = false;
3154                });
3155
3156                return false;
3157            });
3158        },
3159        mixesFn: function() {
3160            var self = this;
3161            
3162            $( '.my-jobs-ordering' ).on( 'change', 'select.orderby', function() {
3163                $( this ).closest( 'form' ).submit();
3164            });
3165
3166            $('.contact-form-wrapper').on('submit', function(){
3167                var $this = $(this);
3168                $this.find('.alert').remove();
3169                $this.addClass('loading');
3170                $.ajax({
3171                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_contact_form' ),
3172                    type:'POST',
3173                    dataType: 'json',
3174                    data: $this.serialize() + '&action=wp_freeio_ajax_contact_form'
3175                }).done(function(data) {
3176                    $this.removeClass('loading');
3177                    if ( data.status ) {
3178                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3179                    } else {
3180                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3181                    }
3182                });
3183
3184                return false;
3185            });
3186
3187            $(document).on( 'submit', 'form.delete-profile-form', function() {
3188                var $this = $(this);
3189                $this.addClass('loading');
3190                $(this).find('.alert').remove();
3191                $.ajax({
3192                    url: wp_freeio_opts.ajaxurl,
3193                    type:'POST',
3194                    dataType: 'json',
3195                    data: $this.serialize() + '&action=wp_freeio_ajax_delete_profile'
3196                }).done(function(data) {
3197                    $this.removeClass('loading');
3198                    if ( data.status ) {
3199                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3200                        window.location.href = wp_freeio_opts.home_url;
3201                    } else {
3202                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3203                    }
3204                });
3205
3206                return false;
3207            });
3208
3209            $('.cannot-download-cv-btn').on('click', function(e) {
3210                e.preventDefault();
3211                self.showMessage($(this).data('msg'), false);
3212            });
3213
3214            // Location Change
3215            $('body').on('change', 'select.select-field-region', function(){
3216                var val = $(this).val();
3217                var next = $(this).data('next');
3218                var main_select = 'select.select-field-region' + next;
3219                if ( $(main_select).length > 0 ) {
3220                    
3221                    var select2_args = wp_freeio_select2_opts;
3222                        select2_args['allowClear'] = true;
3223                        select2_args['minimumResultsForSearch'] = 10;
3224                        select2_args['width'] = '100%';
3225
3226                    if ( typeof wp_freeio_select2_opts.language_result !== 'undefined' ) {
3227                        select2_args['language'] = {
3228                            noResults: function(){
3229                                return wp_freeio_select2_opts.language_result;
3230                            }
3231                        };
3232                    }
3233
3234                    $(main_select).prop('disabled', true);
3235                    $(main_select).val('').trigger('change');
3236
3237                    if ( val ) {
3238                        $(main_select).parent().addClass('loading');
3239                        $.ajax({
3240                            url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wpjb_process_change_location' ),
3241                            type:'POST',
3242                            dataType: 'json',
3243                            data:{
3244                                'action': 'wpjb_process_change_location',
3245                                'parent': val,
3246                                'taxonomy': $(main_select).data('taxonomy'),
3247                                'security': wp_freeio_opts.ajax_nonce,
3248                            }
3249                        }).done(function(data) {
3250                            $(main_select).parent().removeClass('loading');
3251                            
3252                            $(main_select).find('option').remove();
3253                            if ( data ) {
3254                                $.each(data, function(i, item) {
3255                                    var option = new Option(item.name, item.id, true, true);
3256                                    $(main_select).append(option);
3257                                });
3258                            }
3259                            $(main_select).prop("disabled", false);
3260                            $(main_select).val(null).select2("destroy").select2(select2_args);
3261                        });
3262                    } else {
3263                        $(main_select).find('option').remove();
3264                        $(main_select).prop("disabled", false);
3265                        $(main_select).val(null).select2("destroy").select2(select2_args);
3266                    }
3267                }
3268            });
3269
3270            // remove notify
3271            $('.notifications-wrapper').on('click', '.remove-notify-btn', function(e) {
3272                e.stopPropagation();
3273                var $this = $(this);
3274                
3275                $this.addClass('loading');
3276                var unique_id = $(this).data('id');
3277                var nonce = $(this).data('nonce');
3278                $.ajax({
3279                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_remove_notify' ),
3280                    type:'POST',
3281                    dataType: 'json',
3282                    data: {
3283                        'unique_id': unique_id,
3284                        'nonce': nonce,
3285                    }
3286                }).done(function(data) {
3287                    $this.removeClass('loading');
3288                    if ( data.status ) {
3289                        if ( $this.closest('ul').find('li').length > 1 ) {
3290                            $this.closest('li').remove();
3291                        } else {
3292                            window.location.reload(true);
3293                        }
3294                    }
3295                    self.showMessage(data.msg, data.status);
3296                });
3297
3298            });
3299
3300            // currencies
3301            $('body').on('change', '.jobs-currencies input', function(){
3302                $(this).closest('form').trigger('submit');
3303            });
3304
3305            // Report
3306            $(document).on('submit', 'form.report-form-wrapper', function(e) {
3307                e.preventDefault();
3308                var $this = $(this);
3309                if ( $this.hasClass('loading') ) {
3310                    return false;
3311                }
3312                if ( self.reportAjax ) {
3313                    self.reportAjax.abort();
3314                }
3315
3316                $this.find('.alert').remove();
3317                $this.addClass('loading');
3318                self.reportAjax = $.ajax({
3319                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_report_form' ),
3320                    type:'POST',
3321                    dataType: 'json',
3322                    data: $this.serialize()
3323                }).done(function(data) {
3324                    $this.removeClass('loading');
3325
3326                    if ( data.status ) {
3327                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3328                    } else {
3329                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3330                    }
3331
3332                    self.reportAjax = false;
3333                });
3334                return false;
3335            });
3336
3337            // Verify
3338            $(document).on('submit', 'form.verification-identity-form', function(){
3339                var $this = $(this);
3340
3341                if ( self.verifyAjax ) {
3342                    self.verifyAjax.abort();
3343                }
3344
3345                if ( $this.hasClass('loading') ) {
3346                    return false;
3347                }
3348
3349                var form_id = $(this).attr('id');
3350                
3351                
3352                $this.find('.alert').remove();
3353
3354                $this.addClass('loading');
3355                var form_data = new FormData( $('#' + form_id)[0] );
3356                
3357                self.verifyAjax = $.ajax({
3358                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_verification_identity' ),
3359                    type:'POST',
3360                    dataType: 'json',
3361                    data: form_data,
3362                    processData: false,
3363                    contentType: false,
3364                }).done(function(data) {
3365                    $this.removeClass('loading');
3366                    if ( data.status ) {
3367                        $this.prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3368                        setTimeout(function(){
3369                            window.location.reload(true);
3370                        }, 500);
3371                    } else {
3372                        $this.prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3373                    }
3374
3375                    self.verifyAjax = false;
3376                });
3377                
3378                return false;
3379            });
3380
3381            // revoke rerify
3382            $(document).on('click', '.revoke-verification', function(){
3383                var $this = $(this);
3384
3385                if ( self.verifyAjax ) {
3386                    self.verifyAjax.abort();
3387                }
3388
3389                if ( $this.hasClass('loading') ) {
3390                    return false;
3391                }
3392                
3393                $this.parent().find('.alert').remove();
3394
3395                $this.addClass('loading');
3396                self.verifyAjax = $.ajax({
3397                    url: wp_freeio_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'wp_freeio_ajax_revoke_verification_identity' ),
3398                    type:'POST',
3399                    dataType: 'json',
3400                    processData: false,
3401                    contentType: false,
3402                }).done(function(data) {
3403                    $this.removeClass('loading');
3404                    if ( data.status ) {
3405                        $this.parent().prepend( '<div class="alert alert-info">'+data.msg+'</div>' );
3406                        setTimeout(function(){
3407                            window.location.reload(true);
3408                        }, 500);
3409                    } else {
3410                        $this.parent().prepend( '<div class="alert alert-warning">'+data.msg+'</div>' );
3411                    }
3412
3413                    self.verifyAjax = false;
3414                });
3415                
3416                return false;
3417            });
3418        },
3419        addCommas: function(str) {
3420            var parts = (str + "").split("."),
3421                main = parts[0],
3422                len = main.length,
3423                output = "",
3424                first = main.charAt(0),
3425                i;
3426            
3427            if (first === '-') {
3428                main = main.slice(1);
3429                len = main.length;    
3430            } else {
3431                first = "";
3432            }
3433            i = len - 1;
3434            while(i >= 0) {
3435                output = main.charAt(i) + output;
3436                if ((len - i) % 3 === 0 && i > 0) {
3437                    output = wp_freeio_opts.money_thousands_separator + output;
3438                }
3439                --i;
3440            }
3441            // put sign back
3442            output = first + output;
3443            // put decimal part back
3444            if (parts.length > 1) {
3445                output += wp_freeio_opts.money_dec_point + parts[1];
3446            }
3447            return output;
3448        },
3449        showMessage: function(msg, status) {
3450            if ( msg ) {
3451                var classes = 'alert bg-warning';
3452                if ( status ) {
3453                    classes = 'alert bg-info';
3454                }
3455                var $html = '<div id="wp-freeio-popup-message" class="animated fadeInRight"><div class="message-inner '+ classes +'">'+ msg +'</div></div>';
3456                $('body').find('#wp-freeio-popup-message').remove();
3457                $('body').append($html).fadeIn(500);
3458                setTimeout(function() {
3459                    $('body').find('#wp-freeio-popup-message').removeClass('fadeInRight').addClass('delay-2s fadeOutRight');
3460                }, 2500);
3461            }
3462        },
3463        setCookie: function(cname, cvalue, exdays) {
3464            var d = new Date();
3465            d.setTime(d.getTime() + (exdays*24*60*60*1000));
3466            var expires = "expires="+d.toUTCString();
3467            document.cookie = cname + "=" + cvalue + "; " + expires+";path=/";
3468        },
3469        getCookie: function(cname) {
3470            var name = cname + "=";
3471            var ca = document.cookie.split(';');
3472            for(var i=0; i<ca.length; i++) {
3473                var c = ca[i];
3474                while (c.charAt(0)==' ') c = c.substring(1);
3475                if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
3476            }
3477            return "";
3478        },
3479    }
3480
3481    $.wpfiMainCore = WJBPMainCore.prototype;
3482    
3483    $(document).ready(function() {
3484        // Initialize script
3485        new WJBPMainCore();
3486
3487    });
3488    
3489})(jQuery);
3490

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.