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.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
scripts.js 9 years ago scripts_admin.js 9 years ago
scripts_admin.js
139 lines
1 /**
2 * Created by jules on 7/17/2015.
3 */
4
5 var old_compose = _wpcf7.taggen.compose;
6
7 (function($) {
8
9 // ...before overwriting the jQuery extension point
10 _wpcf7.taggen.compose = function(tagType, $form)
11 {
12
13 $('#tag-generator-panel-group-style-hidden').val($('#tag-generator-panel-group-style').val());
14
15 // original behavior - use function.apply to preserve context
16 var ret = old_compose.apply(this, arguments);
17 //tagType = arguments[0];
18 //$form = arguments[1];
19
20 // START: code here will be executed after the _wpcf7.taggen.update function
21 if (tagType== 'group') ret += "[/group]";
22 // END
23
24 return ret;
25 };
26
27 var index = $('#wpcf7cf-entries .entry').length;
28
29 $('.delete-button').click(function(){
30
31 //if (confirm('You sure?')===false) return false;
32 $(this).parent().remove();
33 return false;
34
35 });
36
37 $('#wpcf7cf-add-button').click(function(){
38
39 var id = add_condition_fields();
40
41 return false;
42
43 });
44
45 function clear_all_condition_fields() {
46 $('.entry').remove();
47 }
48
49 function add_condition_fields() {
50 var $delete_button = $('#wpcf7cf-delete-button').clone().removeAttr('id');
51 $('<div class="entry" id="entry-'+index+'">'+($('#wpcf7cf-new-entry').html().replace(/{id}/g, index))+'</div>').prependTo('#wpcf7cf-entries').append($delete_button);
52 $delete_button.click(function(){
53 $(this).parent().remove();
54 return false;
55 });
56 index++;
57
58 return (index-1);
59 }
60
61 function import_condition_fields() {
62 var lines = $('#wpcf7cf-settings-text').val().split(/\r?\n/);
63 for (var i = lines.length+1; i>-1; i--) {
64
65 var str = lines[i];
66
67 var match = regex.exec(str);
68
69 if (match == null) continue;
70
71 var id = add_condition_fields();
72
73 $('#entry-'+id+' .if-field-select').val(match[1]);
74 $('#entry-'+id+' .operator').val(match[2]);
75 $('#entry-'+id+' .if-value').val(match[3]);
76 $('#entry-'+id+' .then-field-select').val(match[4]);
77
78 regex.lastIndex = 0;
79 }
80 }
81
82 // export/import settings
83
84 $('#wpcf7cf-settings-text-wrap').hide();
85
86 $('#wpcf7cf-settings-to-text').click(function() {
87 $('#wpcf7cf-settings-text-wrap').show();
88
89 $('#wpcf7cf-settings-text').val('');
90 $('#wpcf7cf-entries .entry').each(function() {
91 var $entry = $(this);
92 var line = 'if [' + $entry.find('.if-field-select').val() + ']'
93 + ' ' + $entry.find('.operator').val()
94 + ' "' + $entry.find('.if-value').val() + '" then show'
95 + ' [' + $entry.find('.then-field-select').val() + ']';
96 $('#wpcf7cf-settings-text').val($('#wpcf7cf-settings-text').val() + line + "\n" ).select();
97 });
98 return false;
99 });
100
101 var regex = /if \[(.*)] (equals|not equals|equals \(regex\)|not equals \(regex\)|>|>=|<=|<|is empty|not empty) "(.*)" then show \[(.*)]/g;
102
103 $('#add-fields').click(function() {
104 import_condition_fields();
105 update_entries();
106 return false;
107 });
108
109 $('#overwrite-fields').click(function() {
110 clear_all_condition_fields();
111 import_condition_fields();
112 update_entries();
113 return false;
114 });
115
116 $('#wpcf7cf-settings-text-clear').click(function() {
117 $('#wpcf7cf-settings-text-wrap').hide();
118 $('#wpcf7cf-settings-text').val('');
119 return false;
120 });
121
122 function update_entries() {
123 $('.if-value').css({'visibility':'visible'});
124 $('.entry').each(function() {
125 var $entry = $(this);
126 if ($entry.find('.operator').eq(0).val() == 'is empty' || $entry.find('.operator').eq(0).val() == 'not empty') {
127 $entry.find('.if-value').eq(0).css({'visibility':'hidden'});
128 }
129 });
130 }
131
132 update_entries();
133 $('.operator').change(function() {
134 update_entries();
135 });
136
137
138 })( jQuery );
139