PluginProbe
Smart Grid-Layout Design for Contact Form 7 / 3.3.8
Smart Grid-Layout Design for Contact Form 7 v3.3.8
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 / assets / cf7-admin-table / admin / js / cf7-post-table.js

cf7-post-table.js in Smart Grid-Layout Design for Contact Form 7 3.3.8, at assets/cf7-admin-table/admin/js/cf7-post-table.js

66 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 //obtained from wordpress codex: https://codex.wordpress.org/Plugin_API/Action_Reference/quick_edit_custom_box
3 // we create a copy of the WP inline edit post function
4 var $wp_inline_edit = inlineEditPost.edit;
5 // and then we overwrite the function with our own code
6 inlineEditPost.edit = function( id ) {
7
8 // "call" the original WP edit function
9 // we don't want to leave WordPress hanging
10 $wp_inline_edit.apply( this, arguments );
11
12 // now we take care of our business
13
14 // get the post ID
15 var $post_id = 0;
16 if ( typeof( id ) == 'object' ) {
17 $post_id = parseInt( this.getId( id ) );
18 }
19
20 if ( $post_id > 0 ) {
21 // define the edit row
22 var $edit_row = $( '#edit-' + $post_id );
23 var $post_row = $( '#post-' + $post_id );
24
25 // get the data
26 var $name = $( ':input[name="post_name"]', $edit_row );
27 var $error = $('<span class="cf7-2-post-key-error">Key is not unique or contains spaces</span>').hide()
28 $name.after($error);
29
30 var form_key = $name.val();
31
32 // populate the data
33 var slugLabel = $( ':input[name="post_name"]', $edit_row ).closest( 'label' ).find('span.title');
34 slugLabel.text("Form key");
35 $name.on('change', function(){
36 //hide error msg
37 $error.hide();
38 //validate it is unique
39 if(cf7_2_post_admin.keys.includes( $(this).val() ) || $(this).val().stringOf(' ') > -1 ){
40 var bg = $(this).css('background-color');
41 var color = $(this).css('color');
42 $error.show();
43 $(this).animate({ //fadeout the value
44 color: bg },
45 1000, //time
46 'linear', //easing
47 function(){ //on completion
48 $(this).val(form_key).css('color',color); //reset value
49 });
50 }else{ //update the shortcode
51 form_key = $(this).val();
52 $( ':input.cf7-2-post-shortcode', $edit_row ).val( '[cf7-form cf7key="' + form_key + '"]');
53 }
54 })
55 }
56 //remove other fields
57 $(':input[name="_status"]').closest('.inline-edit-group').hide();
58 $(':input[name="post_password"]').closest('.inline-edit-group').hide();
59 $('fieldset.inline-edit-date').hide();
60
61 //$('.inline-edit-row .inline-edit-col-left').not('.inline-edit-cf7').addClass('hide-element');
62 //$('.inline-edit-row .inline-edit-col-right').addClass('hide-element');
63 };
64
65 })(jQuery);
66