PageSourceSearch

https://unique-ars.com/wp-content/plugins/b2b/user-registration-pl…/front/js/afreg_front.js?ver=1.0

js unique-ars.com collected 2026-10-08 14:38:48 UTC 8,141 bytes, 232 lines download raw bytes

1jQuery(document).ready(function($){
2	
3	"user strict";
4	jQuery(".color_sepctrum").spectrum({
5		color: "#000",
6		preferredFormat: "hex",
7	});
8
9	jQuery('.afreg_additional_multi_select').select2();
10	
11	jQuery('form#registerform').attr('enctype','multipart/form-data');
12	jQuery('.woocommerce-form-register').attr('enctype','multipart/form-data');
13	jQuery('.woocommerce-EditAccountForm').attr('enctype','multipart/form-data');
14	
15
16	jQuery('.woocommerce-account-fields div.create-account').append(jQuery('div.afreg_extra_fields'));
17
18
19	// Dependable Fields.
20	check_dependable();
21	// setTimeout(function(){ check_dependable(); },2000);
22	$(document).on('change','.af-dependable-field input , .afreg-is-radio-dependable , .afreg-is-checkbox-dependable , .afreg-is-multi-checkbox-dependable , .afreg-is-multi-select-dependable , .afreg-is-select-dependable , #afreg_select_user_role',function(){
23		check_dependable();
24	});
25
26	function	check_dependable() {
27
28		var all_dependable_ids_array 			=  [];
29
30		let other_filed_type 					= 'text number textarea email number password fileupload color description heading googlecaptcha timepicker datepicker';
31		$('.af-dependable-field').each( function() {
32			if( $(this).find('afreg-dependable-on-rules') ) {
33
34				var hide_or_show_this_element 	= true; 
35
36				let current_post_id = $(this).data('current_post_id'); 
37
38				let user_select_role_at_reg = $('#afreg_select_user_role').length && $('#afreg_select_user_role').val() ? $('#afreg_select_user_role').val() : 'No Selected Yet';
39				let admin_selected_role 	= $(this).find('.afreg-dependable-on-rules').length && $(this).find('.afreg-dependable-on-rules').val() ? $(this).find('.afreg-dependable-on-rules').val() : '';
40
41				if ( admin_selected_role != '' && admin_selected_role != undefined ) {
42
43					if ( admin_selected_role.indexOf( user_select_role_at_reg ) == -1 ) {
44						
45						$(this).hide('fast');
46						// console.log('role not match admin_selected_role => ' + admin_selected_role + ' --- user_select_role_at_reg ==> ' + user_select_role_at_reg + ' ---- afreg_additional_'+current_post_id  );
47						hide_or_show_this_element 	= false;
48					}
49
50				}
51
52				if ( $(this).find('.afreg-dependable-field-on').length && $(this).find('.afreg-dependable-field-on').val() ) {
53
54					let current_field_type 						= $(this).find('.afreg-dependable-field-on').data('current_field_type');
55					let dependable_field_option 				= $(this).find('.afreg-dependable-field-on').data('dependable_field_option');
56					let dependent_on_field_id 					= $(this).find('.afreg-dependable-field-on').val();
57					let dependable_field_type 					= $(this).find('.afreg-dependable-field-on').data('dependable_field_type');
58					let selected_opt_of_dependable_field 		= '';
59
60					// User Selected Data.
61					let selected_dependent_filed_value 			= '';
62
63					if ( 'radio' == dependable_field_type && $('.afreg_additional_'+dependent_on_field_id+':checked').val() != undefined && $('.afreg_additional_'+dependent_on_field_id+':checked').val()) {
64
65						selected_dependent_filed_value 					= $('.afreg_additional_'+dependent_on_field_id+':checked').val();
66
67					} else if ( 'select' == dependable_field_type && $('.afreg_additional_'+ dependent_on_field_id).val() != undefined && $('.afreg_additional_'+ dependent_on_field_id).val()  ) {
68						selected_dependent_filed_value 					= $('.afreg_additional_'+ dependent_on_field_id).val() ;
69
70
71					} else if ( 'multiselect' == dependable_field_type && $('.afreg_additional_'+dependent_on_field_id).children('option:selected').val() != undefined && $('.afreg_additional_'+dependent_on_field_id).children('option:selected').val() ) {
72
73						$('.afreg_additional_'+dependent_on_field_id).children('option:selected').each(function(){
74
75							if ( $(this).val() && undefined != $(this).val() ) {
76								selected_dependent_filed_value     		= selected_dependent_filed_value + ' ' + $(this).val();
77							}
78
79						});
80
81
82					} else if ( 'multi_checkbox' == dependable_field_type && $('.afreg_additional_'+dependent_on_field_id+':checked').val() != undefined && $('.afreg_additional_'+dependent_on_field_id+':checked').val() ) {
83
84						$('.afreg_additional_'+dependent_on_field_id+':checked').each(function(){
85
86							if ( $(this).val() && undefined != $(this).val() ) {
87								selected_dependent_filed_value     		= selected_dependent_filed_value + ' ' + $(this).val();
88							}
89
90						});
91
92
93
94					}  else if ( 'checkbox' == dependable_field_type && $('.afreg_additional_'+dependent_on_field_id+':checked').val() && $('.afreg_additional_'+dependent_on_field_id+':checked').val() != undefined ) {
95						
96						selected_dependent_filed_value 					= $('.afreg_additional_'+dependent_on_field_id+':checked').val() ;
97
98					}
99
100					if ( dependable_field_option && dependable_field_option != undefined ) {
101						dependable_field_option_arr 			= dependable_field_option.split(',');
102					} else {
103						dependable_field_option_arr 			= [];
104					}
105
106
107					if ( selected_dependent_filed_value && selected_dependent_filed_value != undefined ) {
108						selected_dependent_filed_value 				= selected_dependent_filed_value.split(' ');
109					} else {
110						selected_dependent_filed_value 				= [];
111					}
112
113					dependable_field_option_arr 					= array_filter( dependable_field_option_arr ); 
114					selected_dependent_filed_value 					= array_filter( selected_dependent_filed_value ); 
115
116
117					let array_total_match_values = array_intersect( dependable_field_option_arr, selected_dependent_filed_value );
118
119					let total_match_values = 0;
120
121					$.each(array_total_match_values,function(index,val){
122						if ( val != '' && val != undefined  ) {
123
124							total_match_values++;
125
126						}
127
128					});
129
130					if ( total_match_values < 1 && ( dependable_field_option != '' && dependable_field_option != undefined )) {
131
132						hide_or_show_this_element 	= false;
133						$('#afreg_additionalshowhide_' + current_post_id).hide('fast');
134					}
135
136					
137
138
139					if ( $('#afreg_additionalshowhide_' + dependent_on_field_id).is(':hidden') ) {
140
141						$('#afreg_additionalshowhide_' + current_post_id).hide('fast');
142						hide_or_show_this_element 	= false;
143					}
144
145					let dependent_field_id_nd_current_post_id 						= []; 
146					dependent_field_id_nd_current_post_id['current_post_id'] 		=  current_post_id;
147					dependent_field_id_nd_current_post_id['dependent_on_field_id'] 	=  parseInt( dependent_on_field_id );
148					all_dependable_ids_array.push(dependent_field_id_nd_current_post_id);
149
150				}
151
152				if ( hide_or_show_this_element ) {
153					$(this).fadeIn('slow')
154				}
155
156			}
157
158
159		});
160
161
162		setInterval (function() {
163
164			hide_parent_hidden_field(all_dependable_ids_array);
165		} , 1000);
166
167}
168
169function hide_parent_hidden_field(all_dependable_ids_array){
170
171	$.each(all_dependable_ids_array,function(index,dependent_field_id_nd_current_post_id_arr){
172
173		if ( dependent_field_id_nd_current_post_id_arr['current_post_id'] != undefined && dependent_field_id_nd_current_post_id_arr['dependent_on_field_id'] != undefined ) {
174
175			let current_post_id 		=  dependent_field_id_nd_current_post_id_arr['current_post_id'];
176			let dependent_on_field_id 	=  dependent_field_id_nd_current_post_id_arr['dependent_on_field_id'];
177
178			if ( $('#afreg_additionalshowhide_' + dependent_on_field_id).is(':hidden') ) {
179
180				// console.log('Parent is Hidden afreg_additionalshowhide_'+ dependent_on_field_id +' afreg_additional_'+ current_post_id);
181
182				$('#afreg_additionalshowhide_' + current_post_id).hide('fast');
183
184			}
185
186			if ( ! $('#afreg_additionalshowhide_'+dependent_on_field_id).length ) {
187
188
189				$('#afreg_additionalshowhide_' + current_post_id).remove();
190
191			}
192		}
193	});
194}
195
196
197function array_intersect( arr1, arr2) {
198
199
200	let final_array = [];
201
202	$.each(arr1,function(index,main_array_value){
203		main_array_value = main_array_value.trim();
204
205
206		$.each(arr2,function(index,second_array_value){
207			second_array_value = second_array_value.trim();
208
209			if (main_array_value == second_array_value) {
210
211				final_array.push(main_array_value);
212			}
213
214		});
215
216	});
217
218	return final_array;
219
220}
221
222function array_filter(array) {
223	var filteredArray = $.grep(array, function (element) {
224
225		return element !== '';
226
227	});
228
229	return filteredArray;
230}
231
232});

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.