Custom Contact Forms - Version 6.7.1

Version Description

  • Fix MCE Previews that were broken in WP 4.2
Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Custom Contact Forms
Version 6.7.1
Comparing to
See all releases

Code changes from version 6.7.0 to 6.7.1

build/js/form-mce.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){wp.mce.ccfForm={shortcode_data:{},forms:{},View:{template:wp.ccf.utils.template("ccf-form-mce-preview"),type:"video",postID:document.getElementById("post_ID").value,initialize:function(e){this.shortcode=e.shortcode,wp.ccf.dispatcher.on("saveFormComplete",this.triggerRefresh,this),this.fetch()},triggerRefresh:function(e){e===wp.ccf.forms.findWhere({ID:parseInt(this.shortcode.attrs.named.id)})&&(this.renderPreviews(),this.render(!0))},fetch:function(){var e=this,t=parseInt(e.shortcode.attrs.named.id),i=wp.ccf.forms.findWhere({ID:t});i?(e.renderPreviews(),e.render(!0)):(wp.ccf.forms.formsFetching[t]!==void 0?e.formFetch=wp.ccf.forms.formsFetching[t]:(i=new wp.ccf.models.Form({ID:t}),e.formFetch=i.fetch(),wp.ccf.forms.formsFetching[t]=e.formFetch),e.formFetch.complete(function(){"resolved"===e.formFetch.state()&&i!==void 0&&(wp.ccf.forms.add(i),delete wp.ccf.forms.formsFetching[t]),e.renderPreviews(),e.render(!0)}))},renderPreviews:function(){var e=parseInt(this.shortcode.attrs.named.id),t=wp.ccf.forms.findWhere({ID:e});if(t){var i=t.get("fields");i.each(function(e){var t=document.getElementById("ccf-"+e.get("type")+"-preview-template");if(t){var i=wp.ccf.utils.template("ccf-"+e.get("type")+"-preview-template")({field:e.toJSON(),mce:!0});e.set("preview",i)}})}},getHtml:function(){var e=parseInt(this.shortcode.attrs.named.id);if(this.formFetch===void 0||"resolved"===this.formFetch.state()||"rejected"===this.formFetch.state()){var t=wp.ccf.forms.findWhere({ID:e});return this.formFetch===void 0?this.template({form:t.toJSON()}):"resolved"===this.formFetch.state()?this.template({form:t.toJSON()}):wp.ccf.utils.template("ccf-form-mce-error-preview")()}return!1}},edit:function(t){var i=window.decodeURIComponent(e(t).attr("data-wpview-text")),l=i.replace(/^.*id=('|")([0-9]+)('|").*$/i,"$2"),s=wp.ccf.forms.findWhere({ID:parseInt(l)});return s?(wp.ccf.show(s),void 0):!1}},wp.mce.views.register("ccf_form",wp.mce.ccfForm)})(jQuery);
1
+ (function(){wp.mce.ccfForm={template:wp.ccf.utils.template("ccf-form-mce-preview"),initialize:function(){wp.ccf.dispatcher.on("saveFormComplete",this.triggerRefresh,this),this.fetch()},triggerRefresh:function(e){e===wp.ccf.forms.findWhere({ID:parseInt(this.shortcode.attrs.named.id)})&&(this.renderPreviews(),this.render(this.getHtml()))},fetch:function(){var e=this,t=parseInt(e.shortcode.attrs.named.id),i=wp.ccf.forms.findWhere({ID:t});i?(e.renderPreviews(),e.render(e.getHtml())):(wp.ccf.forms.formsFetching[t]!==void 0?e.formFetch=wp.ccf.forms.formsFetching[t]:(i=new wp.ccf.models.Form({ID:t}),e.formFetch=i.fetch(),wp.ccf.forms.formsFetching[t]=e.formFetch),e.formFetch.complete(function(){"resolved"===e.formFetch.state()&&i!==void 0&&(wp.ccf.forms.add(i),delete wp.ccf.forms.formsFetching[t]),e.renderPreviews(),e.render(e.getHtml())}))},renderPreviews:function(){var e=parseInt(this.shortcode.attrs.named.id),t=wp.ccf.forms.findWhere({ID:e});if(t){var i=t.get("fields");i.each(function(e){var t=document.getElementById("ccf-"+e.get("type")+"-preview-template");if(t){var i=wp.ccf.utils.template("ccf-"+e.get("type")+"-preview-template")({field:e.toJSON(),mce:!0});e.set("preview",i)}})}},getHtml:function(){var e=parseInt(this.shortcode.attrs.named.id);if(this.formFetch===void 0||"resolved"===this.formFetch.state()||"rejected"===this.formFetch.state()){var t=wp.ccf.forms.findWhere({ID:e});return this.formFetch===void 0?this.template({form:t.toJSON()}):"resolved"===this.formFetch.state()?this.template({form:t.toJSON()}):wp.ccf.utils.template("ccf-form-mce-error-preview")()}return!1},edit:function(){var e=this.shortcode.attrs.named.id,t=wp.ccf.forms.findWhere({ID:parseInt(e)});return t?(wp.ccf.show(t),void 0):!1}},wp.mce.views.register("ccf_form",wp.mce.ccfForm)})(jQuery);
custom-contact-forms.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
- * Version: 6.7.0
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
+ * Version: 6.7.1
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
js/form-mce.js CHANGED
@@ -1,109 +1,97 @@
1
  ( function( $ ){
2
 
3
  wp.mce.ccfForm = {
4
- shortcode_data: {},
5
 
6
- forms: {},
 
7
 
8
- View: {
9
- template: wp.ccf.utils.template( 'ccf-form-mce-preview' ),
10
 
11
- type: 'video',
 
 
 
 
 
12
 
13
- postID: document.getElementById( 'post_ID' ).value,
 
14
 
15
- initialize: function( options ) {
16
- this.shortcode = options.shortcode;
17
 
18
- wp.ccf.dispatcher.on( 'saveFormComplete', this.triggerRefresh, this );
19
 
20
- this.fetch();
21
- },
22
 
23
- triggerRefresh: function( form ) {
24
- if ( form === wp.ccf.forms.findWhere( { ID: parseInt( this.shortcode.attrs.named.id ) } ) ) {
25
- this.renderPreviews();
26
- this.render( true );
 
 
27
  }
28
- },
29
- fetch: function() {
30
- var SELF = this;
31
-
32
- var id = parseInt( SELF.shortcode.attrs.named.id );
33
-
34
- var form = wp.ccf.forms.findWhere( { ID: id } );
35
 
36
- if ( ! form ) {
37
-
38
- if ( typeof wp.ccf.forms.formsFetching[id] !== 'undefined' ) {
39
- SELF.formFetch = wp.ccf.forms.formsFetching[id];
40
- } else {
41
- form = new wp.ccf.models.Form( { ID: id } );
42
- SELF.formFetch = form.fetch();
43
- wp.ccf.forms.formsFetching[id] = SELF.formFetch;
44
  }
45
 
46
- SELF.formFetch.complete( function() {
47
- if ( 'resolved' === SELF.formFetch.state() && typeof form !== 'undefined' ) {
48
- wp.ccf.forms.add( form );
49
- delete wp.ccf.forms.formsFetching[id];
50
- }
51
-
52
- SELF.renderPreviews();
53
-
54
- SELF.render( true );
55
- });
56
- } else {
57
  SELF.renderPreviews();
58
 
59
- SELF.render( true );
60
- }
61
- },
 
62
 
63
- renderPreviews: function() {
64
- var id = parseInt( this.shortcode.attrs.named.id );
 
65
 
66
- var form = wp.ccf.forms.findWhere( { ID: id } );
 
67
 
68
- if ( form ) {
69
- var fields = form.get( 'fields' );
70
 
71
- fields.each( function( field ) {
72
- var template = document.getElementById( 'ccf-' + field.get( 'type' ) + '-preview-template' );
73
 
74
- if ( template ) {
75
- var preview = wp.ccf.utils.template( 'ccf-' + field.get( 'type' ) + '-preview-template' )( { field: field.toJSON(), mce: true } );
76
- field.set( 'preview', preview );
77
- }
78
- });
79
- }
80
- },
 
 
 
81
 
82
- getHtml: function() {
83
- var id = parseInt( this.shortcode.attrs.named.id );
84
 
85
- if ( typeof this.formFetch === 'undefined' || this.formFetch.state() === 'resolved' || this.formFetch.state() === 'rejected' ) {
86
- var form = wp.ccf.forms.findWhere( { ID: id } );
87
 
88
- if ( typeof this.formFetch === 'undefined' ) {
 
 
 
89
  return this.template( { form: form.toJSON() } );
90
  } else {
91
- if ( this.formFetch.state() === 'resolved' ) {
92
- return this.template( { form: form.toJSON() } );
93
- } else {
94
- return wp.ccf.utils.template( 'ccf-form-mce-error-preview' )();
95
- }
96
  }
97
  }
98
-
99
- return false;
100
  }
 
 
101
  },
102
 
103
- edit: function( node ) {
104
- var data = window.decodeURIComponent( $( node ).attr('data-wpview-text') );
105
 
106
- var id = data.replace( /^.*id=('|")([0-9]+)('|").*$/i, '$2' );
107
  var form = wp.ccf.forms.findWhere( { ID: parseInt( id ) } );
108
 
109
  if ( form ) {
1
  ( function( $ ){
2
 
3
  wp.mce.ccfForm = {
4
+ template: wp.ccf.utils.template( 'ccf-form-mce-preview' ),
5
 
6
+ initialize: function( options ) {
7
+ wp.ccf.dispatcher.on( 'saveFormComplete', this.triggerRefresh, this );
8
 
9
+ this.fetch();
10
+ },
11
 
12
+ triggerRefresh: function( form ) {
13
+ if ( form === wp.ccf.forms.findWhere( { ID: parseInt( this.shortcode.attrs.named.id ) } ) ) {
14
+ this.renderPreviews();
15
+ this.render( this.getHtml() );
16
+ }
17
+ },
18
 
19
+ fetch: function() {
20
+ var SELF = this;
21
 
22
+ var id = parseInt( SELF.shortcode.attrs.named.id );
 
23
 
24
+ var form = wp.ccf.forms.findWhere( { ID: id } );
25
 
26
+ if ( ! form ) {
 
27
 
28
+ if ( typeof wp.ccf.forms.formsFetching[id] !== 'undefined' ) {
29
+ SELF.formFetch = wp.ccf.forms.formsFetching[id];
30
+ } else {
31
+ form = new wp.ccf.models.Form( { ID: id } );
32
+ SELF.formFetch = form.fetch();
33
+ wp.ccf.forms.formsFetching[id] = SELF.formFetch;
34
  }
 
 
 
 
 
 
 
35
 
36
+ SELF.formFetch.complete( function() {
37
+ if ( 'resolved' === SELF.formFetch.state() && typeof form !== 'undefined' ) {
38
+ wp.ccf.forms.add( form );
39
+ delete wp.ccf.forms.formsFetching[id];
 
 
 
 
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  SELF.renderPreviews();
43
 
44
+ SELF.render( SELF.getHtml() );
45
+ });
46
+ } else {
47
+ SELF.renderPreviews();
48
 
49
+ SELF.render( SELF.getHtml() );
50
+ }
51
+ },
52
 
53
+ renderPreviews: function() {
54
+ var id = parseInt( this.shortcode.attrs.named.id );
55
 
56
+ var form = wp.ccf.forms.findWhere( { ID: id } );
 
57
 
58
+ if ( form ) {
59
+ var fields = form.get( 'fields' );
60
 
61
+ fields.each( function( field ) {
62
+ var template = document.getElementById( 'ccf-' + field.get( 'type' ) + '-preview-template' );
63
+
64
+ if ( template ) {
65
+ var preview = wp.ccf.utils.template( 'ccf-' + field.get( 'type' ) + '-preview-template' )( { field: field.toJSON(), mce: true } );
66
+ field.set( 'preview', preview );
67
+ }
68
+ });
69
+ }
70
+ },
71
 
72
+ getHtml: function() {
73
+ var id = parseInt( this.shortcode.attrs.named.id );
74
 
75
+ if ( typeof this.formFetch === 'undefined' || this.formFetch.state() === 'resolved' || this.formFetch.state() === 'rejected' ) {
76
+ var form = wp.ccf.forms.findWhere( { ID: id } );
77
 
78
+ if ( typeof this.formFetch === 'undefined' ) {
79
+ return this.template( { form: form.toJSON() } );
80
+ } else {
81
+ if ( this.formFetch.state() === 'resolved' ) {
82
  return this.template( { form: form.toJSON() } );
83
  } else {
84
+ return wp.ccf.utils.template( 'ccf-form-mce-error-preview' )();
 
 
 
 
85
  }
86
  }
 
 
87
  }
88
+
89
+ return false;
90
  },
91
 
92
+ edit: function() {
93
+ var id = this.shortcode.attrs.named.id;
94
 
 
95
  var form = wp.ccf.forms.findWhere( { ID: parseInt( id ) } );
96
 
97
  if ( form ) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tlovett1
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HR34W94MM53RQ
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
- Tested up to: 4.2
7
- Stable tag: 6.7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -35,6 +35,9 @@ For questions, feature requests, and support concerning the Custom Contact Forms
35
 
36
  == Changelog ==
37
 
 
 
 
38
  = 6.7.0 =
39
  * Ability to pause forms
40
  * Emulate Backbone HTTP via filter instead of API hack
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HR34W94MM53RQ
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
+ Tested up to: 4.3
7
+ Stable tag: 6.7.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
35
 
36
  == Changelog ==
37
 
38
+ = 6.7.1 =
39
+ * Fix MCE Previews that were broken in WP 4.2
40
+
41
  = 6.7.0 =
42
  * Ability to pause forms
43
  * Emulate Backbone HTTP via filter instead of API hack