Changeset 3387924
- Timestamp:
- 11/01/2025 05:57:40 AM (8 weeks ago)
- Location:
- contact-form-7-multi-step-module/trunk
- Files:
-
- 4 edited
-
assets-src/js/cf7msm.js (modified) (9 diffs)
-
contact-form-7-multi-step-module.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
resources/cf7msm.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
contact-form-7-multi-step-module/trunk/assets-src/js/cf7msm.js
r3369480 r3387924 4 4 var cf7msm_ss; 5 5 var cf7msm_did_load = false; 6 /** 7 * Given 2 arrays, return a unique array 8 * https://codegolf.stackexchange.com/questions/17127/array-merge-without-duplicates 9 */ 10 function cf7msm_uniqueArray(i,x) { 11 var h = {}; 12 var n = []; 13 for (var a = 2; a--; i=x) 14 i.map(function(b){ 15 h[b] = h[b] || n.push(b); 16 }); 17 return n 18 } 19 20 /** 21 * check if local storage is usable. 22 */ 23 function cf7msm_hasSS() { 24 var test = 'test'; 25 try { 26 sessionStorage.setItem(test, test); 27 sessionStorage.removeItem(test); 28 return true; 29 } catch(e) { 30 return false; 31 } 32 } 33 function cf7msm_setStorageObject(storage, key, value) { 34 storage.setItem(key, JSON.stringify(value)); 35 } 36 37 function cf7msm_getStorageObject(storage, key) { 38 var value = storage.getItem(key); 39 return value && JSON.parse(value); 40 } 41 42 /** 43 * Escape values when inserting into HTML attributes 44 * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values 45 */ 46 function quoteattr(s, preserveCR) { 47 preserveCR = preserveCR ? ' ' : '\n'; 48 return ('' + s) /* Forces the conversion to string. */ 49 .replace(/&/g, '&') /* This MUST be the 1st replacement. */ 50 .replace(/'/g, ''') /* The 4 other predefined entities, required. */ 51 .replace(/"/g, '"') 52 .replace(/</g, '<') 53 .replace(/>/g, '>') 54 /* 55 You may add other replacements here for HTML only 56 (but it's not necessary). 57 Or for XML, only if the named entities are defined in its DTD. 58 */ 59 .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */ 60 .replace(/[\r\n]/g, preserveCR); 61 } 62 /** 63 * Escape values when using in javascript first. 64 * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values 65 */ 66 function escapeattr(s) { 67 return ('' + s) /* Forces the conversion to string. */ 68 .replace(/\\/g, '\\\\') /* This MUST be the 1st replacement. */ 69 .replace(/\t/g, '\\t') /* These 2 replacements protect whitespaces. */ 70 .replace(/\n/g, '\\n') 71 .replace(/\u00A0/g, '\\u00A0') /* Useful but not absolutely necessary. */ 72 .replace(/&/g, '\\x26') /* These 5 replacements protect from HTML/XML. */ 73 .replace(/'/g, '\\x27') 74 .replace(/"/g, '\\x22') 75 .replace(/</g, '\\x3C') 76 .replace(/>/g, '\\x3E') 77 ; 78 } 6 79 7 80 // load on DOMContentLoaded bc wpc7 loads here. … … 36 109 37 110 if ( cf7msm_hasSS() ) { 38 cf7msm_ss = sessionStorage.getObject('cf7msm' );111 cf7msm_ss = cf7msm_getStorageObject( sessionStorage, 'cf7msm' ); 39 112 /* 40 113 //multi step forms … … 288 361 var names = []; 289 362 var currentInputs = {}; 290 cf7msm_ss = sessionStorage.getObject('cf7msm');363 cf7msm_ss = cf7msm_getStorageObject(sessionStorage, 'cf7msm'); 291 364 if ( !cf7msm_ss ) { 292 365 cf7msm_ss = {}; … … 300 373 301 374 var free_text_els = $('.has-free-text', form); 375 var checkbox_free_text_map = {}; // Track which checkbox fields have free text 376 302 377 $.each(e.detail.inputs, function(i){ 303 378 var name = e.detail.inputs[i].name; … … 315 390 } 316 391 var ref_len = value.length; 317 // append free text value 318 value += ' ' + $('input[name="_wpcf7_free_text_' + base_name + '"]', free_text_els).val(); 392 var free_text_value = $('input[name="_wpcf7_free_text_' + base_name + '"]', free_text_els).val(); 319 393 var ref_name = '_cf7msm_free_text_reflen_' + base_name; 320 currentInputs[ref_name] = ref_len; 394 395 // Store free text info for checkboxes to append later 396 if ( name.indexOf('[]') === name.length - 2 ) { 397 checkbox_free_text_map[name] = { 398 value: value, 399 free_text: free_text_value, 400 ref_len: ref_len, 401 ref_name: ref_name 402 }; 403 } 404 else { 405 // For radio buttons, append immediately 406 value += ' ' + free_text_value; 407 currentInputs[ref_name] = ref_len; 408 } 321 409 } 322 410 } … … 373 461 } 374 462 }); 463 464 // Now append free text to the last checkbox value only 465 $.each(checkbox_free_text_map, function(name, info) { 466 if (currentInputs.hasOwnProperty(name) && currentInputs[name].length > 0) { 467 var last_index = currentInputs[name].length - 1; 468 // Only append if the last value matches the one with free text 469 if (currentInputs[name][last_index] === info.value) { 470 currentInputs[name][last_index] += ' ' + info.free_text; 471 currentInputs[info.ref_name] = info.ref_len; 472 } 473 } 474 }); 475 375 476 if (!isCF7MSM) { 376 477 return; … … 428 529 } 429 530 430 sessionStorage.setObject('cf7msm', cf7msm_ss);531 cf7msm_setStorageObject(sessionStorage, 'cf7msm', cf7msm_ss); 431 532 432 533 if (nextUrl && nextUrl != '') { … … 439 540 cf7msm_ss = {}; 440 541 } 441 sessionStorage.setObject('cf7msm', cf7msm_ss);542 cf7msm_setStorageObject(sessionStorage, 'cf7msm', cf7msm_ss); 442 543 */ 443 544 } … … 445 546 }; 446 547 })(jQuery); 447 448 449 /**450 * Given 2 arrays, return a unique array451 * https://codegolf.stackexchange.com/questions/17127/array-merge-without-duplicates452 */453 function cf7msm_uniqueArray(i,x) {454 var h = {};455 var n = [];456 for (var a = 2; a--; i=x)457 i.map(function(b){458 h[b] = h[b] || n.push(b);459 });460 return n461 }462 463 /**464 * check if local storage is usable.465 */466 function cf7msm_hasSS() {467 var test = 'test';468 try {469 sessionStorage.setItem(test, test);470 sessionStorage.removeItem(test);471 return true;472 } catch(e) {473 return false;474 }475 }476 Storage.prototype.setObject = function(key, value) {477 this.setItem(key, JSON.stringify(value));478 }479 480 Storage.prototype.getObject = function(key) {481 var value = this.getItem(key);482 return value && JSON.parse(value);483 }484 485 /**486 * Escape values when inserting into HTML attributes487 * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values488 */489 function quoteattr(s, preserveCR) {490 preserveCR = preserveCR ? ' ' : '\n';491 return ('' + s) /* Forces the conversion to string. */492 .replace(/&/g, '&') /* This MUST be the 1st replacement. */493 .replace(/'/g, ''') /* The 4 other predefined entities, required. */494 .replace(/"/g, '"')495 .replace(/</g, '<')496 .replace(/>/g, '>')497 /*498 You may add other replacements here for HTML only499 (but it's not necessary).500 Or for XML, only if the named entities are defined in its DTD.501 */502 .replace(/\r\n/g, preserveCR) /* Must be before the next replacement. */503 .replace(/[\r\n]/g, preserveCR);504 }505 /**506 * Escape values when using in javascript first.507 * From SO: https://stackoverflow.com/questions/7753448/how-do-i-escape-quotes-in-html-attribute-values508 */509 function escapeattr(s) {510 return ('' + s) /* Forces the conversion to string. */511 .replace(/\\/g, '\\\\') /* This MUST be the 1st replacement. */512 .replace(/\t/g, '\\t') /* These 2 replacements protect whitespaces. */513 .replace(/\n/g, '\\n')514 .replace(/\u00A0/g, '\\u00A0') /* Useful but not absolutely necessary. */515 .replace(/&/g, '\\x26') /* These 5 replacements protect from HTML/XML. */516 .replace(/'/g, '\\x27')517 .replace(/"/g, '\\x22')518 .replace(/</g, '\\x3C')519 .replace(/>/g, '\\x3E')520 ;521 } -
contact-form-7-multi-step-module/trunk/contact-form-7-multi-step-module.php
r3369480 r3387924 5 5 Plugin URI: http://www.mymonkeydo.com/contact-form-7-multi-step-module/ 6 6 Description: Enables the Contact Form 7 plugin to create multi-page, multi-step forms. 7 Requires Plugins: contact-form-7 7 8 Author: Webhead LLC. 8 9 Author URI: http://webheadcoder.com 9 Version: 4. 4.410 Version: 4.5 10 11 Text Domain: contact-form-7-multi-step-module 11 12 */ … … 64 65 // Signal that SDK was initiated. 65 66 do_action( 'cf7msm_fs_loaded' ); 66 define( 'CF7MSM_VERSION', '4. 4.4' );67 define( 'CF7MSM_VERSION', '4.5' ); 67 68 define( 'CF7MSM_PLUGIN', __FILE__ ); 68 69 define( 'CF7MSM_FREE_TEXT_PREFIX_RADIO', '_wpcf7_free_text_' ); -
contact-form-7-multi-step-module/trunk/readme.txt
r3369480 r3387924 4 4 Requires at least: 4.7 5 5 Tested up to: 6.8 6 Stable tag: 4. 4.46 Stable tag: 4.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 136 136 137 137 == Changelog == 138 139 = 4.5 = 140 * updated scopes to resolve conflicts with other themes and plugins. 141 * removed getObject and setObject override in SessionStorage to avoid conflicts. 142 * fixed free_text in checkbox and radios showing on every value. 138 143 139 144 = 4.4.4 = -
contact-form-7-multi-step-module/trunk/resources/cf7msm.min.js
r3369480 r3387924 1 function e(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(t){return!1}}!function(t){var n,i=!1;function r(r){if(!i){i=!0;var a=cf7msm_posted_data,s=t("input[name='_cf7msm_multistep_tag']"),o=s.length>0;if(o||(o=(s=t("input[name='cf7msm-step']")).length>0),o){var f=s.closest("form"),c=f.find('input[name="_wpcf7"]').val();e()?null!=(n=sessionStorage.getObject("cf7msm"))&&t.each(n,function(e,t){if("cf7msm_prev_urls"==e){var n=f.find(".wpcf7-back, .wpcf7-previous"),i=window.location.href,r=i.replace(/\/$/,""),a=!t.hasOwnProperty(i)||""==t[i];a&&(a=!t.hasOwnProperty(r)||""==t[r]),a&&(i=i.split("?")[0],r=i.replace(/\/$/,""),(a=!t.hasOwnProperty(i)||""==t[i])&&(a=!t.hasOwnProperty(r)||""==t[r])),a?n.hide():n.click(function(e){t.hasOwnProperty(i)&&""!=t[i]?window.location.href=t[i]:t.hasOwnProperty(r)&&""!=t[r]?window.location.href=t[r]:window.history.go(-1),e.preventDefault()})}}):(t("input[name='cf7msm-no-ss']").val(1),t(".wpcf7-previous").hide());var l=wpcf7.submit;wpcf7.submit=function(e,n){!function(e){(function(e){var n=e;n instanceof jQuery||(n=t(e));var i=n.find("input[name='_cf7msm_multistep_tag']");if(0==i.length)return;i.length>1&&(i=i.last());t("<input />",{type:"hidden",name:"cf7msm_options",value:i.val()}).appendTo(n)})(e),function(e){var n=e;n instanceof jQuery||(n=t(e));var i=t(".has-free-text",n);i.each(function(){var e=t(this),n=t("input:checkbox",e);if(0==n.length&&(n=t("input:radio",e)),0==n.length)return!1;var i=n.attr("name");i.indexOf("[]")===i.length-2&&(i=i.substring(0,i.length-2));var r="_cf7msm_free_text_reflen_"+i,a=t('input[name="'+r+'"]',e);n.is(":checked")?(0==a.length&&(a=t('<input type="hidden" name="'+r+'">'),e.append(a)),a.val(n.val().length)):a.length>0&&a.remove()})}(e)}(e),l(e,n)},r&&p(),window.addEventListener("load",function(){p()}),document.addEventListener("wpcf7mailsent",function(i){var r=t("#"+i.detail.unitTag+" form");if(e()){var a=0,s=0,o=[],f={};(n=sessionStorage.getObject("cf7msm"))||(n={});var l=!1,p=!1,u=!0,m=!1,d=null,h=!1,v=t(".has-free-text",r);if(t.each(i.detail.inputs,function(e){var n=i.detail.inputs[e].name,r=i.detail.inputs[e].value,_=t('input[name="'+n+'"]',v);if(_.length>0&&_.is(":checked")){var g=n;n.indexOf("[]")===n.length-2&&(g=n.substring(0,n.length-2));var w=r.length;r+=" "+t('input[name="_wpcf7_free_text_'+g+'"]',v).val(),f["_cf7msm_free_text_reflen_"+g]=w}if(n.indexOf("[]")===n.length-2?(-1===t.inArray(n,o)&&(f[n]=[]),f[n].push(r)):f[n]=r,"cf7msm-step"===n){if(-1!==r.indexOf("-")){l=!0,p=!1;var O=r.split("-");a=parseInt(O[0]),s=parseInt(O[1]),void 0!==cf7msm_redirect_urls[c]&&(d=cf7msm_redirect_urls[c]),a<s?u=!1:a===s&&(m=!0)}}else if("cf7msm_options"===n){l=!0,p=!0,u=!1;var y=JSON.parse(r);y.hasOwnProperty("next_url")&&(d=y.next_url),y.hasOwnProperty("last_step")&&(h=!0,d&&""!==d||(m=!0,u=!0))}else o.push(n)}),!l)return;if(!u){var _=t("#"+i.detail.unitTag).find("div.wpcf7-mail-sent-ok");0==_.length&&(_=t("#"+i.detail.unitTag).find(".wpcf7-response-output")),_.remove()}if(m&&(r.find("*").not("div.wpcf7-response-output").hide(),r.find("div.wpcf7-response-output").parentsUntil("form").show()),p?h&&(n={}):0!=a&&a===s&&(n={}),d&&""!=d){var g=document.createElement("a");g.href=d;var w=g.hostname+(g.port?":"+g.port:""),O={};n&&n.cf7msm_prev_urls&&(O=n.cf7msm_prev_urls);var y=window.location.protocol+"//"+window.location.host;0===d.indexOf(y)||""!=w&&w!=window.location.host||(0!==d.indexOf("/")&&(y+="/"),d=y+d),O[d]=window.location.href;var x=d.split("?")[0];d!=x&&(O[x]=window.location.href),n.cf7msm_prev_urls=O}sessionStorage.setObject("cf7msm",n),d&&""!=d&&(window.location.href=d)}},!1)}}function p(){a&&(t.each(a,function(e,n){if(e.indexOf("[]")===e.length-2&&(e=e.substring(0,e.length-2)),0!=e.indexOf("_")&&"cf7msm-step"!=e&&"cf7msm_options"!=e){var i=f.find('*[name="'+e+'"]:not([data-cf7msm-previous])'),r=f.find('input[name="'+e+'[]"]:not([data-cf7msm-previous])'),s=f.find('select[name="'+e+'[]"]:not([data-cf7msm-previous])');if(i.length>0)if("radio"==i.prop("type")||"checkbox"==i.prop("type")){if(null!==(o=u(a,e,n)))(c=i.filter('[value="'+o.new_val+'"]')).length>0&&(t('input[name="_wpcf7_free_text_'+e+'"]',f).val(o.free_val),n=o.new_val);i.filter(function(){return t(this).val()==n}).prop("checked",!1).trigger("click",[{cf7msm:!0}])}else i.is("select")?i.find("option").filter(function(){return this.value==n}).prop("selected",!0):i.val(n);else if(r.length>0&&n.constructor===Array){""!=n&&n.length>0&&t.each(n,function(e,n){r.filter(function(){return t(this).val()==n}).prop("checked",!1).trigger("click",[{cf7msm:!0}])});var o,c,l=n[n.length-1];if(null!==(o=u(a,e,l)))if((c=r.filter('[value="'+o.new_val+'"]')).length>0)c.prop("checked",!1).trigger("click",[{cf7msm:!0}]),t('input[name="_wpcf7_free_text_'+e+'"]').val(o.free_val)}else s.length>0&&n.constructor===Array&&""!=n&&n.length>0&&t.each(n,function(e,t){s.find("option").filter(function(){return this.value==t}).prop("selected",!0)})}}),f.find('input[name="_wpcf7cf_options"]').trigger("change"))}function u(e,t,n){var i=n;n.constructor===Array&&(i=n[n.length-1]);var r=null,a="_cf7msm_free_text_reflen_"+t;if(a in e){var s=parseInt(e[a]);s<=i.length&&(r={new_val:i.substring(0,s),free_val:i.substring(s+1)})}return r}}window.addEventListener("DOMContentLoaded",e=>{r()}),window.addEventListener("pagehide",e=>{i=!1}),window.addEventListener("pageshow",e=>{r(e.persisted)})}(jQuery),Storage.prototype.setObject=function(e,t){this.setItem(e,JSON.stringify(t))},Storage.prototype.getObject=function(e){var t=this.getItem(e);return t&&JSON.parse(t)};1 !function(e){var n,t=!1;function r(){var e="test";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(n){return!1}}function i(e,n){var t=e.getItem(n);return t&&JSON.parse(t)}function a(a){if(!t){t=!0;var s=cf7msm_posted_data,f=e("input[name='_cf7msm_multistep_tag']"),o=f.length>0;if(o||(o=(f=e("input[name='cf7msm-step']")).length>0),o){var l=f.closest("form"),c=l.find('input[name="_wpcf7"]').val();r()?null!=(n=i(sessionStorage,"cf7msm"))&&e.each(n,function(e,n){if("cf7msm_prev_urls"==e){var t=l.find(".wpcf7-back, .wpcf7-previous"),r=window.location.href,i=r.replace(/\/$/,""),a=!n.hasOwnProperty(r)||""==n[r];a&&(a=!n.hasOwnProperty(i)||""==n[i]),a&&(r=r.split("?")[0],i=r.replace(/\/$/,""),(a=!n.hasOwnProperty(r)||""==n[r])&&(a=!n.hasOwnProperty(i)||""==n[i])),a?t.hide():t.click(function(e){n.hasOwnProperty(r)&&""!=n[r]?window.location.href=n[r]:n.hasOwnProperty(i)&&""!=n[i]?window.location.href=n[i]:window.history.go(-1),e.preventDefault()})}}):(e("input[name='cf7msm-no-ss']").val(1),e(".wpcf7-previous").hide());var p=wpcf7.submit;wpcf7.submit=function(n,t){!function(n){(function(n){var t=n;t instanceof jQuery||(t=e(n));var r=t.find("input[name='_cf7msm_multistep_tag']");if(0==r.length)return;r.length>1&&(r=r.last());e("<input />",{type:"hidden",name:"cf7msm_options",value:r.val()}).appendTo(t)})(n),function(n){var t=n;t instanceof jQuery||(t=e(n));var r=e(".has-free-text",t);r.each(function(){var n=e(this),t=e("input:checkbox",n);if(0==t.length&&(t=e("input:radio",n)),0==t.length)return!1;var r=t.attr("name");r.indexOf("[]")===r.length-2&&(r=r.substring(0,r.length-2));var i="_cf7msm_free_text_reflen_"+r,a=e('input[name="'+i+'"]',n);t.is(":checked")?(0==a.length&&(a=e('<input type="hidden" name="'+i+'">'),n.append(a)),a.val(t.val().length)):a.length>0&&a.remove()})}(n)}(n),p(n,t)},a&&u(),window.addEventListener("load",function(){u()}),document.addEventListener("wpcf7mailsent",function(t){var a,s,f,o=e("#"+t.detail.unitTag+" form");if(r()){var l=0,p=0,u=[],m={};(n=i(sessionStorage,"cf7msm"))||(n={});var d=!1,h=!1,v=!0,_=!1,g=null,w=!1,x=e(".has-free-text",o),y={};if(e.each(t.detail.inputs,function(n){var r=t.detail.inputs[n].name,i=t.detail.inputs[n].value,a=e('input[name="'+r+'"]',x);if(a.length>0&&a.is(":checked")){var s=r;r.indexOf("[]")===r.length-2&&(s=r.substring(0,r.length-2));var f=i.length,o=e('input[name="_wpcf7_free_text_'+s+'"]',x).val(),O="_cf7msm_free_text_reflen_"+s;r.indexOf("[]")===r.length-2?y[r]={value:i,free_text:o,ref_len:f,ref_name:O}:(i+=" "+o,m[O]=f)}if(r.indexOf("[]")===r.length-2?(-1===e.inArray(r,u)&&(m[r]=[]),m[r].push(i)):m[r]=i,"cf7msm-step"===r){if(-1!==i.indexOf("-")){d=!0,h=!1;var k=i.split("-");l=parseInt(k[0]),p=parseInt(k[1]),void 0!==cf7msm_redirect_urls[c]&&(g=cf7msm_redirect_urls[c]),l<p?v=!1:l===p&&(_=!0)}}else if("cf7msm_options"===r){d=!0,h=!0,v=!1;var b=JSON.parse(i);b.hasOwnProperty("next_url")&&(g=b.next_url),b.hasOwnProperty("last_step")&&(w=!0,g&&""!==g||(_=!0,v=!0))}else u.push(r)}),e.each(y,function(e,n){if(m.hasOwnProperty(e)&&m[e].length>0){var t=m[e].length-1;m[e][t]===n.value&&(m[e][t]+=" "+n.free_text,m[n.ref_name]=n.ref_len)}}),!d)return;if(!v){var O=e("#"+t.detail.unitTag).find("div.wpcf7-mail-sent-ok");0==O.length&&(O=e("#"+t.detail.unitTag).find(".wpcf7-response-output")),O.remove()}if(_&&(o.find("*").not("div.wpcf7-response-output").hide(),o.find("div.wpcf7-response-output").parentsUntil("form").show()),h?w&&(n={}):0!=l&&l===p&&(n={}),g&&""!=g){var k=document.createElement("a");k.href=g;var b=k.hostname+(k.port?":"+k.port:""),P={};n&&n.cf7msm_prev_urls&&(P=n.cf7msm_prev_urls);var S=window.location.protocol+"//"+window.location.host;0===g.indexOf(S)||""!=b&&b!=window.location.host||(0!==g.indexOf("/")&&(S+="/"),g=S+g),P[g]=window.location.href;var I=g.split("?")[0];g!=I&&(P[I]=window.location.href),n.cf7msm_prev_urls=P}a=sessionStorage,s="cf7msm",f=n,a.setItem(s,JSON.stringify(f)),g&&""!=g&&(window.location.href=g)}},!1)}}function u(){s&&(e.each(s,function(n,t){if(n.indexOf("[]")===n.length-2&&(n=n.substring(0,n.length-2)),0!=n.indexOf("_")&&"cf7msm-step"!=n&&"cf7msm_options"!=n){var r=l.find('*[name="'+n+'"]:not([data-cf7msm-previous])'),i=l.find('input[name="'+n+'[]"]:not([data-cf7msm-previous])'),a=l.find('select[name="'+n+'[]"]:not([data-cf7msm-previous])');if(r.length>0)if("radio"==r.prop("type")||"checkbox"==r.prop("type")){if(null!==(f=m(s,n,t)))(o=r.filter('[value="'+f.new_val+'"]')).length>0&&(e('input[name="_wpcf7_free_text_'+n+'"]',l).val(f.free_val),t=f.new_val);r.filter(function(){return e(this).val()==t}).prop("checked",!1).trigger("click",[{cf7msm:!0}])}else r.is("select")?r.find("option").filter(function(){return this.value==t}).prop("selected",!0):r.val(t);else if(i.length>0&&t.constructor===Array){""!=t&&t.length>0&&e.each(t,function(n,t){i.filter(function(){return e(this).val()==t}).prop("checked",!1).trigger("click",[{cf7msm:!0}])});var f,o,c=t[t.length-1];if(null!==(f=m(s,n,c)))if((o=i.filter('[value="'+f.new_val+'"]')).length>0)o.prop("checked",!1).trigger("click",[{cf7msm:!0}]),e('input[name="_wpcf7_free_text_'+n+'"]').val(f.free_val)}else a.length>0&&t.constructor===Array&&""!=t&&t.length>0&&e.each(t,function(e,n){a.find("option").filter(function(){return this.value==n}).prop("selected",!0)})}}),l.find('input[name="_wpcf7cf_options"]').trigger("change"))}function m(e,n,t){var r=t;t.constructor===Array&&(r=t[t.length-1]);var i=null,a="_cf7msm_free_text_reflen_"+n;if(a in e){var s=parseInt(e[a]);s<=r.length&&(i={new_val:r.substring(0,s),free_val:r.substring(s+1)})}return i}}window.addEventListener("DOMContentLoaded",e=>{a()}),window.addEventListener("pagehide",e=>{t=!1}),window.addEventListener("pageshow",e=>{a(e.persisted)})}(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.