https://britishfantasysociety.org/wp-content/plugins/ultimate-addo…/js/uacf7-cf-script.js?ver=3.5.45
1; (function ($) { 2 'use strict'; 3 4 jQuery(document).ready(function () { 5 6 var $this = false; 7 uacf7_cf_handler_this($this); 8 9 jQuery(document).on('keyup', '.wpcf7-form input:not(.wpcf7-uacf7_country_dropdown, .wpcf7-uacf7_city, .wpcf7-uacf7_state, .wpcf7-uacf7_zip), .wpcf7-form textarea', function () { 10 var $this = $(this); 11 uacf7_cf_handler_this($this); 12 }); 13 14 jQuery(document).on('change', '.wpcf7-form select:not(.wpcf7-uacf7_product_dropdown), .wpcf7-form input[type="radio"]:not(.uacf7-rating input[type="radio"]), .wpcf7-form input[type="date"]', function () { 15 var $this = $(this); 16 uacf7_cf_handler_this($this); 17 }); 18 19 jQuery(document).on('change', 'input[type="checkbox"]', function () { 20 var $this = $(this); 21 uacf7_cf_handler_this($this); 22 }); 23 24 }); 25 26 27 /* 28 * Conditional script 29 */ 30 function uacf7_cf_handler_this($this) { 31 jQuery('form.wpcf7-form').each(function () { 32 var contactFormId = jQuery('input[name="_wpcf7"]', this).val(); 33 var repeater_count = jQuery('.uacf7-repeater-count', this).val(); 34 var form = uacf7_cf_object[contactFormId]; 35 var $i = 0; 36 if (typeof repeater_count === 'undefined') { 37 var repeater_weapper = '.uacf7_conditional'; 38 } else { 39 if ($this == false) { 40 var repeater_weapper = '.uacf7_conditional'; 41 } else { 42 if (typeof $this.attr('uacf-original-name') === 'undefined' || $this.attr('uacf-original-name').length == 0) { 43 var repeater_weapper = '.uacf7_conditional'; 44 } else { 45 var repeater_weapper = $this.closest('.uacf7_repeater_sub_field'); 46 } 47 48 } 49 } 50 51 // Condition repeater Checked 52 var tag_name_array = []; 53 var count = 0; 54 var count_2 = 0; 55 jQuery(form).each(function () { 56 var $uacf7_cf_conditions = form[count_2]['uacf7_cf_conditions']; 57 var $conditionsLength = $uacf7_cf_conditions['uacf7_cf_tn'].length; 58 var x; 59 if (typeof repeater_count !== 'undefined') { 60 for (x = 0; x < $conditionsLength; x++) { 61 tag_name_array.push($uacf7_cf_conditions['uacf7_cf_tn'][x]); 62 count++; 63 } 64 } 65 count_2++ 66 }); 67 68 if (typeof repeater_count !== 'undefined') { 69 if ($this != false) { 70 if (typeof $this.attr('uacf-original-name') !== 'undefined') { 71 if (jQuery.inArray($this.attr('uacf-original-name'), tag_name_array) == -1) { 72 return false; 73 } 74 } 75 76 } 77 } 78 79 // Condition repeater Checked End 80 jQuery(form).each(function () { 81 82 var $uacf7_cf_conditions = form[$i]['uacf7_cf_conditions']; 83 var $conditionsLength = $uacf7_cf_conditions['uacf7_cf_tn'].length; 84 85 /* 86 * Checking validation. 87 * If tag name not empty 88 */ 89 if ($conditionsLength > 0 && form[$i]['uacf7_cf_group'] != '') { 90 /* Fields value */ 91 var vaL = jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'] + '"]').val(); 92 93 if (jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'] + '"]').is("input[type='radio']")) { 94 var vaL = jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'] + '"]:checked').val(); 95 } 96 97 /* 98 * Conditions If show 99 */ 100 if (form[$i]['uacf7_cf_hs'] == 'show') { 101 if (typeof repeater_count === 'undefined') { 102 jQuery('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + '').hide().addClass('uacf7-hidden'); 103 104 } else { 105 if ($this == false) { 106 jQuery('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + '').hide().addClass('uacf7-hidden'); 107 108 } else { 109 if (typeof $this.attr('uacf-original-name') === 'undefined' || $this.attr('uacf-original-name').length == 0) { 110 jQuery('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + '').hide().addClass('uacf7-hidden'); 111 112 } else { 113 $this.closest('.uacf7_repeater_sub_field').find('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + '').hide().addClass('uacf7-hidden'); 114 115 } 116 } 117 } 118 } 119 120 var $conditionRule = ''; 121 var x; 122 var $conditions = []; 123 for (x = 0; x < $conditionsLength; x++) { 124 var $tag_name = $uacf7_cf_conditions['uacf7_cf_tn'][x]; 125 126 if (typeof $tag_name === 'undefined') { 127 var $tag_name = $uacf7_cf_conditions['uacf7_cf_tn'][x]; 128 } 129 130 if ($tag_name == $uacf7_cf_conditions['uacf7_cf_tn'][x]) { 131 var maybeChecked = ''; 132 var maybeMultiple = ''; 133 var checkedItem = ''; 134 135 if (jQuery('.wpcf7-form [name="' + $tag_name + '"]').is("input[type='radio']")) { 136 var maybeChecked = ':checked'; 137 } 138 139 if (jQuery('.wpcf7-form [name="' + $tag_name + '"]').is("input[type='checkbox']")) { 140 141 var maybeChecked = ':checked'; 142 var maybeMultiple = '[]'; 143 144 var checked_values = []; 145 jQuery('.wpcf7-form [name="' + $tag_name + '"]:checked').each(function () { 146 147 checked_values.push(jQuery(this).val()); 148 }); 149 150 var index = checked_values.indexOf($uacf7_cf_conditions['uacf7_cf_val'][x]); 151 152 var checkedItem = checked_values[index]; 153 154 } 155 // //Repeater support 156 var tagName = $tag_name.replace('[]', ''); 157 158 if (jQuery('.wpcf7-form [uacf-original-name="' + $tag_name + '"]').is("input[type='checkbox']") || jQuery('.wpcf7-form [uacf-original-name="' + $tag_name + '"]').is("input[type='radio']")) { 159 160 var maybeChecked = ':checked'; 161 var maybeMultiple = '[]'; 162 163 var checked_values = []; 164 //Repeater support 165 jQuery('.wpcf7-form-control-wrap.' + tagName + ' input:checked').each(function () { 166 167 checked_values.push(jQuery(this).val()); 168 }); 169 170 var index = checked_values.indexOf($uacf7_cf_conditions['uacf7_cf_val'][x]); 171 172 var checkedItem = checked_values[index]; 173 174 } 175 if (typeof repeater_count === 'undefined') { 176 var currentValue = jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]' + maybeChecked + '').val(); 177 } else { 178 var current_field = jQuery('.wpcf7-form [uacf-original-name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]'); 179 if ($this == false) { 180 181 if (typeof current_field === 'undefined') { 182 var current_field = jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]'); 183 184 } else { 185 var currentValue = jQuery('.wpcf7-form [uacf-original-name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]' + maybeChecked + '').val(); 186 } 187 188 } else { 189 // console.log(current_field); 190 if (typeof current_field === 'undefined' || current_field.length == 0) { 191 var currentValue = jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]' + maybeChecked + '').val(); 192 } else { 193 var currentValue = repeater_weapper.find('[uacf-original-name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]' + maybeChecked + '').val(); 194 } 195 } 196 197 } 198 if (jQuery('.wpcf7-form [name="' + $uacf7_cf_conditions['uacf7_cf_tn'][x] + '"]').is("input[type='checkbox']")) { 199 200 if (typeof checkedItem === 'undefined') { 201 var currentValue = ''; 202 203 } else { 204 var currentValue = checkedItem; 205 } 206 207 208 } 209 210 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'equal') { 211 212 if (currentValue == $uacf7_cf_conditions['uacf7_cf_val'][x]) { 213 214 $conditions.push('true'); 215 216 } else { 217 $conditions.push('false'); 218 219 } 220 } 221 222 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'not_equal') { 223 224 if (currentValue != $uacf7_cf_conditions['uacf7_cf_val'][x]) { 225 226 $conditions.push('true'); 227 228 } else { 229 $conditions.push('false'); 230 231 } 232 } 233 234 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'greater_than') { 235 236 if (parseInt(currentValue) > parseInt($uacf7_cf_conditions['uacf7_cf_val'][x])) { 237 238 $conditions.push('true'); 239 240 } else { 241 $conditions.push('false'); 242 243 } 244 } 245 246 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'less_than') { 247 248 if (parseInt(currentValue) < parseInt($uacf7_cf_conditions['uacf7_cf_val'][x])) { 249 250 $conditions.push('true'); 251 252 } else { 253 $conditions.push('false'); 254 255 } 256 } 257 258 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'greater_than_or_equal_to') { 259 260 if (parseInt(currentValue) >= parseInt($uacf7_cf_conditions['uacf7_cf_val'][x])) { 261 262 $conditions.push('true'); 263 264 } else { 265 $conditions.push('false'); 266 267 } 268 } 269 270 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'less_than_or_equal_to') { 271 272 if (parseInt(currentValue) <= parseInt($uacf7_cf_conditions['uacf7_cf_val'][x])) { 273 274 $conditions.push('true'); 275 276 } else { 277 $conditions.push('false'); 278 279 } 280 } 281 282 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'starts_with') { 283 if (currentValue.startsWith($uacf7_cf_conditions['uacf7_cf_val'][x])) { 284 285 $conditions.push('true'); 286 287 } else { 288 $conditions.push('false'); 289 290 } 291 } 292 293 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'ends_with') { 294 if (currentValue.endsWith($uacf7_cf_conditions['uacf7_cf_val'][x])) { 295 296 $conditions.push('true'); 297 298 } else { 299 $conditions.push('false'); 300 301 } 302 } 303 304 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'contains') { 305 if (currentValue.includes($uacf7_cf_conditions['uacf7_cf_val'][x])) { 306 307 $conditions.push('true'); 308 309 } else { 310 $conditions.push('false'); 311 312 } 313 } 314 315 if ($uacf7_cf_conditions['uacf7_cf_operator'][x] == 'does_not_contain') { 316 if (!currentValue.includes($uacf7_cf_conditions['uacf7_cf_val'][x])) { 317 318 $conditions.push('true'); 319 320 } else { 321 $conditions.push('false'); 322 323 } 324 } 325 326 327 } 328 329 } 330 331 if (typeof repeater_count === 'undefined') { 332 var $this_condition = jQuery(repeater_weapper + '.' + form[$i]['uacf7_cf_group'] + ''); 333 } else { 334 if ($this == false) { 335 var $this_condition = jQuery('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + ''); 336 } else { 337 if (typeof $this.attr('uacf-original-name') === 'undefined' || $this.attr('uacf-original-name').length == 0) { 338 var $this_condition = jQuery(repeater_weapper + '.' + form[$i]['uacf7_cf_group'] + ''); 339 } else { 340 var $this_condition = repeater_weapper.find('.uacf7_conditional.' + form[$i]['uacf7_cf_group'] + ''); 341 } 342 } 343 } 344 345 if (form[$i]['uacf7_cf_condition_for'] === 'all') { 346 var equalResult = $conditions.indexOf("false"); 347 348 if (form[$i]['uacf7_cf_hs'] == 'show') { 349 if (equalResult == -1) { //IF not false and all true 350 $this_condition.show().removeClass('uacf7-hidden'); 351 $this_condition.attr('data-condition', 'true'); 352 } else { 353 $this_condition.hide().addClass('uacf7-hidden'); 354 $this_condition.attr('data-condition', 'false'); 355 } 356 357 } else { 358 if (equalResult == -1) { //IF not false and all true 359 $this_condition.hide().addClass('uacf7-hidden'); 360 $this_condition.attr('data-condition', 'true'); 361 } else { 362 $this_condition.show().removeClass('uacf7-hidden'); 363 $this_condition.attr('data-condition', 'false'); 364 } 365 } 366 } else { 367 var orResult = $conditions.indexOf("true"); 368 if (form[$i]['uacf7_cf_hs'] == 'show') { 369 if (orResult != -1) { //IF true or false 370 $this_condition.show().removeClass('uacf7-hidden'); 371 $this_condition.attr('data-condition', 'true'); 372 } else { 373 $this_condition.hide().addClass('uacf7-hidden'); 374 $this_condition.attr('data-condition', 'false'); 375 } 376 377 } else { 378 if (orResult == -1) { //IF true or false 379 $this_condition.show().removeClass('uacf7-hidden'); 380 $this_condition.attr('data-condition', 'true'); 381 } else { 382 $this_condition.hide().addClass('uacf7-hidden'); 383 $this_condition.attr('data-condition', 'false'); 384 } 385 } 386 } 387 } 388 $i++; 389 }); 390 }); 391 392 uacf7_skip_validation(); 393 } 394 /* 395 * Conditional script 396 */ 397 398 /* 399 * Skip validation 400 */ 401 function uacf7_skip_validation() { 402 403 jQuery('form.wpcf7-form').each(function () { 404 405 var $form = jQuery(this); 406 var hidden_fields = []; 407 jQuery('.uacf7_conditional', $form).each(function () { 408 var $this = jQuery(this); 409 410 if ($this.hasClass('uacf7-hidden')) { 411 412 $this.find('input,select,textarea').each(function () { 413 hidden_fields.push(jQuery(this).attr('name')); 414 }); 415 } 416 }); 417 $form.find('[name="_uacf7_hidden_conditional_fields"]').val(JSON.stringify(hidden_fields)); 418 419 $form.on('submit', function () { 420 uacf7_skip_validation(); 421 }); 422 423 }); 424 } 425 426})(jQuery); 427 428 429
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.