PageSourceSearch

https://thescholarjobline.com/wp-content/plugins/wp-jobsearch/js/jobsearch-plugin.js?ver=3.2.3

js thescholarjobline.com collected 2026-10-04 12:58:26 UTC 110,056 bytes, 2,772 lines download raw bytes

1(function ($) {
2    $.fn.jobsearch_seliz_req_field_loop = function (callback, thisArg) {
3        var me = this;
4        return this.each(function (index, element) {
5            return callback.call(thisArg || element, element, index, me);
6        });
7    };
8})(jQuery);
9
10function jobsearch_validate_seliz_req_form(that) {
11    var req_class = 'selectize-req-field',
12        _this_form = jQuery(that),
13        form_validity = 'valid';
14    var errors_counter = 1;
15    _this_form.find('select.' + req_class).jobsearch_seliz_req_field_loop(function (element, index, set) {
16        var ret_err = '0';
17        if (jQuery(element).val() == '') {
18            form_validity = 'invalid';
19            ret_err = '1';
20        } else {
21            jQuery(element).parents('.jobsearch-profile-select').css({"border": "none"});
22        }
23
24        if (ret_err == '1') {
25            jQuery(element).parents('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
26            var animate_to = jQuery(element).parents('.jobsearch-profile-select');
27
28            if (errors_counter == 1) {
29                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 70}, 1000);
30            }
31
32            errors_counter++;
33        }
34    });
35    if (form_validity == 'valid') {
36        return true;
37    } else {
38        return false;
39    }
40}
41
42function jobsearch_js_call_user_func(cb, parameters) {  
43    var func;  
44   
45    if (typeof cb == 'string') {  
46        if (typeof this[cb] == 'function') {  
47            func = this[cb];  
48        } else {  
49            func = (new Function(null, 'return ' + cb))();  
50        }  
51    } else if (cb instanceof Array) {  
52        func = eval(cb[0]+"['"+cb[1]+"']");  
53    }
54      
55    if (typeof func != 'function') {
56        throw new Exception(func + ' is not a valid function');  
57    }
58
59    //parameters value should be an array - if no parameter then give an empty parameter like this []
60    return func.apply(null, parameters);  
61}
62
63jQuery(document).on('click', '.jobsearch-add-job-to-favourite', function () {
64    var _this = jQuery(this);
65    console.info(_this);
66    var this_id = _this.attr('data-id');
67    var this_view = _this.attr('data-view');
68    var after_label = _this.attr('data-after-label');
69    var before_icon = _this.attr('data-before-icon');
70    var after_icon = _this.attr('data-after-icon');
71    var this_loader = _this.find('i');
72    var msg_con = _this.parent('div').find('.job-to-fav-msg-con');
73
74    this_loader.attr('class', 'fa fa-refresh fa-spin');
75
76    var shortlist_view = 'job';
77    if (typeof this_view !== 'undefined' && this_view !== '') {
78        shortlist_view = this_view;
79    }
80    var request = jQuery.ajax({
81        url: jobsearch_plugin_vars.ajax_url,
82        method: "POST",
83        data: {
84            job_id: this_id,
85            _nonce: jobsearch_comon_script_vars.nonce,
86            action: 'jobsearch_add_candidate_job_to_favourite',
87        },
88        dataType: "json"
89    });
90
91    request.done(function (response) {
92        if (typeof response.error !== 'undefined' && response.error == '1') {
93            msg_con.html(response.msg);
94            this_loader.attr('class', before_icon);
95            return false;
96        }
97        if (typeof response.msg !== 'undefined' && response.msg != '' && shortlist_view == 'job') {
98            this_loader.attr('class', after_icon);
99            _this.removeClass('jobsearch-add-job-to-favourite');
100        }
101        if (typeof response.msg !== 'undefined' && response.msg != '' && shortlist_view == 'job2') {
102            var htm = after_label;
103            _this.empty();
104            _this.html(htm);
105            _this.removeClass('jobsearch-add-job-to-favourite');
106        }
107
108        if (typeof response.msg !== 'undefined' && response.msg != '' && shortlist_view == 'job3') {
109            //this_loader.attr('class', after_icon);
110            var htm = '<i class=" '+after_icon+' "></i> '+after_label+' ';
111            _this.empty();
112            _this.html(htm);
113            _this.removeClass('jobsearch-add-job-to-favourite');
114        }
115        if (typeof response.msg !== 'undefined' && response.msg != '' && shortlist_view == 'style9') {
116            //this_loader.attr('class', after_icon);
117            var htm = '<i class=" '+after_icon+' "></i> '+after_label+' ';
118            _this.empty();
119            _this.html(htm);
120            _this.removeClass('jobsearch-add-job-to-favourite');
121        }
122
123    });
124
125    request.fail(function (jqXHR, textStatus) {
126        this_loader.attr('class', before_icon);
127    });
128});
129
130function jobsearch_validate_cprofile_req_form(that) {
131    var req_class = 'jobsearch-cpreq-field',
132        _this_form = jQuery(that),
133        form_validity = 'valid';
134    var errors_counter = 1;
135    _this_form.find('.' + req_class).jobsearch_seliz_req_field_loop(function (element, index, set) {
136        var ret_err = '0';
137        if (jQuery(element).val() == '' || jQuery(element).val() == null) {
138            form_validity = 'invalid';
139            ret_err = '1';
140        } else {
141            jQuery(element).css({"border": "1px solid #eceeef"});
142        }
143
144        if (ret_err == '1') {
145            if ($(element).hasClass('multiselect-req')) {
146                element = $(element).parents('.jobsearch-profile-select');
147            }
148            jQuery(element).css({"border": "1px solid #ff0000"});
149            var animate_to = jQuery(element);
150
151            if (errors_counter == 1) {
152                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 70}, 1000);
153            }
154
155            errors_counter++;
156        } else {
157            if ($(element).hasClass('multiselect-req')) {
158                element = $(element).parents('.jobsearch-profile-select');
159                $(element).removeAttr('style');
160            }
161        }
162    });
163    if (form_validity == 'valid') {
164        return true;
165    } else {
166        return false;
167    }
168}
169
170var jobsearch_custm_getJSON = function (url, callback) {
171    var xhr = new XMLHttpRequest();
172    xhr.open('GET', url, true);
173    xhr.responseType = 'json';
174    xhr.onload = function () {
175        var status = xhr.status;
176        if (status === 200) {
177            callback(null, xhr.response);
178        } else {
179            callback(status, xhr.response);
180        }
181    };
182    xhr.send();
183};
184
185function jobsearch_get_date_to_num_str(date) {
186    var ext_date = date.toLocaleDateString("en-US");
187    var ext_date_arr = ext_date.split('/');
188    
189    var date_whole_str = date;
190    if (ext_date_arr.length == 3) {
191        var date_str = ext_date_arr[1];
192        var month_str = ext_date_arr[0];
193        var year_str = ext_date_arr[2];
194        
195        var date_w = parseInt(date_str) > 9 ? date_str : '0' + date_str;
196        var month_w = parseInt(month_str) > 9 ? month_str : '0' + month_str;
197        
198        date_whole_str = date_w + '-' + month_w + '-' + year_str;
199    } 
200    
201    return date_whole_str;
202}
203
204jQuery(document).on('click', '.jobsearch-top-searchbar input[type="submit"]', function () {
205    var select_sector = jQuery('.jobsearch-top-searchbar select[name="sector_cat"]');
206    var filter_selectd_sec = jQuery('input[name="sector_cat"]:checked');
207    if (select_sector.length > 0 && filter_selectd_sec.length > 0) {
208        if (select_sector.val() != '') {
209            filter_selectd_sec.prop('checked', false);
210        }
211    }
212});
213
214function jobsearch_cusfield_validate_attach_field(con_form) {
215    var att_error = 0;
216    var attach_file = con_form.find('input[type="file"]');
217
218    jQuery(attach_file).each(function (elem, index) {
219        var _this_file = jQuery(this);
220        if (_this_file.val() == '' && _this_file.hasClass('jobsearch-cusfieldatt-req')) {
221            att_error = 1;
222            _this_file.parent('.jobsearch-fileUpload').css({"border": "1px solid #ff0000"});
223        } else {
224            _this_file.parent('.jobsearch-fileUpload').css({"border": "none"});
225        }
226        if (att_error == 1) {
227            jQuery('html, body').animate({scrollTop: _this_file.parent('.jobsearch-fileUpload').offset().top - 130}, 1000);
228            return false;
229        }
230    });
231    if (att_error == 0) {
232        return true;
233    } else {
234        return false;
235    }
236}
237
238jQuery(document).on('submit', 'form#employer-profilesetings-form', function () {
239    var this_form = jQuery(this);
240    var phone_field = this_form.find('input[name="user_phone"]');
241    if (phone_field.hasClass('phone-input-error')) {
242        jQuery('html, body').animate({scrollTop: phone_field.offset().top - 130}, 1000);
243        return false;
244    }
245    // API Locations
246    var locations_type = jobsearch_plugin_vars.locations_type;
247    var is_req_apilocs = jobsearch_plugin_vars.required_api_locs;
248
249    if (locations_type == 'api' && is_req_apilocs == 'yes') {
250        var api_loc_contry = jQuery('select[name="jobsearch_field_location_location1"]');
251        if (api_loc_contry.length > 0) {
252            var api_locval = api_loc_contry.val();
253            if (api_locval == '') {
254                api_loc_contry.parent('.jobsearch-profile-select').css({"border": "1p
254x solid #ff0000"});
255                var animate_to = api_loc_contry.parent('.jobsearch-profile-select');
256                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
257                return false;
258            } else {
259                api_loc_contry.parent('.jobsearch-profile-select').css({"border": "none"});
260            }
261        }
262        var api_loc_state = jQuery('select[name="jobsearch_field_location_location2"]');
263        if (api_loc_state.length > 0) {
264            var api_locval = api_loc_state.val();
265            if (api_locval == '') {
266                api_loc_state.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
267                var animate_to = api_loc_state.parent('.jobsearch-profile-select');
268                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
269                return false;
270            } else {
271                api_loc_state.parent('.jobsearch-profile-select').css({"border": "none"});
272            }
273        }
274        var api_loc_cities = jQuery('select[name="jobsearch_field_location_location3"]');
275        if (api_loc_cities.length > 0) {
276            var api_locval = api_loc_cities.val();
277            if (api_locval == '') {
278                api_loc_cities.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
279                var animate_to = api_loc_cities.parent('.jobsearch-profile-select');
280                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
281                return false;
282            } else {
283                api_loc_cities.parent('.jobsearch-profile-select').css({"border": "none"});
284            }
285        }
286    }
287    //
288
289    var user_sector_field = jQuery('select[name^="user_sector"]');
290    if (user_sector_field.length > 0 && user_sector_field.hasClass('profile-req-field')) {
291        var user_sector_val = user_sector_field.val();
292        if (user_sector_val == '') {
293            user_sector_field.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
294            var animate_to = user_sector_field.parent('.jobsearch-profile-select');
295            jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
296            return false;
297        } else {
298            user_sector_field.parent('.jobsearch-profile-select').removeAttr('style');
299        }
300    }
301
302    var editor_text_field = jQuery('.jobsearch-reqtext-editor');
303    if (editor_text_field.length > 0) {
304        var text_editr_err = false;
305        editor_text_field.each(function () {
306            var _this_field = jQuery(this);
307            var element_to_err = jQuery(_this_field).parents('.wp-editor-container');
308            if (_this_field.val() == '') {
309                text_editr_err = element_to_err;
310                jQuery(element_to_err).css({"border": "1px solid #ff0000"});
311            } else {
312                jQuery(element_to_err).removeAttr('style');
313            }
314        });
315        if (text_editr_err !== false) {
316            jQuery('html, body').animate({scrollTop: text_editr_err.offset().top - 70}, 1000);
317            return false;
318        }
319    }
320
321    if (this_form.find('.cusfield-checkbox-required').find('input[type=checkbox]').length > 0) {
322        var element_to_go = this_form.find('.cusfield-checkbox-required');
323        var req_checkboxs = this_form.find('.cusfield-checkbox-required').find('input[type=checkbox]');
324        var req_checkbox_err = 1;
325        req_checkboxs.each(function () {
326            if (jQuery(this).is(':checked')) {
327                req_checkbox_err = 0;
328            }
329        });
330        if (req_checkbox_err == 1) {
331            jQuery(element_to_go).css({"border": "1px solid #ff0000"});
332            jQuery('html, body').animate({scrollTop: element_to_go.offset().top - 100}, 1000);
333            return false;
334        } else {
335            jQuery(element_to_go).removeAttr('style');
336        }
337    }
338
339    // For custom upload field
340    var $uplod_file_ret = jobsearch_cusfield_validate_attach_field(jQuery(this));
341    if ($uplod_file_ret == false) {
342        return false;
343    }
344    //
345    var fields_1 = jobsearch_validate_cprofile_req_form(jQuery(this));
346    if (!fields_1) {
347        return false;
348    }
349    var fields_2 = jobsearch_validate_seliz_req_form(jQuery(this));
350    if (!fields_2) {
351        return false;
352    }
353});
354
355jQuery(document).on('submit', 'form#candidate-profilesetings-form', function () {
356    var this_form = jQuery(this);
357    var phone_field = this_form.find('input[name="user_phone"]');
358    if (phone_field.hasClass('phone-input-error')) {
359        jQuery('html, body').animate({scrollTop: phone_field.offset().top - 130}, 1000);
360        return false;
361    }
362    // API Locations
363    var locations_type = jobsearch_plugin_vars.locations_type;
364    var is_req_apilocs = jobsearch_plugin_vars.required_api_locs;
365
366    if (locations_type == 'api' && is_req_apilocs == 'yes') {
367        var api_loc_contry = jQuery('select[name="jobsearch_field_location_location1"]');
368        if (api_loc_contry.length > 0) {
369            var api_locval = api_loc_contry.val();
370            if (api_locval == '') {
371                api_loc_contry.parent('.jobsearch-profile-select').css({"border": "1p
371x solid #ff0000"});
372                var animate_to = api_loc_contry.parent('.jobsearch-profile-select');
373                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
374                return false;
375            } else {
376                api_loc_contry.parent('.jobsearch-profile-select').css({"border": "none"});
377            }
378        }
379        var api_loc_state = jQuery('select[name="jobsearch_field_location_location2"]');
380        if (api_loc_state.length > 0) {
381            var api_locval = api_loc_state.val();
382            if (api_locval == '') {
383                api_loc_state.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
384                var animate_to = api_loc_state.parent('.jobsearch-profile-select');
385                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
386                return false;
387            } else {
388                api_loc_state.parent('.jobsearch-profile-select').css({"border": "none"});
389            }
390        }
391        var api_loc_cities = jQuery('select[name="jobsearch_field_location_location3"]');
392        if (api_loc_cities.length > 0) {
393            var api_locval = api_loc_cities.val();
394            if (api_locval == '') {
395                api_loc_cities.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
396                var animate_to = api_loc_cities.parent('.jobsearch-profile-select');
397                jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
398                return false;
399            } else {
400                api_loc_cities.parent('.jobsearch-profile-select').css({"border": "none"});
401            }
402        }
403    }
404    //
405
406    var user_sector_field = jQuery('select[name^="user_sector"]');
407    if (user_sector_field.length > 0 && user_sector_field.hasClass('profile-req-field')) {
408        var user_sector_val = user_sector_field.val();
409        if (user_sector_val == '') {
410            user_sector_field.parent('.jobsearch-profile-select').css({"border": "1px solid #ff0000"});
411            var animate_to = user_sector_field.parent('.jobsearch-profile-select');
412            jQuery('html, body').animate({scrollTop: animate_to.offset().top - 110}, 1000);
413            return false;
414        } else {
415            user_sector_field.parent('.jobsearch-profile-select').removeAttr('style');
416        }
417    }
418
419    var editor_text_field = jQuery('.jobsearch-reqtext-editor');
420    if (editor_text_field.length > 0) {
421        var text_editr_err = false;
422        editor_text_field.each(function () {
423            var _this_field = jQuery(this);
424            var element_to_err = jQuery(_this_field).parents('.wp-editor-container');
425            if (_this_field.val() == '') {
426                text_editr_err = element_to_err;
427                jQuery(element_to_err).css({"border": "1px solid #ff0000"});
428            } else {
429                jQuery(element_to_err).removeAttr('style');
430            }
431        });
432        if (text_editr_err !== false) {
433            jQuery('html, body').animate({scrollTop: text_editr_err.offset().top - 70}, 1000);
434            return false;
435        }
436    }
437
438    if (this_form.find('.cusfield-checkbox-required').find('input[type=checkbox]').length > 0) {
439        var element_to_go = this_form.find('.cusfield-checkbox-required');
440        var req_checkboxs = this_form.find('.cusfield-checkbox-required').find('input[type=checkbox]');
441        var req_checkbox_err = 1;
442        req_checkboxs.each(function () {
443            if (jQuery(this).is(':checked')) {
444                req_checkbox_err = 0;
445            }
446        });
447        if (req_checkbox_err == 1) {
448            jQuery(element_to_go).css({"border": "1px solid #ff0000"});
449            jQuery('html, body').animate({scrollTop: element_to_go.offset().top - 100}, 1000);
450            return false;
451        } else {
452            jQuery(element_to_go).removeAttr('style');
453        }
454    }
455
456    // For custom upload field
457    var $uplod_file_ret = jobsearch_cusfield_validate_attach_field(jQuery(this));
458    if ($uplod_file_ret == false) {
459        return false;
460    }
461    //
462    var fields_1 = jobsearch_validate_cprofile_req_form(jQuery(this));
463    if (!fields_1) {
464        return false;
465    }
466    var fields_2 = jobsearch_validate_seliz_req_form(jQuery(this));
467    if (!fields_2) {
468        return false;
469    }
470});
471
472jQuery(function () {
473    if (jQuery('.jobsearch-tooltipcon').length > 0) {
474        jQuery('.jobsearch-tooltipcon').tooltip();
475    }
476});
477
478jQuery(document).on('click', '.jobsearch-activcode-popupbtn', function () {
479    jQuery('.jobsearch-modal').removeClass('fade-in').addClass('fade');
480    jQuery('body').removeClass('jobsearch-modal-active');
481    jobsearch_modal_popup_open('JobSearchModalAccountActivationForm');
482});
483
484jQuery(document).on('click', '.user-activeacc-submit-btn', function (e) {
485    e.preventDefault();
486    var this_form = jQuery('#jobsearch_uaccont_aprov_form');
487    var this_loader = this_form.find('.loader-box');
488    var this_msg_con = this_form.find('.message-opbox');
489
490    var activ_code = this_form.find('input[name="activ_code"]');
491    var user_email = this_form.find('input[name="user_email"]');
492
493    var error = 0;
494    if (activ_code.val() == '') {
495        error = 1;
496        activ_code.css({"border": "1px solid #ff0000"});
497    } else {
498        activ_code.css({"border": "1px solid #d3dade"});
499    }
500
501    if (error == 0) {
502
503        this_msg_con.hide();
504        this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
505        var request = jQuery.ajax({
506            url: jobsearch_plugin_vars.ajax_url,
507            method: "POST",
508            data: {
509                active_code: activ_code.val(),
510                user_email: user_email.val(),
511                _nonce: jobsearch_comon_script_vars.nonce,
512                action: 'jobsearch_activememb_accont_by_activation_url',
513            },
514            dataType: "json"
515        });
516
517        request.done(function (response) {
518            var msg_before = '';
519            var msg_after = '';
520            if (typeof response.error !== 'undefined') {
521                if (response.error == '1') {
522                    msg_before = '<div class="alert alert-danger"><i class="fa fa-times"></i> ';
523                    msg_after = '</div>';
524                } else if (response.error == '0') {
525                    msg_before = '<div class="alert alert-success"><i class="fa fa-check"></i> ';
526                    msg_after = '</div>';
527                }
528            }
529            if (typeof response.msg !== 'undefined') {
530                this_msg_con.html(msg_before + response.msg + msg_after);
531                this_msg_con.slideDown();
532                //if (typeof response.error !== 'undefined' && response.error == '0') {
533                //    this_form.find('ul.email-fields-list').slideUp();
534                //}
535                if (typeof response.redirect !== 'undefined') {
536                    window.location.href = response.redirect;
537                    return false;
538                }
539            } else {
540                this_msg_con.html(jobsearch_plugin_vars.error_msg);
541            }
542            this_loader.html('');
543
544        });
545
546        request.fail(function (jqXHR, textStatus) {
547            this_loader.html(jobsearch_plugin_vars.error_msg);
548        });
549    }
550});
551
552jQuery(document).on('click', '.jobsearch-candidatesh-opopupbtn', function () {
553    var _this_id = jQuery(this).attr('data-id');
554    if (jQuery('#JobSearchModalCandShPopup' + _this_id).length) {
555        jobsearch_modal_popup_open('JobSearchModalCandShPopup' + _this_id);
556    } else {
557        jQuery('#JobSearchModalCandShPopupGeneralCand').find('.jobsearch-svcand-withtyp-tolist').attr('data-id', _this_id);
558        jobsearch_modal_popup_open('JobSearchModalCandShPopupGeneralCand');
559    }
560});
561
562jQuery(document).on('click', '.div-to-scroll', function () {
563
564    var trag_todiv = jQuery(this).attr('data-target');
565    jQuery('html, body').animate({
566        scrollTop: jQuery('#' + trag_todiv).offset().top - 200
567    }, 1000);
568});
569
570var location_box = jQuery('input.srch_autogeo_location');
571
572function JobsearchGetClientLocation() {
573    if (navigator.geolocation) {
574        navigator.geolocation.getCurrentPosition(JobsearchShowClientPosition);
575    } else {
576        console.log("Geolocation is not supported by this browser.");
577    }
578}
579
580function JobsearchShowClientPosition(position) {
581    var lat = position.coords.latitude;
582    var lng = position.coords.longitude;
583
584    if (lat != '' && lng != '') {
585        var location_ajax_box = jQuery('.jobsearch_searchloc_div input[type=text]');
586        var icon_classs = jQuery('.geolction-btn').find('i').attr('class');
587        var pos = {
588            lat: lat,
589            lng: lng
590        };
591        jQuery('.geolction-btn').find('i').attr('class', 'fa fa-refresh fa-spin');
592        var dataString = "lat=" + pos.lat + "&lng=" + pos.lng + "&_nonce="+jobsearch_comon_script_vars.nonce+"&action=jobsearch_get_location_with_latlng";
593        jQuery.ajax({
594            type: "POST",
595            url: jobsearch_plugin_vars.ajax_url,
596            data: dataString,
597            dataType: "json",
598            success: function (response) {
599                if (location_box.length > 0) {
600                    location_box.val(response.address);
601                }
602                if (location_ajax_box.length > 0) {
603                    location_ajax_box.val(response.address);
604                }
605                jQuery('.geolction-btn').find('i').attr('class', icon_classs);
606                if (typeof jobsearch_listing_dataobj !== 'undefined') {
607                    var locMapType = jobsearch_plugin_vars.locmap_type;
608                    if (locMapType == 'mapbox') {
609                        var mapCordsToFly = [lng, lat];
610                        jobsearch_listing_map.flyTo({
611                            center: mapCordsToFly,
612                        });
613                    } else {
614                        jobsearch_listing_map.setCenter(pos);
615                    }
616                }
617            }
618        });
619    }
620}
621
622jQuery(document).ready(function () {
623
624    if (location_box.length > 0) {
625        //JobsearchGetClientLocation();
626    }
627    jQuery("body").fitVids();
628    
629    if (jQuery('select[name="sector_cat"]').length > 0) {
630        var sectr_selcts = jQuery('select[name="sector_cat"]');
631        sectr_selcts.each(function() {
632            var _this_sel = jQuery(this);
633            if (_this_sel.hasClass('selectize-select')) {
634                _this_sel.find('option:first').attr('value', '');
635            }
636        });
637    }
638    
639});
640
641jQuery(document).on('submit', 'form', function (er) {
642    var this_form = jQuery(this);
643    if (this_form.find('input[type="checkbox"][name="terms_cond_check"]').length > 0) {
644        var checkbox = this_form.find('input[type="checkbox"][name="terms_cond_check"]');
645        if (!checkbox.is(":checked")) {
646            er.preventDefault();
647            alert(jobsearch_plugin_vars.accpt_terms_cond);
648            var form_allow_subtn = setInterval(function () {
649                this_form.find('input[type=submit]').removeAttr('disabled');
650                this_form.find('input[type=submit]').removeClass('disabled-btn');
651                clearInterval(form_allow_subtn);
652            }, 500);
653            return false;
654        }
655    }
656});
657
658function jobsearch_accept_terms_cond_pop(this_form) {
659    if (this_form.find('input[type="checkbox"][name="terms_cond_check"]').length > 0) {
660        var checkbox = this_form.find('input[type="checkbox"][name="terms_cond_check"]');
661        if (!checkbox.is(":checked")) {
662            alert(jobsearch_plugin_vars.accpt_terms_cond);
663            return 'no';
664        }
665    }
666    return 'yes';
667}
668
669jQuery('#user-sector').find('option').first().val('');
670jQuery('#user-sector').attr('placeholder', jobsearch_plugin_vars.select_sector);
671jQuery('#job-sector').attr('placeholder', jobsearch_plugin_vars.select_sector);
672
673jQuery(window).on('load', function () {
674
675});
676
677jQuery(document).on('click', '.show-toggle-filter-list', function () {
678    var _this = jQuery(this);
679    var more_txt = jobsearch_plugin_vars.see_more_txt;
680    var less_txt = jobsearch_plugin_vars.see_less_txt;
681
682    if (_this.hasClass('jobsearch-loadmore-locations')) {
683
684        var this_loader = _this.find('.loc-filter-loder');
685        var this_appender = _this.parent('.jobsearch-checkbox-toggle').find('>ul');
686        var this_pnm = parseInt(_this.attr('data-pnum'));
687        var this_tpgs = parseInt(_this.attr('data-tpgs'));
688        var this_order = _this.attr('data-order');
689        var this_orderby = _this.attr('data-orderby');
690
691        var this_ptye = _this.attr('data-ptype');
692
693        var this_rid = _this.attr('data-rid');
694        var this_cousw = _this.attr('data-cousw');
695
696        var q_args_json = jQuery('input[name="loc_count_qargs_' + this_rid + '"]').val();
697
698        var to_action = 'jobsearch_load_more_filter_locs_to_list';
699        if (typeof this_ptye !== 'undefined' && this_ptye == 'employer') {
700            to_action = 'jobsearch_load_more_filter_emp_locs_to_list';
701        }
702        if (typeof this_ptye !== 'undefined' && this_ptye == 'candidate') {
703            to_action = 'jobsearch_load_more_filter_clocs_to_list';
704        }
705
706        this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
707
708        var request = jQuery.ajax({
709            url: jobsearch_plugin_vars.ajax_url,
710            method: "POST",
711            data: {
712                page_num: this_pnm,
713                t_pgs: this_tpgs,
714                param_rid: this_rid,
715                q_agrs: q_args_json,
716                param_cousw: this_cousw,
717                order: this_order,
718                orderby: this_orderby,
719                _nonce: jobsearch_comon_script_vars.nonce,
720                action: to_action,
721            },
722            dataType: "json"
723        });
724
725        request.done(function (response) {
726            if (typeof response.list !== 'undefined' && response.list != '') {
727                //
728                this_appender.append(response.list);
729                if (this_pnm < this_tpgs) {
730                    _this.attr('data-pnum', (this_pnm + 1));
731                } else {
732                    _this.remove();
733                }
734            }
735            this_loader.html('');
736        });
737
738        request.fail(function (jqXHR, textStatus) {
739            this_loader.html('');
740        });
741        return false;
742    }
743
744    var etarget = _this.prev('ul').find('li.filter-more-fields');
745    if (etarget.hasClass('f_showing')) {
746        etarget.hide();
747        _this.html(more_txt);
748        etarget.removeClass('f_showing');
749    } else {
750        etarget.show();
751        _this.html(less_txt);
752        etarget.addClass('f_showing');
753    }
754});
755
756function jobsearch_animate_slidein_open(target) {
757    jQuery('#' + target).removeClass('fade').addClass('fade-in');
758    jQuery('body').addClass('jobsearch-modal-active');
759}
760
761function jobsearch_modal_popup_open(target) {
762    jQuery('#' + target).removeClass('fade').addClass('fade-in');
763    jQuery('body').addClass('jobsearch-modal-active');
764}
765
766jQuery(document).on('click', '.jobsearch-modal .modal-close', function () {
767    jQuery('.jobsearch-modal').removeClass('fade-in').addClass('fade');
768    jQuery('body').removeClass('jobsearch-modal-active');
769});
770
771jQuery(document).on('mousedown', '.jobsearch-modal', function (e) {
772    //
773    var is_close = true;
774    var this_dom = e.target;
775    var thisdom_obj = jQuery(this_dom);
776    if (thisdom_obj.parents('.modal-box-area').length > 0) {
777        if (thisdom_obj.parent('.modal-close').length > 0) {
778            //console.log('close');
779        } else {
780            is_close = false;
781        }
782    }
783    // for calendar fix
784    if (thisdom_obj.hasClass('picker-day')) {
785        is_close = false;
786    }
787    // for selectize multi select remove button compatibility
788    if (thisdom_obj.parent('.item').length > 0 && thisdom_obj.hasClass('remove')) {
789        is_close = false;
790    }
791    if (is_close === true) {
792        jQuery('.jobsearch-modal').removeClass('fade-in').addClass('fade');
793        jQuery('body').removeClass('jobsearch-modal-active');
794    }
795});
796
797//for login popup
798jQuery(document).on('click', '.jobsearch-open-signin-tab', function () {
799    var _this = jQuery(this);
800    jobsearch_modal_popup_open('JobSearchModalLogin');
801    jQuery('.reg-tologin-btn').trigger('click');
802    // for redirect url
803    var login_form = jQuery('#JobSearchModalLogin').find('form[id^="login-form-"]');
804    if (_this.hasClass('jobsearch-wredirct-url')) {
805        var wredirct_url = _this.attr('data-wredircto');
806        var redrct_hiden_field = login_form.find('input[name="jobsearch_wredirct_url"]');
807        if (redrct_hiden_field.length > 0) {
808            redrct_hiden_field.remove();
809        }
810        login_form.append('<input type="hidden" name="jobsearch_wredirct_url" value="' + wredirct_url + '">');
811    } else {
812        var redrct_hiden_field = login_form.find('input[name="jobsearch_wredirct_url"]');
813        if (redrct_hiden_field.length > 0) {
814            redrct_hiden_field.remove();
815        }
816    }
817
818    // for packages
819    if (_this.hasClass('jobsearch-pkg-bouybtn')) {
820        var extra_login_info = [];
821        var this_pkg_id = _this.attr('data-id');
822
823        extra_login_info.push('buying_pkg');
824        extra_login_info.push(this_pkg_id);
825        if (typeof _this.attr('data-pinfo') !== 'undefined' && _this.attr('data-pinfo') != '') {
826            extra_login_info.push(_this.attr('data-pinfo'));
827        }
828
829        extra_login_info = extra_login_info.join('|');
830        var pkginfo_hiden_field = login_form.find('input[name="extra_login_params"]');
831        if (pkginfo_hiden_field.length > 0) {
832            pkginfo_hiden_field.remove();
833        }
834        login_form.append('<input type="hidden" name="extra_login_params" value="' + extra_login_info + '">');
835    } else {
836        var pkginfo_hiden_field = login_form.find('input[name="extra_login_params"]');
837        if (pkginfo_hiden_field.length > 0) {
838            pkginfo_hiden_field.remove();
839        }
840    }
841});
842
843//for register popup
844jQuery(document).on('click', '.jobsearch-open-register-tab', function () {
845
846    var _this = jQuery(this);
847    jobsearch_modal_popup_open('JobSearchModalLogin');
848    jQuery('.register-form').trigger('click');
849
850    var login_form = jQuery('#JobSearchModalLogin').find('form[id^="login-form-"]');
851    var register_form = jQuery('#JobSearchModalLogin').find('form[id^="registration-form-"]');
852
853    if (_this.hasClass('company-register-tab')) {
854        register_form.find('.user-type-chose-btn[data-type="jobsearch_employer"]').trigger('click');
855    }
856
857    // for redirect url
858    var redrct_hiden_field = login_form.find('input[name="jobsearch_wredirct_url"]');
859    if (redrct_hiden_field.length > 0) {
860        redrct_hiden_field.remove();
861    }
862
863    // for packages
864    var pkginfo_hiden_field = login_form.find('input[name="extra_login_params"]');
865    if (pkginfo_hiden_field.length > 0) {
866        pkginfo_hiden_field.remove();
867    }
868});
869
870//for email popup
871jQuery(document).on('click', '.jobsearch-send-email-popup-btn', function () {
872    jobsearch_modal_popup_open('JobSearchSendEmailModal');
873});
874
875jQuery(document).on('click', '.employer-followin-btnaction', function () {
876    var _this = jQuery(this);
877    var this_id = _this.attr('data-id');
878    var label_bfr = _this.attr('data-beforelbl');
879    var label_aftr = _this.attr('data-afterlbl');
880
881    if (!_this.hasClass('ajax-loading')) {
882        _this.addClass('ajax-loading');
883        _this.html('<i class="fa fa-refresh fa-spin"></i>');
884        var request = jQuery.ajax({
885            url: jobsearch_plugin_vars.ajax_url,
886            method: "POST",
887            data: {
888                emp_id: this_id,
889                label_bfr: label_bfr,
890                label_aftr: label_aftr,
891                _nonce: jobsearch_comon_script_vars.nonce,
892                action: 'jobsearch_add_employer_followin_to_list',
893            },
894            dataType: "json"
895        });
896        request.done(function (response) {
897            _this.html(response.label);
898            _this.removeClass('ajax-loading');
899            _this.removeClass('employer-followin-btnaction');
900            _this.addClass('employer-followed-already');
901        });
902
903        request.fail(function (jqXHR, textStatus) {
904            _this.html(label_bfr);
905            _this.removeClass('ajax-loading');
906        });
907    }
908});
909
910jQuery.jobsearch_confirm_popup = function (params) {
911    "use strict";
912    if (jQuery('#jobsearch-confirm-msg-popup').length > 0) {
913        jQuery('#jobsearch-confirm-msg-popup').remove();
914    }
915
916    var buttonHTML = '';
917    jQuery.each(params.buttons, function (name, obj) {
918
919        buttonHTML += '<a class="jobsearch-confirm-button jobsearch-link ' + obj['class'] + '">' + name + '</a>';
920
921        if (!obj.action) {
922            obj.action = function () {};
923        }
924    });
925
926    var markup = [
927        '<div id="jobsearch-confirm-msg-popup" class="jobsearch-modal-popup jobsearch-popup-visible jobsearch-confirmsg-modal jobsearch-modal jobsearch-typo-wrap fade-in">',
928        '<div class="modal-inner-area">&nbsp;</div>',
929        '<div class="modal-content-area">',
930        '<div class="modal-box-area">',
931        '<div class="jobsearch-emp-pkg-popup">',
932            '<p class="confrm-msg-txt">', params.message, '</p>',
933            '<div class="confirm-popup-btns jobsearch-emp-pkg-popup-btns">',
934            buttonHTML,
935            '</div>',
936            '<span>', params.title, '</span>',
937            '<small>', params.date, '</small>',
938        '</div></div></div></div>'
939    ].join('');
940
941    //console.log('params', params, markup)
942
943    jQuery(markup).appendTo('body');
944    jQuery('body').addClass('jobsearch-popup-active');
945
946    var buttons = jQuery('#jobsearch-confirm-msg-popup .jobsearch-confirm-button'),
947    i = 0;
948
949    jQuery.each(params.buttons, function (name, obj) {
950        buttons.eq(i++).on('click', function () {
951
952            obj.action();
953            return false;
954        });
955    });
956}
957
958jQuery.jobsearch_confirm_popup.hide = function () {
959    "use strict";
960    jobsearch_modal_popup_close();
961    jQuery('#jobsearch-confirm-msg-popup').remove();
962}
963
964function jobsearch_modal_popup_close() {
965    "use strict";
966    if (!jQuery('body').hasClass('jobsearch-popup-active')) {
967        jQuery('.jobsearch-modal-popup').removeClass('jobsearch-popup-visible').addClass('jobsearch-popup-hide');
968        //jQuery('.jobsearch-modal-popup').removeClass('fade-in').addClass('jobsearch-popup-hide');
969        jQuery('.jobsearch-modal-popup').find('.modal-box-area').html('<i class="fa fa-refresh fa-spin"></i>');
970        jQuery('body').removeClass('jobsearch-popup-active');
971        jQuery('.jobpro-modal-popup').remove();
972    }
973}
974
975jQuery(document).on('click', '.jobsearch-emp-unlockname', function () {
976    var _this = jQuery(this);
977    var this_id = _this.attr('data-id');
978    var data_style = _this.attr('data-style');
979    var this_loader = data_style != undefined && data_style == "true" ? jQuery(this).parent("figure").parent(".careerfy-candidate-style8-wrapper").find(".resume-loding-msg") : jQuery(this).next('.resume-loding-msg');
980
981    this_loader.show();
982    if (data_style != undefined && data_style == "true") {
983        _this.html('<i class="fa fa-refresh fa-spin"></i>');
984    } else {
985        //this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
986        _this.append('<i class="fa fa-refresh fa-spin"></i>');
987    }
988    var request = jQuery.ajax({
989        url: jobsearch_plugin_vars.ajax_url,
990        method: "POST",
991        data: {
992            candidate_id: this_id,
993            unlock_name: 1,
994            _nonce: jobsearch_comon_script_vars.nonce,
995            action: 'jobsearch_employer_order_list_add_candidate',
996        },
997        dataType: "json"
998    });
999    request.done(function (response) {
1000        _this.find('i').remove();
1001
1002        if (typeof response.error !== 'undefined' && response.error == '1') {
1003            _this.find('i').removeClass().addClass('fa fa-heart');
1004            this_loader.html(response.msg);
1005            setTimeout(function () {
1006                this_loader.slideUp(800);
1007            }, 3000);
1008            if (typeof response.pop_html !== undefined) {
1009                jQuery('body').append(response.pop_html);
1010            }
1011            return false;
1012        }
1013        if (typeof response.dbn !== 'undefined' && response.dbn != '') {
1014            _this.hide();
1015            _this.parent('.shortlisting-user-btn').hide();
1016            _this.parent('.shortlisting-user-btn').html(response.dbn).slideDown();
1017            if (typeof response.pop_html !== undefined) {
1018                jQuery('body').append(response.pop_html);
1019            }
1020            return false;
1021        }
1022        if (typeof response.msg !== 'undefined' && response.msg != '') {
1023            //this_loader.html(response.msg);
1024            _this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1025            _this.removeClass('jobsearch-add-resume-to-list');
1026        }
1027        window.location.reload();
1028    });
1029
1030    request.fail(function (jqXHR, textStatus) {
1031        _this.find('i').remove();
1032        this_loader.html(jobsearch_plugin_vars.error_msg);
1033    });         
1034
1035});
1036jQuery(document).on('click', '.jobsearch-unlock-candidate-name', function () {
1037    var _this = jQuery(this);
1038
1039    var user_id = _this.data('user_id');
1040    var candidate_id = _this.data('candidate_id');
1041    var data_style = _this.attr('data-style');
1042    var this_loader = data_style != undefined && data_style == "true" ? jQuery(this).parent("figure").parent(".careerfy-candidate-style8-wrapper").find(".resume-loding-msg") : jQuery(this).next('.resume-loding-msg');
1043
1044    this_loader.show();
1045    if (data_style != undefined && data_style == "true") {
1046        _this.html('<i class="fa fa-refresh fa-spin"></i>');
1047    } else {
1048        _this.append('<i class="fa fa-refresh fa-spin"></i>');
1049    }   
1050
1051    var request = jQuery.ajax({
1052        url: jobsearch_plugin_vars.ajax_url,
1053        method: "POST",
1054        data: {
1055            candidate_id: candidate_id,
1056            user_id: user_id,
1057            _nonce: jobsearch_comon_script_vars.nonce,
1058            action: 'jobsearch_unlock_candidate_name',
1059        },
1060        dataType: "json"
1061    });
1062    request.done(function (response) {
1063        _this.find('i').remove();
1064        if (typeof response.error !== 'undefined' && response.error == '1') {
1065            _this.find('i').remove();
1066            this_loader.html(response.msg);
1067            setTimeout(function () {
1068                this_loader.slideUp(800);
1069            }, 3000);
1070            if (typeof response.pop_html !== undefined) {
1071                jQuery('body').append(response.pop_html);
1072            }
1073            return false;
1074        }
1075        if (typeof response.dbn !== 'undefined' && response.dbn != '') {
1076
1077            _this.hide();
1078            _this.parent('.shortlisting-user-btn').hide();
1079            _this.parent('.shortlisting-user-btn').html(response.dbn).slideDown();
1080            if (typeof response.pop_html !== undefined) {
1081                jQuery('body').append(response.pop_html);
1082            }
1083            return false;
1084        }
1085        if (typeof response.msg !== 'undefined' && response.msg != '') {
1086            //this_loader.html(response.msg);
1087            //_this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1088            //_this.removeClass('jobsearch-add-resume-to-list');
1089        }
1090        //window.location.reload();
1091    });
1092
1093    request.fail(function (jqXHR, textStatus) {
1094        _this.find('i').remove();
1095        this_loader.html(jobsearch_plugin_vars.error_msg);
1096    });         
1097
1098});
1099
1100jQuery(document).on('click', '.jobsearch-emp-pkg-addpoints', function () {
1101    var _this = jQuery(this);
1102    var this_id = _this.attr('data-id');
1103    var download_cv = _this.attr('data-download');
1104    var data_style = _this.attr('data-style');
1105    var this_loader = data_style != undefined && data_style == "true" ? jQuery(this).parent("figure").parent(".careerfy-candidate-style8-wrapper").find(".resume-loding-msg") : jQuery(this).next('.resume-loding-msg');
1106
1107    this_loader.show();
1108    if (data_style != undefined && data_style == "true") {
1109        _this.html('<i class="fa fa-refresh fa-spin"></i>');
1110    } else {
1111        this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
1112    }
1113    var request = jQuery.ajax({
1114        url: jobsearch_plugin_vars.ajax_url,
1115        method: "POST",
1116        data: {
1117            candidate_id: this_id,
1118            download_cv: download_cv,
1119            _nonce: jobsearch_comon_script_vars.nonce,
1120            action: 'jobsearch_add_employer_resume_to_list',
1121        },
1122        dataType: "json"
1123    });
1124
1125    request.done(function (response) {
1126        if (typeof response.error !== 'undefined' && response.error == '1') {
1127            _this.find('i').removeClass().addClass('fa fa-heart');
1128            this_loader.html(response.msg);
1129            setTimeout(function () {
1130                this_loader.slideUp(800);
1131            }, 3000);
1132            if (typeof response.pop_html !== undefined) {
1133                jQuery('body').append(response.pop_html);
1134            }
1135            return false;
1136        }
1137        if (typeof response.dbn !== 'undefined' && response.dbn != '') {
1138            _this.hide();
1139            _this.parent('.shortlisting-user-btn').hide();
1140            _this.parent('.shortlisting-user-btn').html(response.dbn).slideDown();
1141            if (typeof response.pop_html !== undefined) {
1142                jQuery('body').append(response.pop_html);
1143            }
1144
1145            console.log(_this.parent('.shortlisting-user-btn').find('a'), _this.parent('.shortlisting-user-btn'), )
1146
1147            jQuery('.jobsearch-modal .shortlisting-user-btn').find('a').trigger('click');
1148
1149            setTimeout(() => {
1150                jQuery('.jobsearch-modal .modal-close').trigger('click');                
1151            }, 7000);
1152
1153            return false;
1154        }
1155        if (typeof response.msg !== 'undefined' && response.msg != '') {
1156            this_loader.html(response.msg);
1157            _this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1158            _this.removeClass('jobsearch-add-resume-to-list');
1159        }
1160        //window.location.reload();
1161    });
1162
1163    request.fail(function (jqXHR, textStatus) {
1164        this_loader.html(jobsearch_plugin_vars.error_msg);
1165    });
1166});
1167
1168
1169jQuery(document).on('click', '.jobsearch-add-resume-to-list', function () {
1170    var _this = jQuery(this);
1171    var this_id = _this.attr('data-id');
1172    var download_cv = _this.attr('data-download');
1173    var data_style = _this.attr('data-style');
1174    var this_loader = data_style != undefined && data_style == "true" ? jQuery(this).parent("figure").parent(".careerfy-candidate-style8-wrapper").find(".resume-loding-msg") : jQuery(this).next('.resume-loding-msg');
1175
1176    this_loader.show();
1177    if (data_style != undefined && data_style == "true") {
1178        _this.html('<i class="fa fa-refresh fa-spin"></i>');
1179    } else {
1180        this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
1181    }
1182    var request = jQuery.ajax({
1183        url: jobsearch_plugin_vars.ajax_url,
1184        method: "POST",
1185        data: {
1186            candidate_id: this_id,
1187            download_cv: download_cv,
1188            _nonce: jobsearch_comon_script_vars.nonce,
1189            action: 'jobsearch_add_employer_resume_to_list',
1190        },
1191        dataType: "json"
1192    });
1193
1194    request.done(function (response) {
1195        if (typeof response.error !== 'undefined' && response.error == '1') {
1196            _this.find('i').removeClass().addClass('fa fa-heart');
1197            this_loader.html(response.msg);
1198            setTimeout(function () {
1199                this_loader.slideUp(800);
1200            }, 3000);
1201            if (typeof response.pop_html !== undefined) {
1202                jQuery('body').append(response.pop_html);
1203            }
1204            return false;
1205        }
1206        if (typeof response.dbn !== 'undefined' && response.dbn != '') {
1207            _this.hide();
1208            _this.parent('.shortlisting-user-btn').hide();
1209            _this.parent('.shortlisting-user-btn').html(response.dbn).slideDown();
1210            if (typeof response.pop_html !== undefined) {
1211                jQuery('body').append(response.pop_html);
1212            }
1213            return false;
1214        }
1215        if (typeof response.msg !== 'undefined' && response.msg != '') {
1216            this_loader.html(response.msg);
1217            _this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1218            _this.removeClass('jobsearch-add-resume-to-list');
1219        }
1220        window.location.reload();
1221    });
1222
1223    request.fail(function (jqXHR, textStatus) {
1224        this_loader.html(jobsearch_plugin_vars.error_msg);
1225    });
1226});
1227
1228jQuery(document).on('click', '.jobsearch-svcand-withtyp-tolist', function () {
1229    var _this = jQuery(this);
1230    var this_id = _this.attr('data-id');
1231    var this_loader = jQuery(this).next('.resume-loding-msg');
1232
1233    var slected_prmain = _this.parents('#usercand-shrtlistsecs-' + this_id);
1234
1235    if (slected_prmain.length) {
1236        var type_selected = _this.parents('#usercand-shrtlistsecs-' + this_id).find('select[name^="shrtlist_type"]').val();
1237    } else {
1238        var type_selected = _this.parents('#usercand-shrtlistsecs-general-cand').find('select[name^="shrtlist_type"]').val();
1239    }
1240
1241    this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
1242    var request = jQuery.ajax({
1243        url: jobsearch_plugin_vars.ajax_url,
1244        method: "POST",
1245        data: {
1246            candidate_id: this_id,
1247            type_selected: type_selected,
1248            _nonce: jobsearch_comon_script_vars.nonce,
1249            action: 'jobsearch_add_employer_resume_to_list',
1250        },
1251        dataType: "json"
1252    });
1253
1254    request.done(function (response) {
1255        if (typeof response.error !== 'undefined' && response.error == '1') {
1256            //
1257            this_loader.html(response.msg);
1258            return false;
1259        }
1260        if (typeof response.msg !== 'undefined' && response.msg != '') {
1261            this_loader.html(response.msg);
1262            _this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1263            _this.removeClass('jobsearch-svcand-withtyp-tolist');
1264            window.location.reload(true);
1265        }
1266    });
1267
1268    request.fail(function (jqXHR, textStatus) {
1269        this_loader.html(jobsearch_plugin_vars.error_msg);
1270    });
1271});
1272
1273jQuery(document).on('click', '.jobsearch-updcand-withtyp-tolist', function () {
1274    var _this = jQuery(this);
1275    var this_id = _this.attr('data-id');
1276    var this_loader = jQuery(this).next('.resume-loding-msg');
1277
1278    var type_selected = _this.parents('#usercand-shrtlistsecs-' + this_id).find('select[name^="shrtlist_type"]').val();
1279
1280    this_loader.html('<i class="fa fa-refresh fa-spin"></i>');
1281    var request = jQuery.ajax({
1282        url: jobsearch_plugin_vars.ajax_url,
1283        method: "POST",
1284        data: {
1285            candidate_id: this_id,
1286            type_selected: type_selected,
1287            _nonce: jobsearch_comon_script_vars.nonce,
1288            action: 'jobsearch_upd_employer_resume_to_list',
1289        },
1290        dataType: "json"
1291    });
1292
1293    request.done(function (response) {
1294        if (typeof response.error !== 'undefined' && response.error == '1') {
1295            //
1296            this_loader.html(response.msg);
1297            return false;
1298        }
1299        if (typeof response.msg !== 'undefined' && response.msg != '') {
1300            this_loader.html(response.msg);
1301            _this.html('<i class="jobsearch-icon jobsearch-add-list"></i> ' + jobsearch_plugin_vars.shortlisted_str);
1302            _this.removeClass('jobsearch-svcand-withtyp-tolist');
1303            window.location.reload(true);
1304        }
1305    });
1306
1307    request.fail(function (jqXHR, textStatus) {
1308        this_loader.html(jobsearch_plugin_vars.error_msg);
1309    });
1310});
1311
1312jQuery(document).on('click', '.jobsearch-candidate-ct-form', function (e) {
1313    e.preventDefault();
1314    var this_id = jQuery(this).data('id'),
1315        msg_form = jQuery('#ct-form-' + this_id),
1316        ajax_url = jobsearch_plugin_vars.ajax_url,
1317        msg_con = msg_form.find('.jobsearch-ct-msg'),
1318        msg_name = msg_form.find('input[name="u_name"]'),
1319        msg_email = msg_form.find('input[name="u_email"]'),
1320        msg_phone = msg_form.find('input[name="u_number"]'),
1321        msg_txt = msg_form.find('textarea[name="u_msg"]'),
1322        user_id = msg_form.attr('data-uid'),
1323        error = 0;
1324
1325    var cand_ser_form = jQuery('#ct-form-' + this_id)[0];
1326
1327    var get_terr_val = jobsearch_accept_terms_cond_pop(msg_form);
1328    if (get_terr_val != 'yes') {
1329        return false;
1330    }
1331
1332    if (msg_form.find('.jobsearch-open-signin-tab').length > 0) {
1333        msg_form.find('.jobsearch-open-signin-tab').trigger('click');
1334        return false;
1335    }
1336
1337    var email_pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,20}$/i);
1338
1339    if (msg_name.val() == '') {
1340        error = 1;
1341        msg_name.css({"border": "1px solid #ff0000"});
1342    } else {
1343        msg_name.css({"border": "1px solid #efefef"});
1344    }
1345
1346    if (msg_email.val() == '') {
1347        error = 1;
1348        msg_email.css({"border": "1px solid #ff0000"});
1349    } else {
1350        if (!email_pattern.test(msg_email.val())) {
1351            error = 1;
1352            msg_email.css({"border": "1px solid #ff0000"});
1353        } else {
1354            msg_email.css({"border": "1px solid #efefef"});
1355        }
1356    }
1357
1358    if (msg_txt.val() == '') {
1359        error = 1;
1360        msg_txt.css({"border": "1px solid #ff0000"});
1361    } else {
1362        msg_txt.css({"border": "1px solid #efefef"});
1363    }
1364
1365    if (error == 0) {
1366        var formData = new FormData(cand_ser_form);
1367
1368        formData.append("u_candidate_id", user_id);
1369        formData.append("_nonce", jobsearch_comon_script_vars.nonce);
1370        formData.append("action", 'jobsearch_candidate_contact_form_submit');
1371
1372        msg_con.html('<em class="fa fa-refresh fa-spin"></em>');
1373        msg_con.show();
1374
1375        var request = jQuery.ajax({
1376            url: ajax_url,
1377            method: "POST",
1378            processData: false,
1379            contentType: false,
1380            data: formData,
1381            dataType: "json"
1382        });
1383
1384        request.done(function (response) {
1385            if (typeof response.msg !== 'undefined') {
1386                msg_name.val('');
1387                msg_email.val('');
1388                msg_phone.val('');
1389                msg_txt.val('');
1390                msg_con.html(response.msg);
1391            } else {
1392                msg_con.html(jobsearch_plugin_vars.error_msg);
1393            }
1394        });
1395
1396        request.fail(function (jqXHR, textStatus) {
1397            msg_con.html(jobsearch_plugin_vars.error_msg);
1398        });
1399    }
1400
1401    return false;
1402});
1403
1404jQuery(document).on('click', '.jobsearch-employer-ct-form', function (e) {
1405    e.preventDefault();
1406    var this_id = jQuery(this).data('id'),
1407        msg_form = jQuery('#ct-form-' + this_id),
1408        ajax_url = jobsearch_plugin_vars.ajax_url,
1409        msg_con = msg_form.find('.jobsearch-ct-msg'),
1410        msg_name = msg_form.find('input[name="u_name"]'),
1411        msg_email = msg_form.find('input[name="u_email"]'),
1412        msg_phone = msg_form.find('input[name="u_number"]'),
1413        msg_txt = msg_form.find('textarea[name="u_msg"]'),
1414        user_id = msg_form.attr('data-uid'),
1415        error = 0;
1416
1417    var emp_ser_form = jQuery('#ct-form-' + this_id)[0];
1418
1419    var get_terr_val = jobsearch_accept_terms_cond_pop(msg_form);
1420    if (get_terr_val != 'yes') {
1421        return false;
1422    }
1423
1424    if (msg_form.find('.jobsearch-open-signin-tab').length > 0) {
1425        msg_form.find('.jobsearch-open-signin-tab').trigger('click');
1426        return false;
1427    }
1428
1429    var email_pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,20}$/i);
1430
1431    if (msg_name.val() == '') {
1432        error = 1;
1433        msg_name.css({"border": "1px solid #ff0000"});
1434    } else {
1435        msg_name.css({"border": "1px solid #efefef"});
1436    }
1437
1438    if (msg_email.val() == '') {
1439        error = 1;
1440        msg_email.css({"border": "1px solid #ff0000"});
1441    } else {
1442        if (!email_pattern.test(msg_email.val())) {
1443            error = 1;
1444            msg_email.css({"border": "1px solid #ff0000"});
1445        } else {
1446            msg_email.css({"border": "1px solid #efefef"});
1447        }
1448    }
1449
1450    if (msg_txt.val() == '') {
1451        error = 1;
1452        msg_txt.css({"border": "1px solid #ff0000"});
1453    } else {
1454        msg_txt.css({"border": "1px solid #efefef"});
1455    }
1456
1457    if (error == 0) {
1458
1459        var formData = new FormData(emp_ser_form);
1460
1461        formData.append("u_employer_id", user_id);
1462        formData.append("_nonce", jobsearch_comon_script_vars.nonce);
1463        formData.append("action", 'jobsearch_employer_contact_form_submit');
1464
1465        msg_con.html('<em class="fa fa-refresh fa-spin"></em>');
1466        msg_con.show();
1467
1468        var request = jQuery.ajax({
1469            url: ajax_url,
1470            method: "POST",
1471            processData: false,
1472            contentType: false,
1473            data: formData,
1474            dataType: "json"
1475        });
1476
1477        request.done(function (response) {
1478            if (typeof response.msg !== 'undefined') {
1479                msg_name.val('');
1480                msg_email.val('');
1481                msg_phone.val('');
1482                msg_txt.val('');
1483                msg_con.html(response.msg);
1484            } else {
1485                msg_con.html(jobsearch_plugin_vars.error_msg);
1486            }
1487        });
1488
1489        request.fail(function (jqXHR, textStatus) {
1490            msg_con.html(jobsearch_plugin_vars.error_msg);
1491        });
1492    }
1493
1494    return false;
1495});
1496
1497jQuery(document).on('click', '.send-job-email-btn', function () {
1498    jQuery('form#jobsearch_send_to_email_form').submit();
1499});
1500
1501jQuery('form#jobsearch_send_to_email_form').on('submit', function (e) {
1502    e.preventDefault();
1503    var _form = jQuery(this);
1504    var submit_btn = _form.find('.send-job-email-btn');
1505    var msg_con = _form.find('.send-email-msg-box');
1506    var loader_con = _form.find('.send-email-loader-box');
1507    var uemail = _form.find('input[name="send_email_to"]');
1508    var usubject = _form.find('input[name="send_email_subject"]');
1509    var msg = _form.find('textarea[name="send_email_content"]');
1510    var form_data = _form.serialize() + '&_nonce=' + jobsearch_comon_script_vars.nonce;
1511
1512    var get_terr_val = jobsearch_accept_terms_cond_pop(_form);
1513    if (get_terr_val != 'yes') {
1514        return false;
1515    }
1516
1517    var email_pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,20}$/i);
1518
1519    var e_error = 0;
1520    if (msg.val() == '') {
1521        msg.css({"border": "1px solid #ff0000"});
1522        e_error = 1;
1523    }
1524    if (uemail.val() == '' || !email_pattern.test(uemail.val())) {
1525        uemail.css({"border": "1px solid #ff0000"});
1526        e_error = 1;
1527    }
1528    if (usubject.val() == '') {
1529        usubject.css({"border": "1px solid #ff0000"});
1530        e_error = 1;
1531    }
1532
1533    if (e_error == 1) {
1534        return false;
1535    }
1536
1537    if (!submit_btn.hasClass('jobsearch-loading')) {
1538        msg.css({"border": "1px solid #eceeef"});
1539        uemail.css({"border": "1px solid #eceeef"});
1540        usubject.css({"border": "1px solid #eceeef"});
1541        //
1542        submit_btn.addClass('jobsearch-loading');
1543        msg_con.hide();
1544        loader_con.show();
1545        loader_con.html('<i class="fa fa-refresh fa-spin"></i>');
1546        var request = jQuery.ajax({
1547            url: jobsearch_plugin_vars.ajax_url,
1548            method: "POST",
1549            data: form_data,
1550            dataType: "json"
1551        });
1552
1553        request.done(function (response) {
1554            if ('undefined' !== typeof response.msg && response.msg != '') {
1555                msg_con.html(response.msg);
1556                msg_con.slideDown();
1557            }
1558            if ('undefined' !== typeof response.error && response.error == '1') {
1559                msg_con.removeClass('alert-success').addClass('alert-danger');
1560            } else {
1561                msg_con.removeClass('alert-danger').addClass('alert-success');
1562            }
1563            submit_btn.removeClass('jobsearch-loading');
1564            loader_con.hide();
1565            loader_con.html('');
1566        });
1567
1568        request.fail(function (jqXHR, textStatus) {
1569            submit_btn.removeClass('jobsearch-loading');
1570            loader_con.hide();
1571            loader_con.html('');
1572        });
1573    }
1574
1575    return false;
1576});
1577
1578function jobsearchReplaceAll(str, find, replace) {
1579    return str.replace(new RegExp(find, 'g'), replace);
1580}
1581
1582jQuery(document).on('click', '.jobsearch-applyjob-fb-btn', function () {
1583    var _this = jQuery(this);
1584    var this_id = _this.attr('data-id');
1585    var this_loader = _this.find('i');
1586
1587    var this_msg_con = _this.parents('ul').next('.apply-msg');
1588
1589    this_loader.attr('class', 'fa fa-refresh fa-spin');
1590    var request = jQuery.ajax({
1591        url: jobsearch_plugin_vars.ajax_url,
1592        method: "POST",
1593        data: {
1594            job_id: this_id,
1595            _nonce: jobsearch_comon_script_vars.nonce,
1596            action: 'jobsearch_applying_job_with_facebook',
1597        },
1598        dataType: "json"
1599    });
1600
1601    request.done(function (response) {
1602
1603        if (typeof response.msg !== 'undefined' && response.msg != '') {
1604            this_loader.attr('class', 'jobsearch-icon jobsearch-facebook-logo-1');
1605            this_msg_con.html(response.msg);
1606            this_msg_con.show();
1607            return false;
1608        }
1609        if (typeof response.redirect_url !== 'undefined' && response.redirect_url != '') {
1610            var red_url = jobsearchReplaceAll(response.redirect_url, '#038;', '');
1611            window.location.href = red_url;
1612        } else {
1613            this_loader.attr('class', 'jobsearch-icon jobsearch-facebook-logo-1');
1614        }
1615    });
1616
1617    request.fail(function (jqXHR, textStatus) {
1618        this_loader.attr('class', 'jobsearch-icon jobsearch-facebook-logo-1');
1619    });
1620});
1621
1622jQuery(document).on('click', '.jobsearch-applyjob-linkedin-btn', function () {
1623    var _this = jQuery(this);
1624    var this_id = _this.attr('data-id');
1625    var this_loader = _this.find('i');
1626
1627    var this_msg_con = _this.parents('ul').next('.apply-msg');
1628
1629    this_loader.attr('class', 'fa fa-refresh fa-spin');
1630    var request = jQuery.ajax({
1631        url: jobsearch_plugin_vars.ajax_url,
1632        method: "POST",
1633        data: {
1634            job_id: this_id,
1635            _nonce: jobsearch_comon_script_vars.nonce,
1636            action: 'jobsearch_applying_job_with_linkedin',
1637        },
1638        dataType: "json"
1639    });
1640
1641    request.done(function (response) {
1642
1643        if (typeof response.msg !== 'undefined' && response.msg != '') {
1644            this_loader.attr('class', 'jobsearch-icon jobsearch-linkedin-logo');
1645            this_msg_con.html(response.msg);
1646            this_msg_con.show();
1647            return false;
1648        }
1649        if (typeof response.redirect_url !== 'undefined' && response.redirect_url != '') {
1650            var red_url = jobsearchReplaceAll(response.redirect_url, '#038;', '');
1651            window.location.href = red_url;
1652        } else {
1653            this_loader.attr('class', 'jobsearch-icon jobsearch-linkedin-logo');
1654        }
1655    });
1656
1657    request.fail(function (jqXHR, textStatus) {
1658        this_loader.attr('class', 'jobsearch-icon jobsearch-linkedin-logo');
1659    });
1660});
1661
1662jQuery(document).on('click', '.jobsearch-applyjob-google-btn', function () {
1663    var _this = jQuery(this);
1664    var this_id = _this.attr('data-id');
1665    var this_loader = _this.find('i');
1666
1667    var this_msg_con = _this.parents('ul').next('.apply-msg');
1668
1669    this_loader.attr('class', 'fa fa-refresh fa-spin');
1670    var request = jQuery.ajax({
1671        url: jobsearch_plugin_vars.ajax_url,
1672        method: "POST",
1673        data: {
1674            job_id: this_id,
1675            _nonce: jobsearch_comon_script_vars.nonce,
1676            action: 'jobsearch_applying_job_with_google',
1677        },
1678        dataType: "json"
1679    });
1680
1681    request.done(function (response) {
1682
1683        if (typeof response.msg !== 'undefined' && response.msg != '') {
1684            this_loader.attr('class', 'fa fa-google-plus');
1685            this_msg_con.html(response.msg);
1686            this_msg_con.show();
1687            return false;
1688        }
1689        if (typeof response.redirect_url !== 'undefined' && response.redirect_url != '') {
1690            var red_url = jobsearchReplaceAll(response.redirect_url, '#038;', '');
1691            window.location.href = red_url;
1692        } else {
1693            this_loader.attr('class', 'fa fa-google-plus');
1694        }
1695    });
1696
1697    request.fail(function (jqXHR, textStatus) {
1698        this_loader.attr('class', 'fa fa-google-plus');
1699    });
1700});
1701
1702jQuery(document).on('click', '.jobsearch-applyjob-twitter-btn', function () {
1703    var _this = jQuery(this);
1704    var this_id = _this.attr('data-id');
1705    var this_loader = _this.find('i');
1706
1707    var this_msg_con = _this.parents('ul').next('.apply-msg');
1708
1709    this_loader.attr('class', 'fa fa-refresh fa-spin');
1710    var request = jQuery.ajax({
1711        url: jobsearch_plugin_vars.ajax_url,
1712        method: "POST",
1713        data: {
1714            job_id: this_id,
1715            _nonce: jobsearch_comon_script_vars.nonce,
1716            action: 'jobsearch_applying_job_with_twitter',
1717        },
1718        dataType: "json"
1719    });
1720
1721    request.done(function (response) {
1722
1723        if (typeof response.msg !== 'undefined' && response.msg != '') {
1724            this_loader.attr('class', 'careerfy-icon careerfy-twitter');
1725            this_msg_con.html(response.msg);
1726            this_msg_con.show();
1727            return false;
1728        }
1729        if (typeof response.redirect_url !== 'undefined' && response.redirect_url != '') {
1730            var red_url = jobsearchReplaceAll(response.redirect_url, '#038;', '');
1731            window.location.href = red_url;
1732        } else {
1733            this_loader.attr('class', 'careerfy-icon careerfy-twitter');
1734        }
1735    });
1736
1737    request.fail(function (jqXHR, textStatus) {
1738        this_loader.attr('class', 'careerfy-icon careerfy-twitter');
1739    });
1740});
1741
1742jQuery(document).on('click', '.jobsearch-applyjob-xing-btn', function () {
1743    var _this = jQuery(this);
1744    var this_id = _this.attr('data-id');
1745    var this_loader = _this.find('i');
1746
1747    var this_msg_con = _this.parents('ul').next('.apply-msg');
1748
1749    this_loader.attr('class', 'fa fa-refresh fa-spin');
1750    var request = jQuery.ajax({
1751        url: jobsearch_plugin_vars.ajax_url,
1752        method: "POST",
1753        data: {
1754            job_id: this_id,
1755            _nonce: jobsearch_comon_script_vars.nonce,
1756            action: 'jobsearch_applying_job_with_xing',
1757        },
1758        dataType: "json"
1759    });
1760
1761    request.done(function (response) {
1762
1763        if (typeof response.msg !== 'undefined' && response.msg != '') {
1764            this_loader.attr('class', 'fa fa-xing');
1765            this_msg_con.html(response.msg);
1766            this_msg_con.show();
1767            return false;
1768        }
1769        if (typeof response.redirect_url !== 'undefined' && response.redirect_url != '') {
1770            var red_url = jobsearchReplaceAll(response.redirect_url, '#038;', '');
1771            window.location.href = red_url;
1772        } else {
1773            this_loader.attr('class', 'fa fa-xing');
1774        }
1775    });
1776
1777    request.fail(function (jqXHR, textStatus) {
1778        this_loader.attr('class', 'fa fa-xing');
1779    });
1780});
1781
1782jQuery(document).on('click', '.employer-access-btn', function () {
1783    jQuery('.employer-access-msg').slideDown();
1784});
1785//for Download resume shortlist popup
1786jQuery(document).on('click', '.jobsearch-open-dloadres-popup', function () {
1787    var _this_id = jQuery(this).attr('data-id');
1788    jobsearch_modal_popup_open('JobSearchDLoadResModal' + _this_id);
1789});
1790
1791//
1792//
1793jQuery('.location_location1').on('change', function (e) {
1794    e.preventDefault();
1795    var this_id = jQuery(this).data('randid'),
1796        nextfieldelement = jQuery(this).data('nextfieldelement'),
1797        nextfieldval = jQuery(this).data('nextfieldval'),
1798        ajax_url = jobsearch_plugin_vars.ajax_url,
1799        location_location1 = jQuery('#location_location1_' + this_id),
1800        location_location2 = jQuery('#location_location2_' + this_id);
1801    jQuery('.location_location2_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
1802    var request = jQuery.ajax({
1803        url: ajax_url,
1804        method: "POST",
1805        data: {
1806            location_location: location_location1.val(),
1807            nextfieldelement: nextfieldelement,
1808            nextfieldval: nextfieldval,
1809            _nonce: jobsearch_comon_script_vars.nonce,
1810            action: 'jobsearch_location_load_location2_data',
1811        },
1812        dataType: "json"
1813    });
1814
1815    request.done(function (response) {
1816        if ('undefined' !== typeof response.html) {
1817            location_location2.html(response.html);
1818            jQuery('.location_location2_' + this_id).html('');
1819            if (nextfieldval != '') {
1820                jQuery('.location_location2').trigger('change');
1821            }
1822        }
1823    });
1824
1825    request.fail(function (jqXHR, textStatus) {
1826    });
1827    return false;
1828
1829});
1830
1831jQuery('.location_location2').on('change', function (e) {
1832    e.preventDefault();
1833    var this_id = jQuery(this).data('randid'),
1834        nextfieldelement = jQuery(this).data('nextfieldelement'),
1835        nextfieldval = jQuery(this).data('nextfieldval'),
1836        ajax_url = jobsearch_plugin_vars.ajax_url,
1837        location_location2 = jQuery('#location_location2_' + this_id),
1838        location_location3 = jQuery('#location_location3_' + this_id);
1839    jQuery('.location_location3_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
1840    var request = jQuery.ajax({
1841        url: ajax_url,
1842        method: "POST",
1843        data: {
1844            location_location: location_location2.val(),
1845            nextfieldelement: nextfieldelement,
1846            nextfieldval: nextfieldval,
1847            _nonce: jobsearch_comon_script_vars.nonce,
1848            action: 'jobsearch_location_load_location2_data',
1849        },
1850        dataType: "json"
1851    });
1852
1853    request.done(function (response) {
1854        if ('undefined' !== typeof response.html) {
1855            location_location3.html(response.html);
1856            jQuery('.location_location3_' + this_id).html('');
1857            if (nextfieldval != '') {
1858                jQuery('.location_location3').trigger('change');
1859            }
1860        }
1861    });
1862
1863    request.fail(function (jqXHR, textStatus) {
1864    });
1865    return false;
1866
1867});
1868
1869jQuery('.location_location3').on('change', function (e) {
1870    e.preventDefault();
1871    var this_id = jQuery(this).data('randid'),
1872        nextfieldelement = jQuery(this).data('nextfieldelement'),
1873        nextfieldval = jQuery(this).data('nextfieldval'),
1874        ajax_url = jobsearch_plugin_vars.ajax_url,
1875        location_location3 = jQuery('#location_location3_' + this_i
1875d),
1876        location_location4 = jQuery('#location_location4_' + this_id);
1877    jQuery('.location_location4_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
1878    var request = jQuery.ajax({
1879        url: ajax_url,
1880        method: "POST",
1881        data: {
1882            location_location: location_location3.val(),
1883            nextfieldelement: nextfieldelement,
1884            nextfieldval: nextfieldval,
1885            _nonce: jobsearch_comon_script_vars.nonce,
1886            action: 'jobsearch_location_load_location2_data',
1887        },
1888        dataType: "json"
1889    });
1890
1891    request.done(function (response) {
1892        if ('undefined' !== typeof response.html) {
1893            location_location4.html(response.html);
1894            jQuery('.location_location4_' + this_id).html('');
1895        }
1896    });
1897
1898    request.fail(function (jqXHR, textStatus) {
1899    });
1900    return false;
1901
1902});
1903
1904
1905jQuery('.location_location1_ccus').on('change', function (e) {
1906    e.preventDefault();
1907    var this_id = jQuery(this).attr('data-randid'),
1908        nextfieldelement = jQuery(this).attr('data-nextfieldelement'),
1909        nextfieldval = jQuery(this).attr('data-nextfieldval'),
1910        ajax_url = jobsearch_plugin_vars.ajax_url,
1911        location_location1 = jQuery('#location_location1_' + this_id),
1912        location_location2 = jQuery('#location_location2_cus_' + this_i
1912d);
1913    jQuery('.location_location2_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
1914    var request = jQuery.ajax({
1915        url: ajax_url,
1916        method: "POST",
1917        data: {
1918            randid: this_id,
1919            location_location: location_location1.val(),
1920            nextfieldelement: nextfieldelement,
1921            nextfieldval: nextfieldval,
1922            _nonce: jobsearch_comon_script_vars.nonce,
1923            action: 'jobsearch_location_load_cusloc2_data',
1924        },
1925        dataType: "json"
1926    });
1927
1928    request.done(function (response) {
1929        if ('undefined' !== typeof response.html) {
1930            location_location2.html(response.html);
1931            location_location2.find('select').selectize();
1932            jQuery('.location_location2_' + this_id).html('');
1933            if (nextfieldval != '') {
1934                jQuery('.location_location2').trigger('change');
1935            }
1936        }
1937    });
1938
1939    request.fail(function (jqXHR, textStatus) {
1940    });
1941    return false;
1942});
1943
1944if (jQuery('.jobsearch-employer-list .jobsearch-table-layer').length > 0) {
1945    jQuery(document).on('click', '.jobsearch-employer-list .jobsearch-table-layer', function (event) {
1946        var _this = jQuery(this);
1947        var this_target = jQuery(event.target);
1948        if (this_target.is('a') || this_target.parent('a').length > 0) {
1949            // do nothing
1950        } else {
1951            var dest_go_to = _this.find('h2 > a');
1952            window.location.href = dest_go_to.attr('href');
1953        }
1954    });
1955}
1956
1957if (jQuery('.jobsearch-joblisting-classic-wrap').length > 0) {
1958    jQuery(document).on('click', '.jobsearch-joblisting-classic-wrap', function (event) {
1959        var _this = jQuery(this);
1960        var this_target = jQuery(event.target);
1961        if (this_target.is('a') || this_target.parent('a').length > 0) {
1962            // do nothing
1963        } else {
1964            var dest_go_to = _this.find('h2 > a');
1965            window.location.href = dest_go_to.attr('href');
1966        }
1967    });
1968}
1969
1970if (jQuery('.careerfy-employer-grid .careerfy-employer-grid-wrap').length > 0) {
1971    jQuery(document).on('click', '.careerfy-employer-grid .careerfy-employer-grid-wrap', function (event) {
1972        var _this = jQuery(this);
1973        var this_target = jQuery(event.target);
1974        if (this_target.is('a') || this_target.parent('a').length > 0) {
1975            // do nothing
1976        } else {
1977            var dest_go_to = _this.find('h2 > a');
1978            window.location.href = dest_go_to.attr('href');
1979        }
1980    });
1981}
1982
1983jQuery(document).on('click', '#jobsearch-jobadvserach-submit', function (ev) {
1984    ev.preventDefault();
1985    var _thisForm = jQuery(this).parents('form');
1986    _thisForm.find('.jobsearch-search-filter-wrap').find('input').removeAttr('name');
1987    var formToSubmit = setInterval(function () {
1988        var lubricForm = _thisForm.find('input,select,textarea');
1989
1990        jQuery.each(lubricForm, function () {
1991            var thisFieldObj = jQuery(this);
1992            if (typeof thisFieldObj.attr('name') !== 'undefined') {
1993                console.info(thisFieldObj);
1994                var thisFieldName = thisFieldObj.attr('name');
1995                if (thisFieldObj.val() == ''
1996                    || thisFieldName.indexOf("alert-") != -1
1997                    || thisFieldName.indexOf("loc_count_qargs") != -1
1998                    || thisFieldName.indexOf("alerts-") != -1) {
1999                    thisFieldObj.removeAttr('name');
2000                }
2001            }
2002        });
2003        _thisForm.submit();
2004        clearInterval(formToSubmit);
2005    }, 1000);
2006});
2007
2008function jobsearch_js_find_in_array(ar, val) {
2009    if (ar.length > 0) {
2010        for (var i = 0, len = ar.length; i < len; i++) {
2011            if (ar[i] == val) {
2012                return i;
2013            }
2014        }
2015    }
2016    return -1;
2017}
2018
2019jQuery(document).on('keyup', '.jobsearch_chk_passfield', function () {
2020    var _this = jQuery(this);
2021    var parent_form = _this.parents('form');
2022    var _this_classes = 'jobsearch_chk_passfield';
2023    var chk_msg_con = _this.next('.passlenth-chk-msg');
2024    var chkmsg_con_classes = 'passlenth-chk-msg';
2025    var pass_val = _this.val();
2026
2027    var acptable_pass_strnths = jobsearch_plugin_vars.acptable_pass_strnth;
2028    acptable_pass_strnths = jQuery.parseJSON(acptable_pass_strnths);
2029
2030    if (acptable_pass_strnths.length < 1) {
2031        parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2032        parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2033        return -1;
2034    }
2035
2036    var short_pass_msg = jobsearch_plugin_vars.pass_length_short;
2037    var bad_pass_msg = jobsearch_plugin_vars.pass_length_med;
2038    var good_pass_msg = jobsearch_plugin_vars.pass_length_good;
2039    var strong_pass_msg = jobsearch_plugin_vars.pass_length_strng;
2040
2041    if (pass_val == '') {
2042        chk_msg_con.css({display: 'none'});
2043        chk_msg_con.attr('class', chkmsg_con_classes);
2044        chk_msg_con.html('');
2045        _this.attr('class', _this_classes);
2046        if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2047            parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2048        }
2049        parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2050        return false;
2051    }
2052    var blacklistArray = ["querty", "password", "P@ssword1", "132", "123"];
2053    blacklistArray = blacklistArray.concat(wp.passwordStrength.userInputBlacklist());
2054
2055    var pass_strength = wp.passwordStrength.meter(pass_val, blacklistArray);
2056
2057    switch (pass_strength) {
2058        case 0 :
2059            chk_msg_con.css({display: 'inline-block'});
2060            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-vweakp
2060ass');
2061            _this.attr('class', _this_classes + ' jobsearch-vweakpass');
2062            chk_msg_con.html(short_pass_msg);
2063            if (jobsearch_js_find_in_array(acptable_pass_strnths, 'very_weak') !== -1) {
2064                parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2065                parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2066            } else {
2067                if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2068                    parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2069                }
2070                parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2071            }
2072            break;
2073        case 1 :
2074            chk_msg_con.css({display: 'inline-block'});
2075            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-weakpass');
2076            _this.attr('class', _this_classes + ' jobsearch-weakpass');
2077            chk_msg_con.html(bad_pass_msg);
2078            if (jobsearch_js_find_in_array(acptable_pass_strnths, 'weak') !== -1) {
2079                parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2080                parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2081            } else {
2082                if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2083                    parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2084                }
2085                parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2086            }
2087            break;
2088        case 2 :
2089            chk_msg_con.css({display: 'inline-block'});
2090            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-weakpass');
2091            _this.attr('class', _this_classes + ' jobsearch-weakpass');
2092            chk_msg_con.html(bad_pass_msg);
2093            if (jobsearch_js_find_in_array(acptable_pass_strnths, 'weak') !== -1) {
2094                parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2095                parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2096            } else {
2097                if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2098                    parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2099                }
2100                parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2101            }
2102            break;
2103        case 3 :
2104            chk_msg_con.css({display: 'inline-block'});
2105            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-mediumpass');
2106            _this.attr('class', _this_classes + ' jobsearch-mediumpass');
2107            chk_msg_con.html(good_pass_msg);
2108            if (jobsearch_js_find_in_array(acptable_pass_strnths, 'medium') !== -1) {
2109                parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2110                parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2111            } else {
2112                if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2113                    parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2114                }
2115                parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2116            }
2117            break;
2118        case 4 :
2119            chk_msg_con.css({display: 'inline-block'});
2120            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-strongpass');
2121            _this.attr('class', _this_classes + ' jobsearch-strongpass');
2122            chk_msg_con.html(strong_pass_msg);
2123            if (jobsearch_js_find_in_array(acptable_pass_strnths, 'strong') !== -1) {
2124                parent_form.find('.jobsearch-regpass-frmbtn').removeClass('jobsearch-disable-btn');
2125                parent_form.find('.jobsearch-regpass-frmbtn').removeAttr('disabled');
2126            } else {
2127                if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2128                    parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2129                }
2130                parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2131            }
2132            break;
2133        case 5 :
2134            chk_msg_con.css({display: 'inline-block'});
2135            chk_msg_con.attr('class', chkmsg_con_classes + ' jobsearch-shortpass');
2136            _this.attr('class', _this_classes + ' jobsearch-shortpass');
2137            chk_msg_con.html(short_pass_msg);
2138            if (!parent_form.find('.jobsearch-regpass-frmbtn').hasClass('jobsearch-disable-btn')) {
2139                parent_form.find('.jobsearch-regpass-frmbtn').addClass('jobsearch-disable-btn');
2140            }
2141            parent_form.find('.jobsearch-regpass-frmbtn').prop('disabled', true);
2142            break;
2143    }
2144});
2145
2146jQuery(document).on('change', '.filter_location_location1', function (e) {
2147    e.preventDefault();
2148    var this_id = jQuery(this).data('randid'),
2149        nextfieldelement = jQuery(this).data('nextfieldelement'),
2150        nextfieldval = jQuery(this).data('nextfieldval'),
2151        ajax_url = jobsearch_plugin_vars.ajax_url,
2152        location_location1 = jQuery('#location_location1_' + this_id),
2153        location_location2 = jQuery('#location_location2_' + this_id);
2154    jQuery('.location_location2_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
2155
2156    var request = jQuery.ajax({
2157        url: ajax_url,
2158        method: "POST",
2159        data: {
2160            location_location: location_location1.val(),
2161            nextfieldelement: nextfieldelement,
2162            nextfieldval: nextfieldval,
2163            _nonce: jobsearch_comon_script_vars.nonce,
2164            action: 'jobsearch_location_load_location2_data',
2165        },
2166        dataType: "json"
2167    });
2168
2169    request.done(function (response) {
2170        if ('undefined' !== typeof response.html) {
2171            if (jQuery('.location_location2_selectize').length > 0) {
2172                if (jQuery('.location_location2_selectize').hasClass('location2_selectize_ajax')) {
2173                    jQuery('.location2_selectize_ajax').selectize()[0].selectize.destroy();
2174                }
2175            }
2176            location_location2.html(response.html);
2177            if (typeof location_location2.parent('.jobsearch-profile-select').find('.selectize-control') !== 'undefined') {
2178                location_location2.parent('.jobsearch-profile-select').find('.selectize-control').remove();
2179                location_location2.removeAttr('style');
2180                location_location2.removeAttr('tabindex');
2181                location_location2.removeClass('location2_selectize_ajax');
2182                location_location2.removeClass('selectized');
2183            }
2184            jQuery('.location_location2_' + this_id).html('');
2185            if (nextfieldval != '') {
2186                jQuery('.location_location2').trigger('change');
2187            }
2188            //
2189            if (jQuery('.location_location2_selectize').length > 0) {
2190                if (!jQuery('.location_location2_selectize').hasClass('location2_selectize_ajax')) {
2191                    jQuery('.location_location2_selectize').addClass('location2_selectize_ajax');
2192
2193                    jQuery('.location2_selectize_ajax').selectize({
2194                        //allowEmptyOption: true,
2195                    });
2196                }
2197            }
2198
2199            //
2200            if (jQuery('.location_location3_selectize').length > 0) {
2201                if (jQuery('.location_location2_selectize').val() == '') {
2202                    jQuery('.location_location2_selectize').trigger('change');
2203                }
2204            }
2205        }
2206    });
2207
2208    request.fail(function (jqXHR, textStatus) {
2209    });
2210    return false;
2211
2212});
2213
2214jQuery(document).on('change', '.filter_location_location2', function (e) {
2215    e.preventDefault();
2216    var this_id = jQuery(this).data('randid'),
2217        nextfieldelement = jQuery(this).data('nextfieldelement'),
2218        nextfieldval = jQuery(this).data('nextfieldval'),
2219        ajax_url = jobsearch_plugin_vars.ajax_url,
2220        location_location2 = jQuery('#location_location2_' + this_id),
2221        location_location3 = jQuery('#location_location3_' + this_id);
2222    jQuery('.location_location3_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
2223
2224    var request = jQuery.ajax({
2225        url: ajax_url,
2226        method: "POST",
2227        data: {
2228            location_location: location_location2.val(),
2229            nextfieldelement: nextfieldelement,
2230            nextfieldval: nextfieldval,
2231            _nonce: jobsearch_comon_script_vars.nonce,
2232            action: 'jobsearch_location_load_location2_data',
2233        },
2234        dataType: "json"
2235    });
2236
2237    request.done(function (response) {
2238        if ('undefined' !== typeof response.html) {
2239            if (jQuery('.location_location3_selectize').length > 0) {
2240                if (jQuery('.location_location3_selectize').hasClass('location3_selectize_ajax')) {
2241                    jQuery('.location3_selectize_ajax').selectize()[0].selectize.destroy();
2242                }
2243            }
2244            location_location3.html(response.html);
2245            if (typeof location_location3.parent('.jobsearch-profile-select').find('.selectize-control') !== 'undefined') {
2246                location_location3.parent('.jobsearch-profile-select').find('.selectize-control').remove();
2247                location_location3.removeAttr('style');
2248                location_location3.removeAttr('tabindex');
2249                location_location3.removeClass('location3_selectize_ajax');
2250                location_location3.removeClass('selectized');
2251            }
2252            jQuery('.location_location3_' + this_id).html('');
2253            if (nextfieldval != '') {
2254                jQuery('.location_location3').trigger('change');
2255            }
2256            //
2257            if (jQuery('.location_location3_selectize').length > 0) {
2258                if (!jQuery('.location_location3_selectize').hasClass('location3_selectize_ajax')) {
2259                    jQuery('.location_location3_selectize').addClass('location3_selectize_ajax');
2260
2261                    jQuery('.location3_selectize_ajax').selectize({
2262                        //allowEmptyOption: true,
2263                    });
2264                }
2265            }
2266
2267            //
2268            if (jQuery('.location_location4_selectize').length > 0) {
2269                if (jQuery('.location_location3_selectize').val() == '') {
2270                    jQuery('.location_location3_selectize').trigger('change');
2271                }
2272            }
2273        }
2274    });
2275
2276    request.fail(function (jqXHR, textStatus) {
2277    });
2278    return false;
2279
2280});
2281
2282jQuery(document).on('change', '.filter_location_location3', function (e) {
2283    e.preventDefault();
2284    var this_id = jQuery(this).data('randid'),
2285        nextfieldelement = jQuery(this).data('nextfieldelement'),
2286        nextfieldval = jQuery(this).data('nextfieldval'),
2287        ajax_url = jobsearch_plugin_vars.ajax_url,
2288        location_location3 = jQuery('#location_location3_' + this_id),
2289        location_location4 = jQuery('#location_location4_' + this_id);
2290    jQuery('.location_location4_' + this_id).html('<i class="fa fa-refresh fa-spin"></i>');
2291
2292    var request = jQuery.ajax({
2293        url: ajax_url,
2294        method: "POST",
2295        data: {
2296            location_location: location_location3.val(),
2297            nextfieldelement: nextfieldelement,
2298            nextfieldval: nextfieldval,
2299            _nonce: jobsearch_comon_script_vars.nonce,
2300            action: 'jobsearch_location_load_location2_data',
2301        },
2302        dataType: "json"
2303    });
2304
2305    request.done(function (response) {
2306        if ('undefined' !== typeof response.html) {
2307            if (jQuery('.location_location4_selectize').length > 0) {
2308                if (jQuery('.location_location4_selectize').hasClass('location4_selectize_ajax')) {
2309                    jQuery('.location4_selectize_ajax').selectize()[0].selectize.destroy();
2310                }
2311            }
2312            location_location4.html(response.html);
2313            if (typeof location_location4.parent('.jobsearch-profile-select').find('.selectize-control') !== 'undefined') {
2314                location_location4.parent('.jobsearch-profile-select').find('.selectize-control').remove();
2315                location_location4.removeAttr('style');
2316                location_location4.removeAttr('tabindex');
2317                location_location4.removeClass('location4_selectize_ajax');
2318                location_location4.removeClass('selectized');
2319            }
2320            jQuery('.location_location4_' + this_id).html('');
2321            //
2322            if (jQuery('.location_location4_selectize').length > 0) {
2323                if (!jQuery('.location_location4_selectize').hasClass('location4_selectize_ajax')) {
2324                    jQuery('.location_location4_selectize').addClass('location4_selectize_ajax');
2325
2326                    jQuery('.location4_selectize_ajax').selectize({
2327                        //allowEmptyOption: true,
2328                    });
2329                }
2330            }
2331        }
2332    });
2333
2334    request.fail(function (jqXHR, textStatus) {
2335    });
2336    return false;
2337
2338});
2339
2340jQuery('.lodmore-empactjobs-btn').on('click', function (e) {
2341    e.preventDefault();
2342    var _this = jQuery(this),
2343        this_id = _this.attr('data-id'),
2344        total_pages = _this.attr('data-tpages'),
2345        page_num = _this.attr('data-gtopage'),
2346        this_html = _this.html(),
2347        appender_con = jQuery('.jobsearch-empdetail-activejobs > ul');
2348    if (!_this.hasClass('ajax-loadin')) {
2349        _this.addClass('ajax-loadin');
2350        _this.html(this_html + ' <i class="fa fa-refresh fa-spin"></i>');
2351
2352        total_pages = parseInt(total_pages);
2353        page_num = parseInt(page_num);
2354        var request = jQuery.ajax({
2355            url: jobsearch_plugin_vars.ajax_url,
2356            method: "POST",
2357            data: {
2358                emp_id: this_id,
2359                page_num: page_num,
2360                _nonce: jobsearch_comon_script_vars.nonce,
2361                action: 'jobsearch_load_more_actemp_jobs_det',
2362            },
2363            dataType: "json"
2364        });
2365
2366        request.done(function (response) {
2367            if ('undefined' !== typeof response.html) {
2368                page_num += 1;
2369                _this.attr('data-gtopage', page_num);
2370                if (page_num > total_pages) {
2371                    _this.parent('div').hide();
2372                }
2373                appender_con.append(response.html);
2374            }
2375            _this.html(this_html);
2376            _this.removeClass('ajax-loadin');
2377        });
2378
2379        request.fail(function (jqXHR, textStatus) {
2380            _this.html(this_html);
2381            _this.removeClass('ajax-loadin');
2382        });
2383    }
2384    return false;
2385
2386});
2387
2388function jobsearch_upload_cand_cover_letter_file(input, this_id) {
2389
2390    if (input.files && input.files[0]) {
2391
2392        var loader_con = jQuery('#jobsearch-upload-cover-' + this_id).find('.fileUpLoader');
2393
2394        var cv_file = input.files[0];
2395        var file_size = cv_file.size;
2396        var file_type = cv_file.type;
2397        var file_name = cv_file.name;
2398
2399        var allowed_types = jobsearch_plugin_vars.coverdoc_file_types;
2400
2401        file_size = parseFloat(file_size / 1024).toFixed(2);
2402        var filesize_allow = jobsearch_plugin_vars.coverfile_size_allow;
2403        filesize_allow = parseInt(filesize_allow);
2404
2405        if (file_size <= filesize_allow) {
2406            if (allowed_types.indexOf(file_type) >= 0) {
2407                loader_con.html('<i class="fa fa-refresh fa-spin"></i>');
2408                var formData = new FormData();
2409                formData.append('candidate_cover_file', cv_file);
2410                formData.append('_nonce', jobsearch_comon_script_vars.nonce);
2411                formData.append('action', 'jobsearch_dashboard_uploding_candidate_cover_file');
2412                console.info(formData);
2413                var request = jQuery.ajax({
2414                    url: jobsearch_plugin_vars.ajax_url,
2415                    method: "POST",
2416                    data: formData,
2417                    processData: false,
2418                    contentType: false,
2419                    dataType: "json"
2420                });
2421                request.done(function (response) {
2422                    if (typeof response.err_msg !== 'undefined' && response.err_msg != '') {
2423                        loader_con.html(response.err_msg);
2424                        return false;
2425                    }
2426                    if (typeof response.filehtml !== 'undefined' && response.filehtml != '') {
2427                        jQuery('#com-file-holder').html(response.filehtml);
2428                        jQuery('#com-file-holder').find('.jobsearch-cv-manager-list').slideDown();
2429                    }
2430                    loader_con.html('');
2431                });
2432
2433                request.fail(function (jqXHR, textStatus) {
2434                    loader_con.html(jobsearch_plugin_vars.error_msg);
2435                });
2436            } else {
2437                alert(jobsearch_plugin_vars.cover_file_types);
2438            }
2439
2440        } else {
2441            alert(jobsearch_plugin_vars.coverfile_size_err);
2442        }
2443    }
2444}
2445
2446jQuery(document).on('change', 'input[name="candidate_cover_file"]', function () {
2447    var this_id = jQuery(this).attr('data-id');
2448    jobsearch_upload_cand_cover_letter_file(this, this_id);
2449});
2450
2451function jobsearch_upload_cand_aply_cover_letter(input, this_id) {
2452
2453    if (input.files && input.files[0]) {
2454
2455        var loader_con = jQuery('#jobsearch-upload-cover-' + this_i
2455d).find('.fileUpLoader');
2456
2457        var cv_file = input.files[0];
2458        var file_size = cv_file.size;
2459        var file_type = cv_file.type;
2460        var file_name = cv_file.name;
2461
2462        var allowed_types = jobsearch_plugin_vars.coverdoc_file_types;
2463
2464        file_size = parseFloat(file_size / 1024).toFixed(2);
2465        var filesize_allow = jobsearch_plugin_vars.coverfile_size_allow;
2466        filesize_allow = parseInt(filesize_allow);
2467
2468        if (file_size <= filesize_allow) {
2469            if (allowed_types.indexOf(file_type) >= 0) {
2470                loader_con.html('<i class="fa fa-refresh fa-spin"></i>');
2471                var formData = new FormData();
2472                formData.append('candidate_apply_cover', cv_file);
2473                formData.append('_nonce', jobsearch_comon_script_vars.nonce);
2474                formData.append('action', 'jobsearch_aplyjob_uplodin_candidate_cover_file');
2475                console.info(formData);
2476                var request = jQuery.ajax({
2477                    url: jobsearch_plugin_vars.ajax_url,
2478                    method: "POST",
2479                    data: formData,
2480                    processData: false,
2481                    contentType: false,
2482                    dataType: "json"
2483                });
2484                request.done(function (response) {
2485                    if (typeof response.err_msg !== 'undefined' && response.err_msg != '') {
2486                        loader_con.html(response.err_msg);
2487                        return false;
2488                    }
2489                    if (typeof response.filehtml !== 'undefined' && response.filehtml != '') {
2490                        jQuery('#cover-uploded-' + this_id).html(response.filehtml);
2491                            jQuery('#cover-uploded-' + this_id).slideDown();
2492                    }
2493                    loader_con.html('');
2494                });
2495
2496                request.fail(function (jqXHR, textStatus) {
2497                    loader_con.html(jobsearch_plugin_vars.error_msg);
2498                });
2499            } else {
2500                alert(jobsearch_plugin_vars.cover_file_types);
2501            }
2502
2503        } else {
2504            alert(jobsearch_plugin_vars.coverfile_size_err);
2505        }
2506    }
2507}
2508
2509jQuery(document).on('change', 'input[name="candidate_apply_cover"]', function () {
2510    var this_id = jQuery(this).attr('data-id');
2511    jobsearch_upload_cand_aply_cover_letter(this, this_id);
2512});
2513
2514jQuery(document).on('click', '.jobsearch-deluser-coverfile', function () {
2515    var _this = jQuery(this);
2516    var this_id = _this.attr('data-id');
2517    if (this_id != '') {
2518        var conf = confirm(jobsearch_plugin_vars.are_you_sure);
2519        if (conf) {
2520            _this.find('i').attr('class', 'fa fa-refresh fa-spin');
2521            var request = jQuery.ajax({
2522                url: jobsearch_plugin_vars.ajax_url,
2523                method: "POST",
2524                data: {
2525                    'attach_id': this_id,
2526                    _nonce: jobsearch_comon_script_vars.nonce,
2527                    'action': 'jobsearch_act_user_coverletr_delete',
2528                },
2529                dataType: "json"
2530            });
2531
2532            request.done(function (response) {
2533                if (typeof response.err_msg !== 'undefined' && response.err_msg != '') {
2534                    _this.find('i').removeAttr('class').html(response.err_msg);
2535                    return false;
2536                }
2537                _this.parents('.jobsearch-cv-manager-list').slideUp();
2538                window.location.reload();
2539            });
2540
2541            request.fail(function (jqXHR, textStatus) {
2542                _this.find('i').attr('class', 'jobsearch-icon jobsearch-rubbish');
2543            });
2544        }
2545    }
2546});
2547
2548jQuery(document).on('change', '.jobsearch-cusfield-checkbox input[type=checkbox]', function () {
2549    var _this = jQuery(this);
2550    var this_parent = _this.parents('.jobsearch-cusfield-checkbox');
2551    var max_options = this_parent.attr('data-mop');
2552
2553    max_options = parseInt(max_options);
2554    if (max_options > 0) {
2555        var chkbox_options = this_parent.find('input[type=checkbox]');
2556        var checkd_err_alrt = false;
2557        var checkd_counts = 0;
2558        chkbox_options.each(function () {
2559            var this_option = jQuery(this);
2560            if (this_option.is(':checked')) {
2561                checkd_counts++;
2562            }
2563            if (checkd_counts > max_options) {
2564                this_option.prop('checked', false);
2565                checkd_err_alrt = true;
2566            }
2567        });
2568        if (checkd_err_alrt === true) {
2569            alert(this_parent.attr('data-maxerr'));
2570        }
2571    }
2572});
2573
2574function jobsearch_check_webgl_compatibility() {
2575    var canvas = document.createElement('canvas'); 
2576    return !!window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
2577}
2578
2579jQuery(document).on('click', '.open-listin-mobfiltrs', function() {
2580    var filters_con = jQuery('.listin-filters-sidebar');
2581    filters_con.toggleClass('active-filters-con');
2582});
2583
2584jQuery(document).on('click', '.close-listin-mobfiltrs', function() {
2585    var filters_con = jQuery('.listin-filters-sidebar');
2586    filters_con.removeClass('active-filters-con');
2587});
2588
2589jQuery(document).on('change', '.jobsearch-select-style select,.jobsearch-select-style input', function() {
2590    if (jQuery(this).parents('.no-onchange-trigercall').length > 0) {
2591        // do not submit
2592    } else {
2593        jQuery('#jobsearch-jobadvserach-submit').trigger('click');
2594    }
2595});
2596
2597jQuery('.jobsearch-toggle-dashmenu').click(function () {
2598    if (!jQuery('.careerfy-mobile-hdr-sidebar').hasClass('animate-menu-open')) {
2599        jQuery('.careerfy-inmobile-itemsgen').hide();
2600        jQuery('.jobsearch-mobile-dashmenu').removeAttr('style');
2601    }
2602    jQuery('.careerfy-mobile-hdr-sidebar').toggleClass('animate-menu-open');
2603});
2604
2605jQuery('.mobile-usernotifics-btn').click(function () {
2606    if (!jQuery('.careerfy-mobile-hdr-sidebar').hasClass('animate-menu-open')) {
2607        jQuery('.careerfy-inmobile-itemsgen').hide();
2608        jQuery('.jobsearch-mobile-notificsdet').removeAttr('style');
2609    }
2610    jQuery('.careerfy-mobile-hdr-sidebar').toggleClass('animate-menu-open');
2611});
2612
2613if (jQuery('.jobsearch-checkbox-toggle .jobsearch-checkbox').length > 0) {
2614    var jobsearch_filter_ulists = jQuery('.jobsearch-checkbox-toggle .jobsearch-checkbox');
2615    jobsearch_filter_ulists.each(function () {
2616        if (!jQuery(this).hasClass('jobsearch-sectr-chckbxes')) {
2617            var filters_list = jQuery(this).find('>li');
2618            if (filters_list.length > 0) {
2619                filters_list.each(function (index, elem) {
2620                    var this_litm = jQuery(this);
2621                    if (index < 6) {
2622                        if (this_litm.hasClass('filter-more-fields')) {
2623                            this_litm.removeClass('filter-more-fields');
2624                        }
2625                    } else {
2626                        if (!this_litm.hasClass('filter-more-fields') && !this_litm.hasClass('location-level-0')) {
2627                            this_litm.addClass('filter-more-fields');
2628                        }
2629                    }
2630                });
2631            }
2632        }
2633    });
2634}
2635if (jQuery('.jobsearch-checkbox-toggle .jobsearch-sectr-chckbxes').length > 0) {
2636    var jobsearch_filter_ulists = jQuery('.jobsearch-checkbox-toggle .jobsearch-sectr-chckbxes');
2637    jobsearch_filter_ulists.each(function () {
2638        var this_bx = jQuery(this);
2639        if (this_bx.next('a.show-toggle-filter-list').length) {
2640            this_bx.next('a.show-toggle-filter-list').remove();
2641        }
2642        var filters_list = this_bx.find('>li');
2643        if (filters_list.length > 0) {
2644            var jobsearch_sctrfiltr_countr = 0;
2645            filters_list.each(function () {
2646                var this_litm = jQuery(this);
2647                //
2648                if (this_litm.hasClass('jobserach-mainch-fltritm')) {
2649                    if (jobsearch_sctrfiltr_countr < 6) {
2650                        if (this_litm.hasClass('filter-more-fields')) {
2651                            this_litm.removeClass('filter-more-fields');
2652                        }
2653                    } else {
2654                        if (!this_litm.hasClass('filter-more-fields')) {
2655                            //this_litm.addClass('filter-more-fields');
2656                        }
2657                    }
2658                    jobsearch_sctrfiltr_countr++;
2659                }
2660                if (this_litm.hasClass('jobserach-childch-fltritm')) {
2661                    //this_litm.hide();
2662                }
2663                jobsearch_shw_childprnt_filtritms_chk(this_litm);
2664            });
2665        }
2666    });
2667}
2668
2669function jobsearch_shw_childprnt_filtritms_chk(this_litm) {
2670    var main_bx_con = this_litm.closest('.jobsearch-sectr-chckbxes');
2671    var this_inpch = this_litm.find('input');
2672    var trmid = this_litm.attr('data-id');
2673    var prnid = false;
2674    if (this_litm.hasClass('jobserach-childch-fltritm')) {
2675        var prnid_hcls = this_litm.attr('class').split(" ").find(cls => cls.startsWith("jobserach-prntsec-"));
2676        prnid = prnid_hcls.match(/\d+/)[0];
2677    }
2678    
2679    if (this_inpch.is(':checked')) {
2680        if (this_litm.hasClass('jobserach-childch-fltritm')) {
2681            this_litm.removeAttr('style');
2682            main_bx_con.find('li[data-id="' + prnid + '"]').removeAttr('style');
2683            main_bx_con.find('.jobserach-prntsec-' + prnid).removeAttr('style');
2684        }
2685        if (main_bx_con.find('.jobserach-prntsec-' + trmid).length) {
2686            main_bx_con.find('.jobserach-prntsec-' + trmid).removeAttr('style');
2687        }
2688    } else {
2689        if (main_bx_con.find('.jobserach-prntsec-' + trmid).length) {
2690            main_bx_con.find('.jobserach-prntsec-' + trmid).hide();
2691        }
2692    }
2693}
2694
2695function jobsearch_fix_chkradio_loadmore_filtrs() {
2696    if (jQuery('.jobsearch-checkbox-toggle .jobsearch-checkbox').length > 0) {
2697        var jobsearch_filter_ulists = jQuery('.jobsearch-checkbox-toggle .jobsearch-checkbox');
2698        jobsearch_filter_ulists.each(function () {
2699            if (!jQuery(this).hasClass('jobsearch-sectr-chckbxes')) {
2700                var filters_list = jQuery(this).find('>li');
2701                if (filters_list.length > 0) {
2702                    filters_list.each(function (index, elem) {
2703                        var this_litm = jQuery(this);
2704                        if (index < 6) {
2705                            if (this_litm.hasClass('filter-more-fields')) {
2706                                this_litm.removeClass('filter-more-fields');
2707                            }
2708                        } else {
2709                            if (!this_litm.hasClass('filter-more-fields') && !this_litm.hasClass('location-level-0')) {
2710                                //this_litm.addClass('filter-more-fields');
2711                            }
2712                        }
2713                    });
2714                }
2715            }
2716        });
2717    }
2718    if (jQuery('.jobsearch-checkbox-toggle .jobsearch-sectr-chckbxes').length > 0) {
2719        var jobsearch_filter_ulists = jQuery('.jobsearch-checkbox-toggle .jobsearch-sectr-chckbxes');
2720        jobsearch_filter_ulists.each(function () {
2721            var this_bx = jQuery(this);
2722            if (this_bx.next('a.show-toggle-filter-list').length) {
2723                this_bx.next('a.show-toggle-filter-list').remove();
2724            }
2725            var filters_list = this_bx.find('>li');
2726            if (filters_list.length > 0) {
2727                var jobsearch_sctrfiltr_countr = 0;
2728                filters_list.each(function () {
2729                    var this_litm = jQuery(this);
2730                    //
2731                    if (this_litm.hasClass('jobserach-mainch-fltritm')) {
2732                        if (jobsearch_sctrfiltr_countr < 6) {
2733                            if (this_litm.hasClass('filter-more-fields')) {
2734                                this_litm.removeClass('filter-more-fields');
2735                            }
2736                        } else {
2737                            if (!this_litm.hasClass('filter-more-fields')) {
2738                                //this_litm.addClass('filter-more-fields');
2739                            }
2740                        }
2741                        jobsearch_sctrfiltr_countr++;
2742                    }
2743                    if (this_litm.hasClass('jobserach-childch-fltritm')) {
2744                        //this_litm.hide();
2745                    }
2746                    jobsearch_shw_childprnt_filtritms_chk(this_litm);
2747                });
2748            }
2749        });
2750    }
2751}
2752
2753jQuery(document).on('change', '.jobsearch-filter-multicon .jobsearch-taxnm-multislectr', function() {
2754    var this_btn = jQuery(this);
2755    var parnt_con = this_btn.parents('.jobsearch-filter-multicon');
2756    var apender_con = parnt_con.find('.jobsearch-filter-multiappnder');
2757    var onchange_func = parnt_con.attr('data-func');
2758    var global_counter = parnt_con.attr('data-gcounter');
2759
2760    var finl_val = '';
2761    var vals_arr = [];
2762    parnt_con.find('.jobsearch-taxnm-multislectr').each(function() {
2763        if (jQuery(this).is(':checked')) {
2764            vals_arr.push(jQuery(this).val());
2765        }
2766    });
2767    if (vals_arr.length > 0) {
2768        finl_val = vals_arr.join();
2769    }
2770    apender_con.val(finl_val);
2771    window[onchange_func](global_counter);
2772});

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.