PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 4.12
Smart Grid-Layout Design for Contact Form 7 v4.12
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 / admin / js / mail-tag-helper.js

mail-tag-helper.js in Smart Grid-Layout Design for Contact Form 7 4.12, at admin/js/mail-tag-helper.js

62 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 (function( $ ) {
3 'use strict';
4 var $mailtags
5 $(document).ready(function(){
6
7 $('span.mailtag.code', '#wpcf7-mail').each(function(){
8 var $this = $(this);
9 var tag = $this.text().replace(/\[(.+)\]/g,'$1');
10 var $help = $('<a class="helper" data-tag="'+tag+'" href="javascript:void(0);"><span class="dashicons dashicons-info"></span></a>');
11 $(this).after($help);
12 new Clipboard($help[0], {
13 text: function(trigger) {
14 var form = $('#post_name').val();
15 if(!form) form = 'my-form';
16 var tag = $(trigger).data('tag'), ftag = tag.replace(/\-/g,'_');
17 var addTable = false;
18 if(0==tag.indexOf('cf7sg-form-')){
19 //check if table or tab exists.
20 let $form = $('<div>').html($('#grid-form').CF7FormHTML());
21 if( $('div.container.cf7-sg-table', $form).length > 0) addTable=true;
22 if( $('div.container.cf7-sg-tabs-panel', $form).length > 0) addTable=true;
23 }
24 var text = "add_filter( 'cf7sg_mailtag_"+tag+"', 'filter_cf7_mailtag_"+ftag+"', 10, 3);\n";
25 text += "function filter_cf7_mailtag_"+ftag+"($tag_replace, $submitted, $cf7_key){\n";
26 text += " /*the $tag_replace string to change*/\n";
27 text += " /*the $submitted an array containing all submitted fields*/\n";
28 text += " /*the $cf7_key is a unique string key to identify your form, which you can find in your form table in the dashboard.*/\n"
29 text += " if('"+form+"'==$cf7_key ){\n";
30 if(addTable){
31 text += " $style = 'style=[qtm]padding:0 3px;border-collapse:collapse;border-bottom:1px solid black[qtm]';\n";
32 text += " $tag_replace ='\n";
33 text += " <table>\n";
34 text += " <thead><tr><th '.$style.'>Guest Name</th><th '.$style.'>Senior</th></tr></thead>\n";
35 text += " <tbody>';\n";
36 text += " if(!empty($submitted['guest-name'])){\n";
37 text += " $style = 'style=[qtm]background-color:#e3e3e3[qtm]';\n";
38 text += " $row=1;\n";
39 text += " foreach($submitted['guest-name'] as $idx=>$guest){\n";
40 text += " $tag_replace .=' <tr><td '.($row%2==0?$style:'').'>'.$guest.'</td><td '.($row%2==0?$style:'').'>'. (empty($submitted['senior-guest'][$idx]) ? '' : 'yes') . '</td></tr>'.PHP_EOL;\n";
41 text += " $row++;\n";
42 text += " }\n";
43 text += " }\n";
44 text += " $tag_replace .='\n";
45 text += " </tbody>\n";
46 text += " </table>\n";
47 text += " ';\n";
48 }else{
49 text += " $tag_replace = ... //change the "+tag+".\n";
50 }
51 text += " }\n";
52 text += " return $tag_replace;\n";
53 text += "}\n";
54 return text.replace(/\[qtm\]/,'"');
55 }
56 });
57 var helper = mailTagHelper.filter.replace('%s', '<span class="tag-colour">'+tag+'</span>');
58 $help.after('<span class="helper">'+helper+', '+mailTagHelper.msg+'</span>');
59 })
60 })
61 })( jQuery );
62