PluginProbe ʕ •ᴥ•ʔ
Conditional Fields for Contact Form 7 / 2.6
Conditional Fields for Contact Form 7 v2.6
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
574 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 'equals (regex)',
45 'not equals (regex)',
46
47 ];
48
49 wpcf7cf.$newEntry = jQuery(`<div class="entry">
50 <div class="wpcf7cf-if">
51 <span class="label">Show</span>
52 <select class="then-field-select"></select>
53 </div>
54 <div class="wpcf7cf-and-rules ui-sortable" data-next-index="1">
55 <div class="wpcf7cf-and-rule ui-sortable-handle">
56 <span class="rule-part if-txt label">if</span>
57 <select class="rule-part if-field-select"></select>
58 <select class="rule-part operator">${ wpcf7cf.operators.map(o => `<option value="${o}">${o}</option>`) }</select>
59 <input class="rule-part if-value" type="text" placeholder="value" value="" style="visibility: visible;">
60 <span class="and-button" style="height: 22px; line-height: 22px;">And</span>
61 <span title="delete rule" class="rule-part delete-button">remove</span>
62 </div>
63 </div>
64 </div>`);
65 wpcf7cf.$textView = jQuery('#wpcf7cf-settings-text').eq(0);
66 wpcf7cf.$textOnlyCheckbox = jQuery('#wpcf7cf-text-only-checkbox').eq(0);
67 wpcf7cf.$textOnlyLinks = jQuery('.wpcf7cf-switch-to-txt-link');
68 wpcf7cf.$entriesUi = jQuery('#wpcf7cf-entries-ui').eq(0);
69 wpcf7cf.$addButton = jQuery('#wpcf7cf-add-button').eq(0);
70 wpcf7cf.$maxReachedWarning = jQuery('#wpcf7cf-a-lot-of-conditions').eq(0);
71 wpcf7cf.$formEditorForm = jQuery('#wpcf7-admin-form-element').eq(0);
72 wpcf7cf.$formEditor = jQuery('#wpcf7-form').eq(0);
73
74 // Smart Grid compat https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/
75 if(jQuery('#cf7sg-editor').length>0) wpcf7cf.$formEditorForm = jQuery('form#post').eq(0);
76
77 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;
78 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;
79
80 wpcf7cf.transformConditionsFromStringToArrayOfObjects = function(str) {
81
82 if (!str) str = '';
83
84 var conditionsAsStrings = str.split(/\r?\n(?=show)/);
85 var conditionsAsObjects = [];
86 for (var i = 0; i<conditionsAsStrings.length; i++) {
87
88 var lines = conditionsAsStrings[i].split(/\r?\n/);
89
90 wpcf7cf.regexCondition.lastIndex = 0;
91 var line1Match = wpcf7cf.regexCondition.exec(lines[0]);
92
93 if (line1Match != null) {
94
95 var conditionObject = {
96 then_field:line1Match[1],
97 and_rules: [
98 {
99 if_field: line1Match[2],
100 operator: line1Match[3],
101 if_value: line1Match[4],
102 },
103 ],
104 };
105
106 for(var and_i = 1; and_i < lines.length; and_i++) {
107 wpcf7cf.regexConditionAnd.lastIndex = 0;
108 lineMatch = wpcf7cf.regexConditionAnd.exec(lines[and_i]);
109 if (lineMatch != null) {
110 conditionObject.and_rules.push({
111 if_field: lineMatch[1],
112 operator: lineMatch[2],
113 if_value: lineMatch[3],
114 });
115 }
116 }
117
118 conditionsAsObjects.push(conditionObject);
119
120 }
121 }
122 return conditionsAsObjects;
123 }
124
125 wpcf7cf.getnumberOfTextEntries = function () {
126 const textConditions = wpcf7cf.transformConditionsFromStringToArrayOfObjects(wpcf7cf.$textView.val());
127 return textConditions.length;
128 }
129
130 wpcf7cf.getnumberOfFieldEntries = function () {
131 return wpcf7cf.$entriesUi.find('.entry').length;
132 }
133
134 wpcf7cf.transformConditionsFromArrayOfObjectsToString = function(conditions) {
135 return conditions.map(function(condition){
136 var indent = ' '.repeat(condition.then_field.length + 4);
137 return `show [${condition.then_field}] `+condition.and_rules.map(function(rule, i){
138 return ( i>0 ? indent+'and ':'' ) + `if [${rule.if_field}] ${rule.operator} "${rule.if_value}"`
139 }).join('\n');
140 }).join('\n');
141 }
142
143 /**
144 * Tranform an array of conditions (Objects) to HTML fields
145 * @param Array conditions
146 * @returns jQuery
147 */
148 wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements = function(conditions) {
149
150 if ( wpcf7cf.MAX_CONDITIONS < conditions.length ) {
151 jQuery('#wpcf7cf-entries').html('');
152 wpcf7cf.maybeDisableAddButton();
153 return;
154 }
155
156 var entries = [];
157
158 for (var c_i = 0; c_i<conditions.length; c_i++) {
159
160 var condition = conditions[c_i];
161 var id=0;
162
163 // setup then_field
164 var $entry = jQuery(wpcf7cf.template_for_condition_fields_without_and_rules);
165 jQuery('.then-field-select', $entry).val(condition.then_field);
166
167 for (var a_i = 0; a_i < condition.and_rules.length; a_i++) {
168 var and_rule = condition.and_rules[a_i];
169
170 $rule = jQuery(wpcf7cf.template_for_and_rule);
171
172 jQuery('.if-field-select', $rule).val(and_rule.if_field);
173 jQuery('.operator', $rule).val(and_rule.operator);
174 jQuery('.if-value', $rule).val(and_rule.if_value);
175
176 jQuery('.wpcf7cf-and-rules', $entry).eq(0).append($rule);
177
178 }
179
180 entries.push($entry);
181 }
182
183 jQuery('#wpcf7cf-entries').html(entries);
184
185 updateDisplayOfEntries();
186
187 }
188
189 wpcf7cf.isMaxConditionsReached = function() {
190 return wpcf7cf.getnumberOfTextEntries() >= wpcf7cf.MAX_CONDITIONS && wpcf7cf.getnumberOfFieldEntries() == 0 ||
191 wpcf7cf.getnumberOfFieldEntries() >= wpcf7cf.MAX_CONDITIONS;
192
193 }
194
195 wpcf7cf.maybeDisableAddButton = function() {
196 if (wpcf7cf.isMaxConditionsReached()) {
197 wpcf7cf.$addButton.hide();
198 wpcf7cf.$maxReachedWarning.show();
199 } else {
200 wpcf7cf.$addButton.show();
201 wpcf7cf.$maxReachedWarning.hide();
202 }
203 }
204
205 wpcf7cf.transformConditionsFromFieldsToArrayOfObjects = function($entries) {
206
207 if (!$entries) {
208 $entries = jQuery('#wpcf7cf-entries .entry');
209 }
210
211 var conditionsAsObjects = [];
212
213 $entries.each(function() {
214
215 var $entry = jQuery(this);
216 var then_field = $entry.find('.then-field-select').val() ?? '';
217
218 var conditionObject = {
219 then_field: then_field,
220 and_rules: [],
221 };
222
223 $entry.find('.wpcf7cf-and-rule').each(function(i) {
224 const $and_rule = jQuery(this);
225 conditionObject.and_rules.push({
226 operator : $and_rule.find('.operator').val() ?? '',
227 if_field : $and_rule.find('.if-field-select').val() ?? '',
228 if_value : $and_rule.find('.if-value').val() ?? '',
229 });
230 });
231
232 conditionsAsObjects.push(conditionObject);
233
234 });
235
236 return conditionsAsObjects;
237 }
238
239
240 wpcf7cf.copyTextToFields = function() {
241 var str = wpcf7cf.$textView.val();
242 var obj = wpcf7cf.transformConditionsFromStringToArrayOfObjects(str);
243 wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements(obj);
244 wpcf7cf.setDefaultValues();
245 }
246
247 wpcf7cf.copyFieldsToText = function() {
248 var obj = wpcf7cf.transformConditionsFromFieldsToArrayOfObjects();
249 var str = wpcf7cf.transformConditionsFromArrayOfObjectsToString(obj);
250 wpcf7cf.$textView.val(str);
251 }
252
253 function add_condition_fields() {
254 $c = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule)
255 $c.appendTo('#wpcf7cf-entries');
256 updateDisplayOfEntries();
257 }
258
259 /**
260 * Update visibility / autocomplete and some other visual properties based on the selected conditions.
261 */
262 function updateDisplayOfEntries() {
263 wpcf7cf.$if_values = jQuery('.if-value');
264 init_autocomplete();
265 wpcf7cf.$if_values.css({'visibility':'visible'});
266 wpcf7cf.$if_values.autocomplete( "disable" );
267
268 jQuery('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
269 var $and_rule = jQuery(this);
270 var $operatorField = $and_rule.find('.operator').eq(0);
271 var operator = $operatorField.val() || 'equals';
272 if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
273 $and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
274 } else if (operator.endsWith('(regex)')) {
275 $and_rule.find('.if-value').eq(0).autocomplete( "enable" );
276 }
277 });
278
279 scale_and_button();
280
281 set_events();
282
283 wpcf7cf.maybeDisableAddButton();
284 }
285
286 function init_autocomplete() {
287
288 wpcf7cf.$if_values.autocomplete({
289 disabled: true,
290 source: function(request, response) {
291 var matcher = new RegExp(jQuery.ui.autocomplete.escapeRegex(request.term), "i");
292 response(jQuery.grep(regexes, function(value) {
293 return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
294 }));
295 },
296 focus: function( event, ui ) {
297 jQuery( event.target ).val( ui.item.desc );
298 return false;
299 },
300 select: function( event, ui ) {
301 jQuery( event.target ).val( ui.item.desc );
302 return false;
303 },
304 open: function(e,ui) {
305 $el = jQuery(e.target);
306 var styledTerm = `<span class='ui-autocomplete-term'>${$el.val()}</span>`;
307
308 jQuery('.ui-autocomplete').find('em').each(function() {
309 var me = jQuery(this);
310 me.html( me.text().replace($el.val(), styledTerm) );
311 });
312 },
313 minLength: 0
314 }).each(function() {
315 jQuery(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
316 return jQuery("<li>")
317 .append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
318 .appendTo(ul);
319 }
320 });
321 wpcf7cf.$if_values.on('focus', function() {
322 jQuery(this).autocomplete("search");
323 });
324 }
325
326 function set_events() { // called at the end of updateDisplayOfEntries
327
328 jQuery('.wpcf7cf-and-rules').sortable();
329
330 jQuery('.and-button').off('click').click(function() {
331 $this = jQuery(this);
332 $andblock = $this.closest('.wpcf7cf-and-rule');
333 $andblocks_container = $this.closest('.wpcf7cf-and-rules');
334 next_index = $andblocks_container.data('next-index');
335 $andblocks_container.data('next-index',next_index+1);
336 var and_i = next_index;
337 clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
338 $andblock.after(clone_html);
339 updateDisplayOfEntries();
340 wpcf7cf.copyFieldsToText();
341 return false;
342 });
343
344 jQuery('.delete-button').off('click').click(function(){
345 $and_rule = jQuery(this).closest('.wpcf7cf-and-rule');
346 if ($and_rule.siblings().length > 0) {
347 $and_rule.remove();
348 } else {
349 $and_rule[0].closest('.entry').remove();
350 }
351 updateDisplayOfEntries();
352 wpcf7cf.copyFieldsToText();
353 return false;
354 });
355
356 jQuery('.operator').on('change', (function() {
357 updateDisplayOfEntries();
358 wpcf7cf.copyFieldsToText();
359 return false;
360 }));
361 }
362
363 function scale_and_button() {
364 jQuery('.wpcf7cf-and-rule:first-child .and-button').each(function(){
365 $and_button = jQuery(this);
366 num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
367 var height = (34*num_and_rules-12)+'px';
368 $and_button.css({'height':height,'line-height':height});
369 });
370 }
371
372 // ------------------------------------
373 // TOOGGLE UI MODE
374 // ------------------------------------
375
376 /**
377 * Make either Text-only view or field view visible.
378 *
379 * @param {boolean} is_text_only `true` to show text-only view. `false` for fields view
380 */
381 wpcf7cf.setViewMode = function(is_text_only) {
382 if (is_text_only) {
383 wpcf7cf.currentMode = 'text';
384 wpcf7cf.$entriesUi.hide();
385 wpcf7cf.$textView.show();
386 if (wpcf7cf.getnumberOfFieldEntries() > 0) {
387 wpcf7cf.copyFieldsToText();
388 }
389 } else {
390 wpcf7cf.currentMode = 'normal';
391 wpcf7cf.$entriesUi.show();
392 wpcf7cf.$textView.hide();
393 wpcf7cf.copyTextToFields();
394 }
395 }
396
397 wpcf7cf.$textOnlyLinks.on( 'click', function() {
398 wpcf7cf.$textOnlyCheckbox.prop('checked', true).trigger('change');
399 return false;
400 } )
401
402 wpcf7cf.$textOnlyCheckbox.on('change', function() {
403 wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
404 });
405
406 wpcf7cf.$formEditorForm.on('submit', function() {
407 if (wpcf7cf.currentMode == 'normal' && wpcf7cf.getnumberOfFieldEntries() > 0) {
408 wpcf7cf.copyFieldsToText();
409 }
410 });
411
412 wpcf7cf.$entriesUi.on('change', function(){
413 wpcf7cf.copyFieldsToText();
414 });
415
416
417 // ------------------------------------
418 // CF7 TAG GENERATOR OVERRIDE
419 // ------------------------------------
420
421 window.addEventListener('load', function() {
422
423 document.querySelectorAll(
424 '[data-taggen="open-dialog"]'
425 ).forEach( button => {
426 button.addEventListener( 'click', event => {
427 const dialog = document.querySelector( `#${ button.dataset.target }` );
428 if (!dialog) {
429 return true;
430 }
431 const form = dialog.querySelector( 'form.tag-generator-panel' );
432 if (!form) {
433 return true;
434 }
435 setTimeout( function() {
436 wpcf7cf.updateTagGenerator(form);
437 }, 10 );
438 } );
439 } );
440
441 document.querySelectorAll('form.tag-generator-panel .control-box input').forEach(function(input){
442 const form = input.closest('form.tag-generator-panel');
443 if (!form) { return; }
444 setTimeout( function() {
445 wpcf7cf.updateTagGenerator(form);
446 }, 10 );
447 input.addEventListener('keyup', function(e) {
448 wpcf7cf.updateTagGenerator(form);
449 });
450 input.addEventListener('change', function(e) {
451 wpcf7cf.updateTagGenerator(form);
452 });
453 });
454 });
455
456 wpcf7cf.updateTagGenerator = function( form ) {
457 setTimeout( function() {
458 form.querySelectorAll(
459 '[data-tag-part="mail-tag-closed"]'
460 ).forEach( tag => {
461 const nameField = form.querySelector( '[data-tag-part="name"]' );
462
463 if ( nameField ) {
464 tag.innerText = `[/${ nameField.value.trim() }]`;
465 }
466 } );
467 }, 10 );
468 };
469
470
471
472
473
474
475 function scanFormTags(formCode) {
476 const fields = [...formCode.matchAll(/\[(?!group|step|repeater|submit)[^\] ]+ ([^\] ]+)/g)].map(e=>e[1]);
477 const groups = [...formCode.matchAll(/\[group ([^\] ]+)/g)].map(e=>e[1]);
478 return [ fields, groups ];
479 }
480
481 function updateAvailableGroupsAndFields() {
482 const formCode = wpcf7cf.$formEditor.val();
483 const [ fields, groups ] = scanFormTags(formCode);
484
485 $temp = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule);
486 $temp.find('.then-field-select').eq(0).html(createOptionsHTML(groups, 'group'));
487 $temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
488 // $temp.find('.operator').eq(0).html(createOptionsHTML(wpcf7cf.operators, null));
489 wpcf7cf.template_for_condition_fields_with_one_and_rule = $temp[0].outerHTML;
490
491 $temp.find('.wpcf7cf-and-rules').eq(0).html('');
492 wpcf7cf.template_for_condition_fields_without_and_rules = $temp[0].outerHTML;
493
494 $temp = jQuery(wpcf7cf.template_for_and_rule);
495 $temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
496 wpcf7cf.template_for_and_rule = $temp[0].outerHTML;
497
498 jQuery('.then-field-select').each(function(){
499 const $this = jQuery(this);
500 updateSelectWithValues($this, groups, 'group');
501 });
502 jQuery('.if-field-select').each(function(){
503 const $this = jQuery(this);
504 updateSelectWithValues($this, fields, 'field');
505 });
506 }
507
508 function updateSelectWithValues($select, values, type) {
509 $select.html(createOptionsHTML(values, type));
510 }
511
512 function createOptionsHTML(values, type) {
513 return (type?`<option value="-1">-- Select ${type} --</option>`:'')+values.map(value => `<option value="${value}">${value}</option>`).join('');
514 }
515
516 /**
517 * Set the default value of all fields to their current value.
518 * This prevents CF7 to show an unsaved-changes warning on these fields.
519 * (The single source of truth is the value in the text view.)
520 */
521 wpcf7cf.setDefaultValues = function() {
522 jQuery('#wpcf7cf-entries select').each(function() {
523 const $select = jQuery(this);
524 let selectedIndex = $select.prop('selectedIndex');
525 if (selectedIndex == -1) {
526 selectedIndex = 0;
527 }
528 $select.find('option').removeAttr('selected');
529 $select.find(`option:eq(${selectedIndex})`).prop('selected', 'selected').attr('selected', 'selected');
530 })
531
532 jQuery('#wpcf7cf-entries .if-value').each(function(){
533 const $input = jQuery(this);
534 $input.attr('value',$input.val());
535 });
536 }
537
538 // update available groups and fields each time there is a change in the form code.
539 wpcf7cf.$formEditor.on('change focusout', function() {
540 if( !wpcf7cf_formcode || wpcf7cf_formcode !== this.value ) {
541 wpcf7cf_formcode = this.value;
542 updateAvailableGroupsAndFields();
543 if (!wpcf7cf.isMaxConditionsReached()) {
544 wpcf7cf.copyTextToFields();
545 wpcf7cf.copyFieldsToText();
546 }
547 }
548 });
549
550 wpcf7cf.$addButton.click(function(){
551 add_condition_fields();
552 wpcf7cf.copyFieldsToText();
553 });
554
555 jQuery(document).ready(function() {
556
557 wpcf7cf.$if_values = jQuery('.if-value'); // gets updated now and then
558
559 // init HTML templates (will be updated immediatly by updateAvailableGroupsAndFields())
560 wpcf7cf.template_for_condition_fields_with_one_and_rule = wpcf7cf.$newEntry[0].outerHTML;
561 wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
562
563 updateAvailableGroupsAndFields();
564 wpcf7cf.copyTextToFields();
565
566 wpcf7cf.maybeDisableAddButton();
567
568 jQuery('#wpcf7cf-entries').sortable();
569
570 wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
571
572 })
573
574 }