PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 4.10
Smart Grid-Layout Design for Contact Form 7 v4.10
4.18.0 4.17.0 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10 4.11 4.12 4.13 4.14 All 119 releases
cf7-grid-layout / public / partials / cf7sg-field-load-script.php

cf7sg-field-load-script.php in Smart Grid-Layout Design for Contact Form 7 4.10, at public/partials/cf7sg-field-load-script.php

77 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 This file outputs javascript to enable the form loading of grid fields (tabs and tables)
4 */
5 ?>
6 if(<?= $json_value?> !== undefined && <?= $json_value?> instanceof Object){
7 var $input = $('span.wpcf7-form-control-wrap.<?= $field ?> :input:enabled', <?= $js_form ?>);
8 var $field = $input.parent();
9 <?php
10 $add_string='';
11 switch($grid){
12 case 'table':
13 $add_string = '$container.cf7sgCloneRow(false);';
14 ?>
15 var $container = $field.closest('.container.cf7-sg-table');
16 var count = $container.children( '.row.cf7-sg-table').length - 1;
17 <?php
18 break;
19 case 'tab':
20 $add_string='$container.cf7sgCloneTab(false);';
21 ?>
22 var $container = $field.closest('.columns.cf7-sg-tabs');
23 var count = $container.children('.cf7-sg-tabs-list').children('li').length ;
24 <?php
25 break;
26 }
27 switch($grid){
28 case 'tab':
29 case 'table':
30 ?>
31 var idx=0;
32 var keys = Object.keys(<?= $json_value?>).length;
33 for(var key in <?= $json_value?>){
34 if(idx>0) $field = $('span.wpcf7-form-control-wrap.<?= $field ?>'+key, $container);
35 idx++;
36 if(<?= $json_value?>[key]) {
37 $(':input', $field).val(<?= $json_value?>[key]).trigger('change');
38 }
39 if(count < keys && idx < keys){
40 <?= $add_string?>
41 }
42 }
43 <?php
44 break;
45 case 'both':
46 ?>
47 var $tabContainer = $field.closest('.columns.cf7-sg-tabs');
48 var eRows, eTabs = $tabContainer.children('.cf7-sg-tabs-list').children('li').length ;
49 var $rowContainer;
50 var rIdx, tIdx=0;
51 var rows, tabs = Object.keys(<?= $json_value?>).length;
52 for(var tab in <?= $json_value?>){
53 if(tIdx>0) $field = $('span.wpcf7-form-control-wrap.<?= $field ?>'+tab, $tabContainer);
54 $rowContainer = $field.closest('.container.cf7-sg-table');
55 eRows = $rowContainer.children( '.row.cf7-sg-table').length - 1;
56 rIdx = 0;
57 tIdx++;
58 var table = <?= $json_value?>[tab];
59 rows = Object.keys(table).length;
60 for(var row in table){
61 if(rIdx>0) $field = $('span.wpcf7-form-control-wrap.<?= $field ?>'+tab+row, $rowContainer);
62 rIdx++;
63 if(table[row]) $(':input', $field).val(table[row]).trigger('change');
64 if(eRows < rows && rIdx < rows){
65 $rowContainer.cf7sgCloneRow(false); //add another row
66 }
67 }
68 if(eTabs < tabs && tIdx < tabs){
69 $tabContainer.cf7sgCloneTab(false); //add a new tab
70 }
71 }
72 <?php
73 break;
74 }
75 ?>
76 }
77