PluginProbe ʕ •ᴥ•ʔ
Conditional Fields for Contact Form 7 / 2.5.4
Conditional Fields for Contact Form 7 v2.5.4
2.7.10 2.7.9 2.7.8 2.7.7 2.7.6 2.7.5 2.7.4 2.7.3 2.7.2 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6.1 1.6.2 1.6.3 1.6.5 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2 2.2.1 2.2.10 2.2.11 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.10 2.3.11 2.3.12 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.7 2.7.1 trunk 0.1 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.2 0.2.1 0.2.2 0.2.3
cf7-conditional-fields / js / scripts_admin.js
cf7-conditional-fields / js Last commit date
polyfill.js 3 years ago scripts.js 1 year ago scripts.js.map 3 years ago scripts_admin copy.js 4 years ago scripts_admin.js 1 year ago scripts_admin_all_pages.js 2 years ago scripts_es6.js 3 years ago temp.js 4 years ago
scripts_admin.js
572 lines
1 /**
2 * These scripts are part of the Conditional Fields for Contact Form 7 plugin.
3 * Should only be loaded when editing a form in the WP backend.
4 */
5
6 let wpcf7cf_formcode = null; // used to detect if the form code has changed
7
8 var regexes = [
9 { label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
10 { label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
11 { label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
12 { label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
13 { label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
14 { label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
15 { label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
16 { label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
17 { label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
18 { label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
19 ];
20
21 var i = regexes.length;
22 while (i--) {
23 if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
24 regexes.splice(i,1);
25 }
26 }
27
28
29 if (typeof(_wpcf7) != 'undefined' || typeof(wpcf7) != 'undefined') {
30
31 var wpcf7cf = {};
32
33 wpcf7cf.MAX_CONDITIONS = 50;
34
35 wpcf7cf.operators = [
36 'equals',
37 'not equals',
38 'greater than',
39 'greater than or equals',
40 'less than',
41 'less than or equals',
42 'is empty',
43 'not empty',
44
45 ];
46
47 wpcf7cf.$newEntry = jQuery(`<div class="entry">
48 <div class="wpcf7cf-if">
49 <span class="label">Show</span>
50 <select class="then-field-select"></select>
51 </div>
52 <div class="wpcf7cf-and-rules ui-sortable" data-next-index="1">
53 <div class="wpcf7cf-and-rule ui-sortable-handle">
54 <span class="rule-part if-txt label">if</span>
55 <select class="rule-part if-field-select"></select>
56 <select class="rule-part operator">${ wpcf7cf.operators.map(o => `<option value="${o}">${o}</option>`) }</select>
57 <input class="rule-part if-value" type="text" placeholder="value" value="" style="visibility: visible;">
58 <span class="and-button" style="height: 22px; line-height: 22px;">And</span>
59 <span title="delete rule" class="rule-part delete-button">remove</span>
60 </div>
61 </div>
62 </div>`);
63 wpcf7cf.$textView = jQuery('#wpcf7cf-settings-text').eq(0);
64 wpcf7cf.$textOnlyCheckbox = jQuery('#wpcf7cf-text-only-checkbox').eq(0);
65 wpcf7cf.$textOnlyLinks = jQuery('.wpcf7cf-switch-to-txt-link');
66 wpcf7cf.$entriesUi = jQuery('#wpcf7cf-entries-ui').eq(0);
67 wpcf7cf.$addButton = jQuery('#wpcf7cf-add-button').eq(0);
68 wpcf7cf.$maxReachedWarning = jQuery('#wpcf7cf-a-lot-of-conditions').eq(0);
69 wpcf7cf.$formEditorForm = jQuery('#wpcf7-admin-form-element').eq(0);
70 wpcf7cf.$formEditor = jQuery('#wpcf7-form').eq(0);
71
72 // Smart Grid compat https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/
73 if(jQuery('#cf7sg-editor').length>0) wpcf7cf.$formEditorForm = jQuery('form#post').eq(0);
74
75 wpcf7cf.regexCondition = /(?:show \[([^\]]*?)\]) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
76 wpcf7cf.regexConditionAnd = /and if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
77
78 wpcf7cf.transformConditionsFromStringToArrayOfObjects = function(str) {
79
80 if (!str) str = '';
81
82 var conditionsAsStrings = str.split(/\r?\n(?=show)/);
83 var conditionsAsObjects = [];
84 for (var i = 0; i<conditionsAsStrings.length; i++) {
85
86 var lines = conditionsAsStrings[i].split(/\r?\n/);
87
88 wpcf7cf.regexCondition.lastIndex = 0;
89 var line1Match = wpcf7cf.regexCondition.exec(lines[0]);
90
91 if (line1Match != null) {
92
93 var conditionObject = {
94 then_field:line1Match[1],
95 and_rules: [
96 {
97 if_field: line1Match[2],
98 operator: line1Match[3],
99 if_value: line1Match[4],
100 },
101 ],
102 };
103
104 for(var and_i = 1; and_i < lines.length; and_i++) {
105 wpcf7cf.regexConditionAnd.lastIndex = 0;
106 lineMatch = wpcf7cf.regexConditionAnd.exec(lines[and_i]);
107 if (lineMatch != null) {
108 conditionObject.and_rules.push({
109 if_field: lineMatch[1],
110 operator: lineMatch[2],
111 if_value: lineMatch[3],
112 });
113 }
114 }
115
116 conditionsAsObjects.push(conditionObject);
117
118 }
119 }
120 return conditionsAsObjects;
121 }
122
123 wpcf7cf.getnumberOfTextEntries = function () {
124 const textConditions = wpcf7cf.transformConditionsFromStringToArrayOfObjects(wpcf7cf.$textView.val());
125 return textConditions.length;
126 }
127
128 wpcf7cf.getnumberOfFieldEntries = function () {
129 return wpcf7cf.$entriesUi.find('.entry').length;
130 }
131
132 wpcf7cf.transformConditionsFromArrayOfObjectsToString = function(conditions) {
133 return conditions.map(function(condition){
134 var indent = ' '.repeat(condition.then_field.length + 4);
135 return `show [${condition.then_field}] `+condition.and_rules.map(function(rule, i){
136 return ( i>0 ? indent+'and ':'' ) + `if [${rule.if_field}] ${rule.operator} "${rule.if_value}"`
137 }).join('\n');
138 }).join('\n');
139 }
140
141 /**
142 * Tranform an array of conditions (Objects) to HTML fields
143 * @param Array conditions
144 * @returns jQuery
145 */
146 wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements = function(conditions) {
147
148 if ( wpcf7cf.MAX_CONDITIONS < conditions.length ) {
149 jQuery('#wpcf7cf-entries').html('');
150 wpcf7cf.maybeDisableAddButton();
151 return;
152 }
153
154 var entries = [];
155
156 for (var c_i = 0; c_i<conditions.length; c_i++) {
157
158 var condition = conditions[c_i];
159 var id=0;
160
161 // setup then_field
162 var $entry = jQuery(wpcf7cf.template_for_condition_fields_without_and_rules);
163 jQuery('.then-field-select', $entry).val(condition.then_field);
164
165 for (var a_i = 0; a_i < condition.and_rules.length; a_i++) {
166 var and_rule = condition.and_rules[a_i];
167
168 $rule = jQuery(wpcf7cf.template_for_and_rule);
169
170 jQuery('.if-field-select', $rule).val(and_rule.if_field);
171 jQuery('.operator', $rule).val(and_rule.operator);
172 jQuery('.if-value', $rule).val(and_rule.if_value);
173
174 jQuery('.wpcf7cf-and-rules', $entry).eq(0).append($rule);
175
176 }
177
178 entries.push($entry);
179 }
180
181 jQuery('#wpcf7cf-entries').html(entries);
182
183 updateDisplayOfEntries();
184
185 }
186
187 wpcf7cf.isMaxConditionsReached = function() {
188 return wpcf7cf.getnumberOfTextEntries() >= wpcf7cf.MAX_CONDITIONS && wpcf7cf.getnumberOfFieldEntries() == 0 ||
189 wpcf7cf.getnumberOfFieldEntries() >= wpcf7cf.MAX_CONDITIONS;
190
191 }
192
193 wpcf7cf.maybeDisableAddButton = function() {
194 if (wpcf7cf.isMaxConditionsReached()) {
195 wpcf7cf.$addButton.hide();
196 wpcf7cf.$maxReachedWarning.show();
197 } else {
198 wpcf7cf.$addButton.show();
199 wpcf7cf.$maxReachedWarning.hide();
200 }
201 }
202
203 wpcf7cf.transformConditionsFromFieldsToArrayOfObjects = function($entries) {
204
205 if (!$entries) {
206 $entries = jQuery('#wpcf7cf-entries .entry');
207 }
208
209 var conditionsAsObjects = [];
210
211 $entries.each(function() {
212
213 var $entry = jQuery(this);
214 var then_field = $entry.find('.then-field-select').val() ?? '';
215
216 var conditionObject = {
217 then_field: then_field,
218 and_rules: [],
219 };
220
221 $entry.find('.wpcf7cf-and-rule').each(function(i) {
222 const $and_rule = jQuery(this);
223 conditionObject.and_rules.push({
224 operator : $and_rule.find('.operator').val() ?? '',
225 if_field : $and_rule.find('.if-field-select').val() ?? '',
226 if_value : $and_rule.find('.if-value').val() ?? '',
227 });
228 });
229
230 conditionsAsObjects.push(conditionObject);
231
232 });
233
234 return conditionsAsObjects;
235 }
236
237
238 wpcf7cf.copyTextToFields = function() {
239 var str = wpcf7cf.$textView.val();
240 var obj = wpcf7cf.transformConditionsFromStringToArrayOfObjects(str);
241 wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements(obj);
242 wpcf7cf.setDefaultValues();
243 }
244
245 wpcf7cf.copyFieldsToText = function() {
246 var obj = wpcf7cf.transformConditionsFromFieldsToArrayOfObjects();
247 var str = wpcf7cf.transformConditionsFromArrayOfObjectsToString(obj);
248 wpcf7cf.$textView.val(str);
249 }
250
251 function add_condition_fields() {
252 $c = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule)
253 $c.appendTo('#wpcf7cf-entries');
254 updateDisplayOfEntries();
255 }
256
257 /**
258 * Update visibility / autocomplete and some other visual properties based on the selected conditions.
259 */
260 function updateDisplayOfEntries() {
261 wpcf7cf.$if_values = jQuery('.if-value');
262 init_autocomplete();
263 wpcf7cf.$if_values.css({'visibility':'visible'});
264 wpcf7cf.$if_values.autocomplete( "disable" );
265
266 jQuery('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
267 var $and_rule = jQuery(this);
268 var $operatorField = $and_rule.find('.operator').eq(0);
269 var operator = $operatorField.val() || 'equals';
270 if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
271 $and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
272 } else if (operator.endsWith('(regex)')) {
273 $and_rule.find('.if-value').eq(0).autocomplete( "enable" );
274 }
275 });
276
277 scale_and_button();
278
279 set_events();
280
281 wpcf7cf.maybeDisableAddButton();
282 }
283
284 function init_autocomplete() {
285
286 wpcf7cf.$if_values.autocomplete({
287 disabled: true,
288 source: function(request, response) {
289 var matcher = new RegExp(jQuery.ui.autocomplete.escapeRegex(request.term), "i");
290 response(jQuery.grep(regexes, function(value) {
291 return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
292 }));
293 },
294 focus: function( event, ui ) {
295 jQuery( event.target ).val( ui.item.desc );
296 return false;
297 },
298 select: function( event, ui ) {
299 jQuery( event.target ).val( ui.item.desc );
300 return false;
301 },
302 open: function(e,ui) {
303 $el = jQuery(e.target);
304 var styledTerm = `<span class='ui-autocomplete-term'>${$el.val()}</span>`;
305
306 jQuery('.ui-autocomplete').find('em').each(function() {
307 var me = jQuery(this);
308 me.html( me.text().replace($el.val(), styledTerm) );
309 });
310 },
311 minLength: 0
312 }).each(function() {
313 jQuery(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
314 return jQuery("<li>")
315 .append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
316 .appendTo(ul);
317 }
318 });
319 wpcf7cf.$if_values.on('focus', function() {
320 jQuery(this).autocomplete("search");
321 });
322 }
323
324 function set_events() { // called at the end of updateDisplayOfEntries
325
326 jQuery('.wpcf7cf-and-rules').sortable();
327
328 jQuery('.and-button').off('click').click(function() {
329 $this = jQuery(this);
330 $andblock = $this.closest('.wpcf7cf-and-rule');
331 $andblocks_container = $this.closest('.wpcf7cf-and-rules');
332 next_index = $andblocks_container.data('next-index');
333 $andblocks_container.data('next-index',next_index+1);
334 var and_i = next_index;
335 clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
336 $andblock.after(clone_html);
337 updateDisplayOfEntries();
338 wpcf7cf.copyFieldsToText();
339 return false;
340 });
341
342 jQuery('.delete-button').off('click').click(function(){
343 $and_rule = jQuery(this).closest('.wpcf7cf-and-rule');
344 if ($and_rule.siblings().length > 0) {
345 $and_rule.remove();
346 } else {
347 $and_rule[0].closest('.entry').remove();
348 }
349 updateDisplayOfEntries();
350 wpcf7cf.copyFieldsToText();
351 return false;
352 });
353
354 jQuery('.operator').on('change', (function() {
355 updateDisplayOfEntries();
356 wpcf7cf.copyFieldsToText();
357 return false;
358 }));
359 }
360
361 function scale_and_button() {
362 jQuery('.wpcf7cf-and-rule:first-child .and-button').each(function(){
363 $and_button = jQuery(this);
364 num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
365 var height = (34*num_and_rules-12)+'px';
366 $and_button.css({'height':height,'line-height':height});
367 });
368 }
369
370 // ------------------------------------
371 // TOOGGLE UI MODE
372 // ------------------------------------
373
374 /**
375 * Make either Text-only view or field view visible.
376 *
377 * @param {boolean} is_text_only `true` to show text-only view. `false` for fields view
378 */
379 wpcf7cf.setViewMode = function(is_text_only) {
380 if (is_text_only) {
381 wpcf7cf.currentMode = 'text';
382 wpcf7cf.$entriesUi.hide();
383 wpcf7cf.$textView.show();
384 if (wpcf7cf.getnumberOfFieldEntries() > 0) {
385 wpcf7cf.copyFieldsToText();
386 }
387 } else {
388 wpcf7cf.currentMode = 'normal';
389 wpcf7cf.$entriesUi.show();
390 wpcf7cf.$textView.hide();
391 wpcf7cf.copyTextToFields();
392 }
393 }
394
395 wpcf7cf.$textOnlyLinks.on( 'click', function() {
396 wpcf7cf.$textOnlyCheckbox.prop('checked', true).trigger('change');
397 return false;
398 } )
399
400 wpcf7cf.$textOnlyCheckbox.on('change', function() {
401 wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
402 });
403
404 wpcf7cf.$formEditorForm.on('submit', function() {
405 if (wpcf7cf.currentMode == 'normal' && wpcf7cf.getnumberOfFieldEntries() > 0) {
406 wpcf7cf.copyFieldsToText();
407 }
408 });
409
410 wpcf7cf.$entriesUi.on('change', function(){
411 wpcf7cf.copyFieldsToText();
412 });
413
414
415 // ------------------------------------
416 // CF7 TAG GENERATOR OVERRIDE
417 // ------------------------------------
418
419 window.addEventListener('load', function() {
420
421 document.querySelectorAll(
422 '[data-taggen="open-dialog"]'
423 ).forEach( button => {
424 button.addEventListener( 'click', event => {
425 const dialog = document.querySelector( `#${ button.dataset.target }` );
426 if (!dialog) {
427 return true;
428 }
429 const form = dialog.querySelector( 'form.tag-generator-panel' );
430 if (!form) {
431 return true;
432 }
433 setTimeout( function() {
434 wpcf7cf.updateTagGenerator(form);
435 }, 10 );
436 } );
437 } );
438
439 document.querySelectorAll('form.tag-generator-panel .control-box input').forEach(function(input){
440 const form = input.closest('form.tag-generator-panel');
441 if (!form) { return; }
442 setTimeout( function() {
443 wpcf7cf.updateTagGenerator(form);
444 }, 10 );
445 input.addEventListener('keyup', function(e) {
446 wpcf7cf.updateTagGenerator(form);
447 });
448 input.addEventListener('change', function(e) {
449 wpcf7cf.updateTagGenerator(form);
450 });
451 });
452 });
453
454 wpcf7cf.updateTagGenerator = function( form ) {
455 setTimeout( function() {
456 form.querySelectorAll(
457 '[data-tag-part="mail-tag-closed"]'
458 ).forEach( tag => {
459 const nameField = form.querySelector( '[data-tag-part="name"]' );
460
461 if ( nameField ) {
462 tag.innerText = `[/${ nameField.value.trim() }]`;
463 }
464 } );
465 }, 10 );
466 };
467
468
469
470
471
472
473 function scanFormTags(formCode) {
474 const fields = [...formCode.matchAll(/\[(?!group|step|repeater|submit)[^\] ]+ ([^\] ]+)/g)].map(e=>e[1]);
475 const groups = [...formCode.matchAll(/\[group ([^\] ]+)/g)].map(e=>e[1]);
476 return [ fields, groups ];
477 }
478
479 function updateAvailableGroupsAndFields() {
480 const formCode = wpcf7cf.$formEditor.val();
481 const [ fields, groups ] = scanFormTags(formCode);
482
483 $temp = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule);
484 $temp.find('.then-field-select').eq(0).html(createOptionsHTML(groups, 'group'));
485 $temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
486 // $temp.find('.operator').eq(0).html(createOptionsHTML(wpcf7cf.operators, null));
487 wpcf7cf.template_for_condition_fields_with_one_and_rule = $temp[0].outerHTML;
488
489 $temp.find('.wpcf7cf-and-rules').eq(0).html('');
490 wpcf7cf.template_for_condition_fields_without_and_rules = $temp[0].outerHTML;
491
492 $temp = jQuery(wpcf7cf.template_for_and_rule);
493 $temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
494 wpcf7cf.template_for_and_rule = $temp[0].outerHTML;
495
496 jQuery('.then-field-select').each(function(){
497 const $this = jQuery(this);
498 updateSelectWithValues($this, groups, 'group');
499 });
500 jQuery('.if-field-select').each(function(){
501 const $this = jQuery(this);
502 updateSelectWithValues($this, fields, 'field');
503 });
504 }
505
506 function updateSelectWithValues($select, values, type) {
507 $select.html(createOptionsHTML(values, type));
508 }
509
510 function createOptionsHTML(values, type) {
511 return (type?`<option value="-1">-- Select ${type} --</option>`:'')+values.map(value => `<option value="${value}">${value}</option>`).join('');
512 }
513
514 /**
515 * Set the default value of all fields to their current value.
516 * This prevents CF7 to show an unsaved-changes warning on these fields.
517 * (The single source of truth is the value in the text view.)
518 */
519 wpcf7cf.setDefaultValues = function() {
520 jQuery('#wpcf7cf-entries select').each(function() {
521 const $select = jQuery(this);
522 let selectedIndex = $select.prop('selectedIndex');
523 if (selectedIndex == -1) {
524 selectedIndex = 0;
525 }
526 $select.find('option').removeAttr('selected');
527 $select.find(`option:eq(${selectedIndex})`).prop('selected', 'selected').attr('selected', 'selected');
528 })
529
530 jQuery('#wpcf7cf-entries .if-value').each(function(){
531 const $input = jQuery(this);
532 $input.attr('value',$input.val());
533 });
534 }
535
536 // update available groups and fields each time there is a change in the form code.
537 wpcf7cf.$formEditor.on('change focusout', function() {
538 if( !wpcf7cf_formcode || wpcf7cf_formcode !== this.value ) {
539 wpcf7cf_formcode = this.value;
540 updateAvailableGroupsAndFields();
541 if (!wpcf7cf.isMaxConditionsReached()) {
542 wpcf7cf.copyTextToFields();
543 wpcf7cf.copyFieldsToText();
544 }
545 }
546 });
547
548 wpcf7cf.$addButton.click(function(){
549 add_condition_fields();
550 wpcf7cf.copyFieldsToText();
551 });
552
553 jQuery(document).ready(function() {
554
555 wpcf7cf.$if_values = jQuery('.if-value'); // gets updated now and then
556
557 // init HTML templates (will be updated immediatly by updateAvailableGroupsAndFields())
558 wpcf7cf.template_for_condition_fields_with_one_and_rule = wpcf7cf.$newEntry[0].outerHTML;
559 wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
560
561 updateAvailableGroupsAndFields();
562 wpcf7cf.copyTextToFields();
563
564 wpcf7cf.maybeDisableAddButton();
565
566 jQuery('#wpcf7cf-entries').sortable();
567
568 wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
569
570 })
571
572 }