Version Description
- Fix form iframe onload bug
Download this release
Release Info
Developer | tlovett1 |
Plugin | Custom Contact Forms |
Version | 7.4.1 |
Comparing to | |
See all releases |
Code changes from version 7.4 to 7.4.1
- build/js/form.min.js +1 -1
- classes/class-ccf-form-renderer.php +1 -1
- custom-contact-forms.php +2 -2
- js/form.js +2 -10
- readme.txt +3 -0
build/js/form.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(e,t){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.validators=wp.ccf.validators||{};var i={}
|
1 |
+
(function(e,t){"use strict";window.wp=window.wp||{},wp.ccf=wp.ccf||{},wp.ccf.validators=wp.ccf.validators||{};var i={};window.ccfRecaptchaOnload=function(){for(var e=document.querySelectorAll(".ccf-recaptcha-wrapper"),l=function(l){grecaptcha.render(e[s],{sitekey:e[s].getAttribute("data-sitekey"),theme:t.recaptcha_theme,callback:function(){i[l]=!0}})},s=0;e.length>s;s++){var r=e[s].getAttribute("data-form-id");l(r)}};var l=function(e){if(this.wrapper=e,this.errors={},e.className.match(" field-required")){this.inputs=this.wrapper.querySelectorAll(".field-input");var i=this.wrapper.querySelectorAll(".error");i.length&&i[0].parentNode.removeChild(i[0]);var l=!1;if(_.each(this.inputs,function(e){(e.checked&&e.value||e.selected)&&(l=!0)}),!l){this.errors[this.inputs[this.inputs.length-1].getAttribute("name")]={required:!0};var s=document.createElement("div");s.className="error required-error",s.innerHTML=t.required,e.appendChild(s)}}},s=function(e,i){return function(l){this.wrapper=l,this.inputs=this.wrapper.querySelectorAll(".field-input"),this.errors={};for(var s=this.wrapper.querySelectorAll(".error"),r=s.length-1;r>=0;r--)s[r].parentNode.removeChild(s[r]);_.each(this.inputs,function(t){var i=t.getAttribute("name");this.errors[i]={},t.getAttribute("aria-required")&&""===t.value&&(this.errors[i].required=t),e&&e.call(this,t)},this),i&&i.call(this);var o;for(var c in this.errors)if(this.errors.hasOwnProperty(c))for(var n in this.errors[c])o=document.createElement("div"),o.className="error "+n+"-error",o.setAttribute("data-field-name",c),o.innerHTML=t[n],this.errors[c][n].parentNode.insertBefore(o,this.errors[c][n].nextSibling)}};wp.ccf.validators["single-line-text"]=wp.ccf.validators["single-line-text"]||s(),wp.ccf.validators["paragraph-text"]=wp.ccf.validators["paragraph-text"]||s(),wp.ccf.validators.name=wp.ccf.validators.name||s(),wp.ccf.validators.email=wp.ccf.validators.email||s(!1,function(){var e=this.inputs[0].value;if(e){2===this.inputs.length&&e!==this.inputs[1].value&&(this.errors[this.inputs[0].getAttribute("name")].match=this.wrapper.lastChild);var t=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;t.test(e)||(this.errors[this.inputs[0].getAttribute("name")].email=this.wrapper.lastChild)}}),wp.ccf.validators.recaptcha=wp.ccf.validators.recaptcha||function(e,l){this.wrapper=e,this.inputs=this.wrapper.querySelectorAll(".g-recaptcha-response"),this.errors={};for(var s=this.wrapper.querySelectorAll(".error"),r=s.length-1;r>=0;r--)s[r].parentNode.removeChild(s[r]);i[l]||(this.errors["g-recaptcha-response"]={},this.errors["g-recaptcha-response"].recaptcha=this.wrapper.lastChild);var o;for(var c in this.errors)if(this.errors.hasOwnProperty(c))for(var n in this.errors[c])o=document.createElement("div"),o.className="error "+n+"-error",o.setAttribute("data-field-name",c),o.innerHTML=t[n],this.errors[c][n].parentNode.insertBefore(o,this.errors[c][n].nextSibling)},wp.ccf.validators.phone=wp.ccf.validators.phone||s(!1,function(){var e=this.inputs[0].value;if(e){var t=/^[0-9+.)(\- ]+$/;if(t.test(e)){if("us"===this.wrapper.getAttribute("data-phone-format")){var i=e.replace(/[^0-9]/gi,"");10!==i.length&&(this.errors[this.inputs[0].getAttribute("name")].digits=this.wrapper.lastChild)}}else this.errors[this.inputs[0].getAttribute("name")].phone=this.wrapper.lastChild}}),wp.ccf.validators.date=wp.ccf.validators.date||function(e){this.wrapper=e,this.errors={},this.inputs=this.wrapper.querySelectorAll(".field-input");for(var i=this.wrapper.querySelectorAll(".error"),l=i.length-1;l>=0;l--)i[l].parentNode.removeChild(i[l]);var s;_.each(this.inputs,function(i){var l=i.getAttribute("name");if(this.errors[l]={},i.getAttribute("aria-required")&&""===i.value&&(this.errors[l].required=!0,s=document.createElement("div"),s.className="error required-error",1===this.inputs.length?(s.innerHTML=t.required,s.className+=" right-error",i.parentNode.insertBefore(s,i.nextSibling)):(s.innerHTML=t[l.replace(/.*\[(.*?)\]/i,"$1")+"_required"],e.appendChild(s))),""!==i.value){var r=l.replace(/^.*\[(.*?)\]$/,"$1");"date"===r?i.value.match(/^([0-9]|\/)+$/)||(s=document.createElement("div"),s.className="error date-error",s.innerHTML=t.date,e.appendChild(s)):"hour"===r?i.value.match(/^[0-9]+$/)||(s=document.createElement("div"),s.className="error hour-error",s.innerHTML=t.hour,e.appendChild(s)):"minute"===r&&(i.value.match(/^[0-9]+$/)||(s=document.createElement("div"),s.className="error minute-error",s.innerHTML=t.minute,e.appendChild(s)))}},this)},wp.ccf.validators.address=wp.ccf.validators.address||s(),wp.ccf.validators.file=wp.ccf.validators.file||function(e){this.wrapper=e,this.inputs=this.wrapper.querySelectorAll(".field-input"),this.errors={};for(var i=this.wrapper.querySelectorAll(".error"),l=i.length-1;l>=0;l--)i[l].parentNode.removeChild(i[l]);_.each(this.inputs,function(e){var t=e.getAttribute("name");this.errors[t]={},e.getAttribute("aria-required")&&""===e.value&&(this.errors[t].required=e)},this);var s=this.inputs[0],r=this.wrapper.getAttribute("data-max-file-size"),o=this.wrapper.getAttribute("data-file-extensions");if(s.value){if(r){var c=1e3*1e3*parseInt(r);if(s.files)s.files[0].size>c&&(this.errors[this.inputs[0].getAttribute("name")].fileSize=this.wrapper.lastChild);else if("undefined"!=typeof ActiveXObject)try{var n=new ActiveXObject("Scripting.FileSystemObject"),a=n.getFile(s.value);a.size>c&&(this.errors[this.inputs[0].getAttribute("name")].fileSize=this.wrapper.lastChild)}catch(d){}}if(o){var f=o.replace(";",",").toLowerCase();if(f=f.replace(/\s+/g,""),f=f.split(","),f.length){var u=s.value.replace(/^.*\.(.+)$/g,"$1").toLowerCase();-1===_.indexOf(f,u)&&(this.errors[this.inputs[0].getAttribute("name")].fileExtension=this.wrapper.lastChild)}}}var p;for(var h in this.errors)if(this.errors.hasOwnProperty(h))for(var m in this.errors[h])p=document.createElement("div"),p.className="error "+m+"-error",p.setAttribute("data-field-name",h),p.innerHTML=t[m],"fileExtension"===m&&o?p.innerHTML+=" ("+o+")":"fileSize"===m&&r&&(p.innerHTML+=" "+r+" MB"),this.errors[h][m].parentNode.insertBefore(p,this.errors[h][m].nextSibling)},wp.ccf.validators.website=wp.ccf.validators.website||s(function(e){if(e.value){var t=/^http(s?)\:\/\/(([a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+)+)|localhost)(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?([\d\w\.\/\%\+\-\=\&\?\:\\\"\'\,\|\~\;]*)$/;t.test(e.value)||(this.errors[e.getAttribute("name")].website=e)}}),wp.ccf.validators.checkboxes=wp.ccf.validators.checkboxes||l,wp.ccf.validators.dropdown=wp.ccf.validators.dropdown||s(),wp.ccf.validators.radio=wp.ccf.validators.radio||l,wp.ccf.setupDOM=wp.ccf.setupDOM||function(){for(var l,s,r=document.querySelectorAll(".ccf-datepicker"),o=0;r.length>o;o++)l={},s=r[o].getAttribute("data-date-format"),s&&(l.dateFormat=s.replace(/yyyy/i,"yy")),e(r[o]).datepicker(l);var c=document.querySelectorAll(".ccf-form-wrapper");c.length>=1&&_.each(c,function(l){function s(t){var i=l.querySelectorAll(".field"),s=[];if(_.each(i,function(e){if(!e.className.match(/ skip-field/i)){var t=e.getAttribute("data-field-type"),i=e.getAttribute("data-field-slug");p[i]=e;var l=new wp.ccf.validators[t](e,c);if(_.size(l.errors)){var r=0;for(var o in l.errors)l.errors.hasOwnProperty(o)&&_.size(l.errors[o])&&r++;r>0&&s.push(l)}}}),!s.length)return o.trigger("ccfFormSuccess"),l.className=l.className.replace(/ loading/i,"")+" loading",d.animate({opacity:100}),!0;t.returnFalse=!1,t.preventDefault&&t.preventDefault(),o.trigger("ccfFormError",s);var r=e(window).scrollTop(),n=r+e(window).height(),a=e(s[0].wrapper),f=a.offset(),u=f.top,h=u+a.height();return u>=r&&n>=h||e("html, body").animate({scrollTop:a.offset().top},500),!1}var r=l.querySelectorAll(".ccf-form")[0],o=e(r),c=parseInt(l.getAttribute("data-form-id")),n=r.querySelectorAll(".ccf-submit-button")[0],a=document.getElementById("ccf_form_frame_"+c),d=e(r.querySelectorAll(".loading-img")[0]),f=e(a),u=e(n),p={};f.on("load",function(){var l,s=f.contents().find("body").text();if(!s)return!1;r.className=r.className.replace(/ loading/i,""),d.animate({opacity:0}),i[c]=!1;try{l=e.parseJSON(s)}catch(o){var a=document.createElement("div");return a.className="error unknown-error",a.innerText=t.unknown,n.parentNode.appendChild(a),!1}var u=n.parentNode.querySelectorAll(".error");if(u.length&&u[0].parentNode.removeChild(u[0]),l.success)if("text"===l.action_type&&l.completion_message){r.innerHTML="";var h=document.createElement("div");h.innerHTML=l.completion_message,h.className="ccf-form-complete",r.appendChild(h),e("html, body").animate({scrollTop:e(r).offset().top},500)}else"redirect"===l.action_type&&l.completion_redirect_url&&(document.location=l.completion_redirect_url);else l.field_errors&&_.each(l.field_errors,function(e,t){var i=p[t].querySelectorAll(".field-input");for(var l in e)if(e.hasOwnProperty(l)){var s=document.createElement("div");s.className="error "+l+"-error",s.innerHTML=e[l],1===i.length?i[i.length-1].parentNode.insertBefore(s,i[i.length-1].nextSibling):p[t].appendChild(s)}})}),u.on("click",function(e){return e.preventDefault(),r.target="ccf_form_frame_"+c,r.action=t.ajaxurl,o.submit(),!1}),o.on("submit",s)})},e(document).ready(wp.ccf.setupDOM)})(jQuery,ccfSettings);
|
classes/class-ccf-form-renderer.php
CHANGED
@@ -244,7 +244,7 @@ class CCF_Form_Renderer {
|
|
244 |
<input type="hidden" name="form_nonce" value="<?php echo wp_create_nonce( 'ccf_form' ); ?>">
|
245 |
</form>
|
246 |
|
247 |
-
<iframe
|
248 |
</div>
|
249 |
|
250 |
<?php
|
244 |
<input type="hidden" name="form_nonce" value="<?php echo wp_create_nonce( 'ccf_form' ); ?>">
|
245 |
</form>
|
246 |
|
247 |
+
<iframe class="ccf-form-frame" id="ccf_form_frame_<?php echo (int) $form_id; ?>" name="ccf_form_frame_<?php echo (int) $form_id; ?>"></iframe>
|
248 |
</div>
|
249 |
|
250 |
<?php
|
custom-contact-forms.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: http://www.taylorlovett.com
|
5 |
* Description: Build beautiful custom forms and manage submissions the WordPress way. View live previews of your forms while you build them. Contact forms, subscription forms, payment forms, etc.
|
6 |
* Author: Taylor Lovett
|
7 |
-
* Version: 7.4
|
8 |
* Text Domain: custom-contact-forms
|
9 |
* Domain Path: /languages
|
10 |
* Author URI: http://www.taylorlovett.com
|
@@ -14,7 +14,7 @@
|
|
14 |
* Include plugin reqs
|
15 |
*/
|
16 |
|
17 |
-
define( 'CCF_VERSION', '7.4' );
|
18 |
|
19 |
require_once( dirname( __FILE__ ) . '/classes/class-ccf-constants.php' );
|
20 |
require_once( dirname( __FILE__ ) . '/classes/class-ccf-custom-contact-forms.php' );
|
4 |
* Plugin URI: http://www.taylorlovett.com
|
5 |
* Description: Build beautiful custom forms and manage submissions the WordPress way. View live previews of your forms while you build them. Contact forms, subscription forms, payment forms, etc.
|
6 |
* Author: Taylor Lovett
|
7 |
+
* Version: 7.4.1
|
8 |
* Text Domain: custom-contact-forms
|
9 |
* Domain Path: /languages
|
10 |
* Author URI: http://www.taylorlovett.com
|
14 |
* Include plugin reqs
|
15 |
*/
|
16 |
|
17 |
+
define( 'CCF_VERSION', '7.4.1' );
|
18 |
|
19 |
require_once( dirname( __FILE__ ) . '/classes/class-ccf-constants.php' );
|
20 |
require_once( dirname( __FILE__ ) . '/classes/class-ccf-custom-contact-forms.php' );
|
js/form.js
CHANGED
@@ -8,8 +8,6 @@
|
|
8 |
|
9 |
var _verifiedRecaptcha = {};
|
10 |
|
11 |
-
var _formFrameOnload = {};
|
12 |
-
|
13 |
window.ccfRecaptchaOnload = function() {
|
14 |
var recaptchas = document.querySelectorAll( '.ccf-recaptcha-wrapper' );
|
15 |
|
@@ -353,12 +351,6 @@
|
|
353 |
|
354 |
wp.ccf.validators.radio = wp.ccf.validators.radio || choiceValidator;
|
355 |
|
356 |
-
wp.ccf.iframeOnload = function( formId ) {
|
357 |
-
if ( _formFrameOnload[formId] ) {
|
358 |
-
_formFrameOnload[formId]();
|
359 |
-
}
|
360 |
-
};
|
361 |
-
|
362 |
wp.ccf.setupDOM = wp.ccf.setupDOM || function() {
|
363 |
var datepickers = document.querySelectorAll( '.ccf-datepicker' ),
|
364 |
options,
|
@@ -390,7 +382,7 @@
|
|
390 |
|
391 |
var fieldsBySlug = {};
|
392 |
|
393 |
-
|
394 |
var data,
|
395 |
content = $frame.contents().find( 'body' ).text();
|
396 |
|
@@ -453,7 +445,7 @@
|
|
453 |
});
|
454 |
}
|
455 |
|
456 |
-
};
|
457 |
|
458 |
$button.on( 'click', function( event ) {
|
459 |
event.preventDefault();
|
8 |
|
9 |
var _verifiedRecaptcha = {};
|
10 |
|
|
|
|
|
11 |
window.ccfRecaptchaOnload = function() {
|
12 |
var recaptchas = document.querySelectorAll( '.ccf-recaptcha-wrapper' );
|
13 |
|
351 |
|
352 |
wp.ccf.validators.radio = wp.ccf.validators.radio || choiceValidator;
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
wp.ccf.setupDOM = wp.ccf.setupDOM || function() {
|
355 |
var datepickers = document.querySelectorAll( '.ccf-datepicker' ),
|
356 |
options,
|
382 |
|
383 |
var fieldsBySlug = {};
|
384 |
|
385 |
+
$frame.on( 'load', function() {
|
386 |
var data,
|
387 |
content = $frame.contents().find( 'body' ).text();
|
388 |
|
445 |
});
|
446 |
}
|
447 |
|
448 |
+
} );
|
449 |
|
450 |
$button.on( 'click', function( event ) {
|
451 |
event.preventDefault();
|
readme.txt
CHANGED
@@ -55,6 +55,9 @@ For full documentation, questions, feature requests, and support concerning the
|
|
55 |
|
56 |
== Changelog ==
|
57 |
|
|
|
|
|
|
|
58 |
= 7.4 =
|
59 |
* Themes and Bootstrap support
|
60 |
|
55 |
|
56 |
== Changelog ==
|
57 |
|
58 |
+
= 7.4.1 =
|
59 |
+
* Fix form iframe onload bug
|
60 |
+
|
61 |
= 7.4 =
|
62 |
* Themes and Bootstrap support
|
63 |
|