1/** 2 * 3 * @author : Saravana Kumar K 4 * @copyright : Sarkware Research & Development (OPC) Pvt Ltd 5 * 6 * Wcff client controller module 7 * 8 */ 9var wcffEditorObj=null,wcffValidatorObj=null,wcffFieldsRulerObj=null,wcffPricingRulerObj=null;!function(e){var t=null,i=!0,a=null,l=null;Array.prototype.equals=function(e){if(!e)return!1;if(this.length!=e.length)return!1;for(var t=0,i=this.length;t<i;t++)if(this[t]instanceof Array&&e[t]instanceof Array){if(!this[t].equals(e[t]))return!1}else if(this[t]!=e[t])return!1;return!0},Object.defineProperty(Array.prototype,"equals",{enumerable:!1}),Number.prototype.formatMoney=function(e,t,i){var a=this,l=(e=isNaN(e=Math.abs(e))?2:e,i=null==i?".":i,t=null==t?",":t,a<0?"-":""),c=parseInt(a=Math.abs(+a||0).toFixed(e))+"",r=(r=c.length)>3?r%3:0;return l+(r?c.substr(0,r)+t:"")+c.substr(r).replace(/(\d{3})(?=\d)/g,"$1"+t)+(e?i+Math.abs(a-c).toFixed(e).slice(2):"")};var c=function(){this.init=function(){e(document).on("change","[data-has_field_rules=yes]",this,(function(t){t.data.handleFieldChangeEvent(e(this))}
9)),e("[data-has_field_rules=yes]").trigger("change")},this.handleFieldChangeEvent=function(e){var t=0,i=0,a=this,l="",c="",r=[],s=!1,d="",f=[],n=e.attr("data-fkey"),o=e.attr("data-field-type"),_=e.closest("div.wcff-fields-group");_.attr("data-custom-layout");if("radio"==o?c=e.closest("ul").find("input[type=radio]:checked").val():"checkbox"==o?c=e.closest("ul").find("input[type=checkbox]:checked").map((function(){return a.escapeQuote(this.value)})).get():"datepicker"==o?(day=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],d=e.datepicker("getDate")):"text"!=o&&"number"!=o&&"select"!=o&&"textarea"!=o&&"colorpicker"!=o||(c=e.val()),wcff_fields_rules_meta[n])for(t=0;t<wcff_fields_rules_meta[n].length;t++)if("equal"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value==c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("not-equal"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value!=c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("greater-than-equal"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value<=c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("greater-than"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value<c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("less-than-equal"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value>=c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("less-than"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value>c)this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("is-only"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value.equals(c))this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("is-also"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value.some((e=>c.includes(e))))this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("any-one-of"==wcff_fields_rules_meta[n][t].logic){if((f=this.fetchCommonItems(wcff_fields_rules_meta[n][t].expected_value,c)).length<=wcff_fields_rules_meta[n][t].expected_value.length){for(s=!0,i=0;i<f.length;i++)-1===wcff_fields_rules_meta[n][t].expected_value.indexOf(f[i])&&(s=!1);s&&this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules)}}else if("has-options"==wcff_fields_rules_meta[n][t].logic&&wcff_fields_rules_meta[n][t].expected_value.some((e=>c.includes(e))))this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("has-not-options"!=wcff_fields_rules_meta[n][t].logic||wcff_fields_rules_meta[n][t].expected_value.some((e=>c.includes(e))))if("days"==wcff_fields_rules_meta[n][t].logic&&Array.isArray(wcff_fields_rules_meta[n][t].expected_value))-1!=wcff_fields_rules_meta[n][t].expected_value.indexOf(d.getDay())&&this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("specific-dates"==wcff_fields_rules_meta[n][t].logic&&""!=wcff_fields_rules_meta[n][t].expected_value)for(r=wcff_fields_rules_meta[n][t].expected_value.split(","),i=0;i<r.length;i++)l=r[i].trim().split("-"),parseInt(l[0].trim())==d.getMonth()+1&&parseInt(l[1].trim())==d.getDate()&&parseInt(l[2].trim())==d.getFullYear()&&this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("weekends-weekdays"==wcff_fields_rules_meta[n][t].logic)"weekends"==wcff_fields_rules_meta[n][t].expected_value?6!=d.getDay()&&0!=d.getDay()||this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules):6==d.getDay()&&0==d.getDay()||this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else if("specific-dates-each-month"==wcff_fields_rules_meta[n][t].logic)for(r=wcff_fields_rules_meta[n][t].expected_value.split(","),i=0;i<r.length;i++)parseInt(r[i].trim())==d.getDay()&&this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else"not-null"==wcff_fields_rules_meta[n][t].logic&&c?this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules):"null"!=wcff_fields_rules_meta[n][t].logic||""!==c&&null!=c||this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules);else this.handleFieldsVisibility(_,wcff_fields_rules_meta[n][t].field_rules)},this.handleFieldsVisibility=function(t,i){var a=null,l=t.attr("data-custom-layout");t.find(".wccpf-field ").each((function(){a="yes"==l?e(this).closest("div.wcff-layout-form-col"):e(this).parent().hasClass("wcff-label")?e(this).parent():e(this).closest("table.wccpf_fields_table"),i[e(this).attr("data-fkey")]&&("show"==i[e(this).attr("data-fkey")]?(a.show(),a.removeClass("wcff_is_hidden_from_field_rule")):"hide"==i[e(this).attr("data-fkey")]&&(a.hide(),a.addClass("wcff_is_hidden_from_field_rule")))}))},this.fetchCommonItems=function(t,i){return e.grep(t,(function(t){return-1!==e.inArray(t,i)}
9))},this.escapeQuote=function(e){return e&&(e=(e=e.replace(/'/g,"'")).replace(/"/g,""")),e},this.unEscapeQuote=function(e){return e&&(e=(e=e.replace(/'/g,"'")).replace(/"/g,'"')),e}},r=function(){this.init=function(){e(document).on("change","input[name=quantity]",this,(function(t){var i=parseInt(e(this).val()),a=parseInt(e("#wccpf_fields_clone_count").val());if(e("#wccpf_fields_clone_count").val(i),a<i){var l=0,c=0,r=0,s=t.data,d=null,f=null,n=null,_=!1;for(n=e(".wccpf-fields-group-container"),c=0;c<n.length;c++)if((f=e(n[c]).find("> div:not(.cloned)"))&&f.length>0){if("no"==f.attr("data-group-clonable"))continue;for(d=null,l=a;l<i;l++)(d=f.clone(!0)).addClass("cloned"),d.find("script").remove(),d.find("div.sp-replacer").remove(),d.find("span.wccpf-fields-group-title-index").html(l+1),d.find(".hasDatepicker").attr("id",""),d.find(".hasDatepicker").removeClass("hasDatepicker"),d.find(".wccpf-field").each((function(){e(this).hasClass("label")||(s.updateFieldIndex(l,e(this)),"checkbox"==e(this).attr("data-field-type")||"radio"==e(this).attr("data-field-type")?e(this).prop("checked",!1):e(this).val(""))})),d.find(".wccaf-field").each((function(){e(this).hasClass("label")||(s.updateFieldIndex(l,e(this)),"checkbox"==e(this).attr("data-field-type")||"radio"==e(this).attr("data-field-type")?e(this).prop("checked",!1):e(this).val(""))})),d.find(".wccvf-field").each((function(){e(this).hasClass("label")||(s.updateFieldIndex(l,e(this)),"checkbox"==e(this).attr("data-field-type")||"radio"==e(this).attr("data-field-type")?e(this).prop("checked",!1):e(this).val(""))})),d.find(".wcff-label").each((function(){_=e(this).attr("data-cloneable");var t=e(this).find("input").attr("name").slice(0,-1)+l;e(this).find("input").attr("name",t),void 0!==_&&!1!==_||e(this).remove()})),d.find("div[class=wcff-layout-form-col]:not(:has(*))").remove(),d.find("div[class=wcff-layout-form-row]:not(:has(*))").remove(),e(n[c]).append(d),setTimeout((function(){o()}),500)}}else{var p=a-i;for(n=e(".wccpf-fields-group-container"),c=0;c<n.length;c++)for(e(n[c]).find("> div"),r=0;r<p;r++)n.find("> div:nth-child("+(a-r)+")").remove()}})),setTimeout((function(){e("input[name=quantity]").trigger("change")}),300)},this.updateFieldIndex=function(e,t){var i=t.attr("data-cloneable");if("checkbox"!==t.attr("data-field-type")&&"radio"!==t.attr("data-field-type")||(i=t.closest("ul").attr("data-cloneable")),void 0===i&&(i="yes"),"no"!==i){var a=t.attr("name");if(-1!=a.indexOf("[]")){var l=a.substring(0,a.lastIndexOf("_"));a=l+"_"+(e+1)+"[]"}else a=a.slice(0,-1)+(e+1);t.attr("name",a)}else t.closest("table.wccpf_fields_table").remove()}},s=function(){this.isValid=!0,this.init=function(){e(document).on("submit","form.cart",this,(function(t){var i=t.data;return t.data.isValid=!0,e(this).find(".wccpf-field").each((function(){"yes"===e(this).attr("data-mandatory")&&i.doValidate(e(this))})),t.data.isValid})),"blur"===wccpf_opt.validation_type&&e(document).on("blur",".wccpf-field",this,(function(t){"yes"===e(this).attr("data-mandatory")&&t.data.doValidate(e(this))}))},this.doValidate=function(e){if("radio"!==e.attr("data-field-type")&&"checkbox"!==e.attr("data-field-type")&&"file"!==e.attr("data-field-type"))"select"!==e.attr("data-field-type")?this.doPatterns(e.attr("data-pattern"),e.val())?e.nextAll(".wccpf-validation-message").hide():(this.isValid=!1,e.nextAll(".wccpf-validation-message").css("display","block")):""!==e.val()&&"wccpf_none"!==e.val()?e.nextAll(".wccpf-validation-message").hide():(this.isValid=!1,e.nextAll(".wccpf-validation-message").css("display","block"));else if("radio"===e.attr("data-field-type"))e.closest("td.wccpf_value").find("input[type=radio]").is(":checked")?e.closest("td.wccpf_value").find("span.wccpf-validation-message").hide():(e.closest("td.wccpf_value").find("span.wccpf-validation-message").css("display","block"),this.isValid=!1);else if("checkbox"===e.attr("data-field-type")){0===e.closest("td.wccpf_value").find("input[type=checkbox]:checked").map((function(){return this.value})).get().length?(e.closest("td.wccpf_value").find("span.wccpf-validation-message").css("display","block"),this.isValid=!1):e.closest("td.wccpf_value").find("span.wccpf-validation-message").hide()}else"file"===e.attr("data-field-type")&&(""==e.val()?(e.next().css("display","block"),this.isValid=!1):e.next().hide());return this.isValid},this.doPatterns=function(e,t){var i={mandatory:/\S/,number:/^-?\d+\.?\d*$/,email:/^([\w-]+(?:\.[\w-]+)*)@((?
9:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i};return!e||!i[e]||i[e].test(t)}},d=function(){this.top=0,this.left=0,this.bottom=0,this.right=0,this.target=null,this.mask=null,this.getPosition=function(t){this.target=t;var i=this.target.position(),a=this.target.offset();this.top=a.top,this.left=a.left,this.bottom=e(window).width()-i.left-this.target.width(),this.right=e(window).height()-i.right-this.target.height()},this.doMask=function(t){t&&(this.target=t,this.mask=e('<div class="wcff-dock-loader"></div>'),this.target.append(this.mask),this.mask.css("left","0px"),this.mask.css("top","0px"),this.mask.css("right",this.target.innerWidth()+"px"),this.mask.css("bottom",this.target.innerHeight()+"px"),this.mask.css("width",this.target.innerWidth()+"px"),this.mask.css("height",this.target.innerHeight()+"px"))},this.doUnMask=function(){this.mask&&this.mask.remove()}},f=function(){this.appliedRules={},this.init=function(){this.registerEvents()},this.registerEvents=function(){e(document).on("change","[data-has_pricing_rules=yes]",this,(function(t){t.data.updatePrice(e(this)),t.data.refreshPricingRuleTitles(e(this))}))},this.refreshPricingRuleTitles=function(t){var i=this,a=[],l=[],c="",r=[],s=null;void 0!==t?t.closest("div.wcff-fields-group"):e("div.wccpf-fields-container"),e("div.wcff-fields-group").each((function(){if(c="",l=e(this).find('[data-has_pricing_rules="yes"]'),r=i.getFieldsPricingRules(l),Array.isArray(r)&&r.length>0)for(let e=0;e<r.length;e++)if(wcff_pricing_rules_meta&&wcff_pricing_rules_meta[r[e].fkey]){a=wcff_pricing_rules_meta[r[e].fkey];for(let t=0;t<a.length;t++)i.checkPricingRules(a[t],r[e].fval,r[e].ftype,r[e].dformat)&&("cost"==a[t].tprice?c+=a[t].title+" : "+wccpf_opt.currency+a[t].amount+"<br/>":c+=a[t].title+" : "+a[t].amount+"%<br/>")}"show"==wccpf_opt.price_details&&""!=c?0==(s=e(this).find(".wcff_pricing_rules_title_container")).length?e(this).append('<div class="wcff_pricing_rules_title_container">'+c+"</div>"):(s.html(c),s.show()):e(this).find(".wcff_pricing_rules_title_container").hide()}))},this.updatePrice=function(t){var i,a=[];a="archive"==wccpf_opt.is_page?t.closest("li.product").find("[data-is_pricing_rules=yes]"):e('[data-has_pricing_rules="yes"]'),i=this.getFieldsPricingRules(a),Array.isArray(i)&&i.length>0&&this.determineThePrice(i,t)},this.getFieldsPricingRules=function(t){var i="",a="",l=[],c=null;for(let r=0;r<t.length;r++)((c=e(t[r])).is(":visible")||c.is(".wccpf-color")&&c.closest("table").is(":visible")&&!c.closest("table").is(".wcff_is_hidden_from_field_rule"))&&(i=c.attr("data-fkey"),c.is("[type=checkbox]")?(a=[],c.is(":checked")&&(a=[c.val()])):c.is("[type=radio]")?(a="",c.is(":checked")&&(a=c.val())):a=c.val(),l.push({fkey:i,fval:a,ftype:c.attr("data-field-type"),dformat:c.attr("data-date-format")}));return l},this.determineThePrice=function(t,i){var a,l,c,r,s=[],d="",f=[],n=0,o=0,_=0;if("yes"==wcff_is_variable){if(""==e("input[name=variation_id]").val())return;for(f=e("form.variations_form").attr("data-product_variations"),f=JSON.parse(f),s=Object.keys(f),a=0;a<s.length;a++)f[s[a]].variation_id==e("input[name=variation_id]").val()&&(n=f[s[a]].display_regular_price)}else n=wcff_product_price;for(a=0;a<t.length;a++)if(wcff_pricing_rules_meta&&wcff_pricing_rules_meta[t[a].fkey])for(c=wcff_pricing_rules_meta[t[a].fkey],l=0;l<c.length;l++)this.checkPricingRules(c[l],t[a].fval,t[a].ftype,t[a].dformat)&&("cost"==c[l].tprice?"add"==c[l].ptype?o+=parseFloat(c[l].amount):"sub"==c[l].ptype?o-=parseFloat(c[l].amount):_+=parseFloat(c[l].amount):"add"==c[l].ptype?o+=parseFloat(c[l].amount)/100*n:"sub"==c[l].ptype?o-=parseFloat(c[l].amount)/100*n:_+=parseFloat(c[l].amount)/100*n,c[l].title+" : "+wccpf_opt.currency+c[l].amount+"<br/>");n=_>0?o+_:n+o+_,"enable"==wccpf_opt.real_time_price_update&&(r=wccpf_opt.number_of_decimal,"yes"==wccpf_opt.trim_zeros&&(r=0),"left"==wccpf_opt.currency_position?d='<bdi><span class="woocommerce-Price-currencySymbol">'+wccpf_opt.currency+"</span>"+n.formatMoney(r,wccpf_opt.thousand_seperator,wccpf_opt.decimal_seperator)+"</bdi>":"right"==wccpf_opt.currency_position?d="<bdi>"+n.formatMoney(r,wccpf_opt.thousand_seperator,wccpf_opt.decimal_seperator)+'<span class="woocommerce-Price-currencySymbol">'+wccpf_opt.currency+"</span></bdi>
9":"left_space"==wccpf_opt.currency_position?d='<bdi><span class="woocommerce-Price-currencySymbol">'+wccpf_opt.currency+"</span> "+n.formatMoney(r,wccpf_opt.thousand_seperator,wccpf_opt.decimal_seperator)+"</bdi>":"right_space"==wccpf_opt.currency_position&&(d="<bdi>"+n.formatMoney(r,wccpf_opt.thousand_seperator,wccpf_opt.decimal_seperator)+' <span class="woocommerce-Price-currencySymbol">'+wccpf_opt.currency+"</span></bdi>"),"default"==wccpf_opt.price_container_is?("yes"==wcff_is_variable?e("form.variations_form span.amount"):e("div.summary span.amount")).html(d):e(wccpf_opt.price_container).length>0&&e(wccpf_opt.price_container).html('<span class="woocommerce-Price-amount amount">'+d+"</span>"))},this.checkPricingRules=function(e,t,i,a){var l,c,r,s;if(e&&e.expected_value&&e.logic&&""!=t||"datepicker"==i)if("checkbox"!=i&&"datepicker"!=i){if("equal"==e.logic)return e.expected_value.trim()==t.trim();if("not-equal"==e.logic)return e.expected_value!=t;if("greater-than"==e.logic)return parseFloat(t)>parseFloat(e.expected_value);if("less-than"==e.logic)return parseFloat(t)<parseFloat(e.expected_value);if("greater-than-equal"==e.logic)return parseFloat(t)>=parseFloat(e.expected_value);if("less-than-equal"==e.logic)return parseFloat(t)<=parseFloat(e.expected_value);if("not-null"==e.logic)return""!=t.trim()}else if("checkbox"==i){if(Array.isArray(e.expected_value)&&Array.isArray(t)&&"has-options"==e.logic){if(!(t.length>=e.expected_value.length))return!1;for(l=0;l<e.expected_value.length;l++)if(-1==t.indexOf(e.expected_value[l]))return!1;return!0}}else if("datepicker"==i){if(""==t)return!1;var d=(a.match(/y/gi)||[]).length;2==d?a=a.replace("yy","yyyy"):1==d&&(a=a.replace("y","yy"));const i=moment(t,a.toUpperCase());if(i&&e.expected_value.dtype&&e.expected_value.value){if("days"==e.expected_value.dtype&&(c=i.format("dddd"),Array.isArray(e.expected_value.value)&&-1!=e.expected_value.value.indexOf(c.toLowerCase())))return!0;if("specific-dates"==e.expected_value.dtype&&(s=e.expected_value.value.split(","),Array.isArray(s)))for(l=0;l<s.length;l++)if(r=moment(s[l].trim(),"M-D-YYYY"),i.format("M-D-YYYY")==r.format("M-D-YYYY"))return!0;if("weekends-weekdays"==e.expected_value.dtype)if("weekends"==e.expected_value.value){if("saturday"==i.format("dddd").toLowerCase()||"sunday"==i.format("dddd").toLowerCase())return!0}else if("saturday"!=i.format("dddd").toLowerCase()&&"sunday"!=i.format("dddd").toLowerCase())return!0;if("specific-dates-each-month"==e.expected_value.dtype)for(s=e.expected_value.value.split(","),l=0;l<s.length;l++)if(s[l].trim()==i.format("D"))return!0}}return!1}},n=function(){var i=this;this.init=function(){this.registerEvent()},this.registerEvent=function(){e(document).on("dblclick","li.wcff_cart_editor_field",this,(function(t){if(!(e("div.wccpf-cart-edit-wrapper").length>0)){var i=e(this);i.closest("ul.wccpf-is-editable-yes").removeClass("wccpf-is-editable-yes"),0!=!i.find("input, select, textarea, label").length&&i.is(".wcff_cart_editor_field")&&t.data.getFieldForEdit(i)}})),e(document).on("click",".wccpf-update-cart-field-btn",this,(function(t){t.data.updateField(e(this)),t.preventDefault()})),e(document).on("click","#wccpf-cart-editor-close-btn",(function(i){var a=e(this).parent();a.closest("ul.wccpf-cart-editor-ul").addClass("wccpf-is-editable-yes"),a.prev().show(),a.remove(),t.doUnMask(),i.preventDefault()})),e(window).on("keydown",(function(t){var i=t.keyCode?t.keyCode:t.which,a=e("div.wccpf-cart-edit-wrapper");27===i&&a.length>0&&(a.closest("ul.wccpf-cart-editor-ul").addClass("wccpf-is-editable-yes"),a.prev().show(),a.remove())})),e(document).on("change","[data-is_pricing_rules=yes]",(function(t){i.updateNegotiatePrice(e(this))})),setTimeout((function(){e('[data-has_field_rules="yes"]').trigger("change"),"archive"!=wccpf_opt.is_page&&i.updateNegotiatePrice()}),180),e(document).on("change","input[name=variation_id]",(function(){""!=e("input[name=variation_id]").val().trim()?(_("wcff_variation_fields","GET",{variation_id:e("input[name=variation_id]").val()}),p("wcff_variation_fields")):(e(".wcff-variation-field").html(""),i.updateNegotiatePrice(e(this)))}))},this.getFieldForEdit=function(t){var i=0!=t.find(".wcff-color-picker-color-show").length?t.find(".wcff-color-picker-color-show").css("background-color"):e.trim(t.find("p").text());_("wcff_render_field_on_cart_edit","GET",{product_id:t.attr("data-productid"),product_cart_id:t.attr("data-itemkey"),data:{value:i,field:t.attr("data-field"),name:t.attr("data-fieldname")}}),p("inflate_field_for_edit",t)},this.updateNegotiatePrice=function(t){if(t){var i=e(""),a="no",l="yes"==wccpf_opt.cloning?"yes":"no",c="archive"==wccpf_opt.is_page?t.closest("li.product").find("[data-is_pricing_rules=ye
9s]"):e("[data-is_pricing_rules=yes]"),r={_product_id:"archive"==wccpf_opt.is_page?t.closest("li.product").find("a.add_to_cart_button").attr("data-product_id"):0!=e("input[name=add-to-cart]").length?e("input[name=add-to-cart]").val():e("button[name=add-to-cart]").val(),_variation_id:e("input[name=variation_id]").val(),_fields_data:[]};if(0==e("input[name=variation_id]").length||""!=e("input[name=variation_id]").val().trim()&&"0"!=e("input[name=variation_id]").val().trim())for(var s=0;s<c.length;s++)if((i=e(c[s])).is(":visible")||i.is(".wccpf-color")&&i.closest("table").is(":visible")&&!i.closest("table").is(".wcff_is_hidden_from_field_rule")){a="yes"==l?i.is("[type=radio]")||i.is("[type=checkbox]")?i.closest("ul").data("cloneable"):i.data("cloneable"):l;var d=i.is("[type=checkbox]")?i.attr("name").replace("[","").replace("]",""):i.attr("name"),f=i.is("[type=checkbox]")?i.prop("checked")?[i.val()]:[]:i.is("[type=radio]")?i.is(":checked")?i.val():"":i.val();r._fields_data.push({is_clonable:a,name:d,value:f})}}},this.updateField=function(e){var t=null,i=new s,a=e.closest("div.wccpf-cart-edit-wrapper").attr("data-field"),l=e.closest("div.wccpf-cart-edit-wrapper").attr("data-field_name"),c=e.closest("div.wccpf-cart-edit-wrapper").attr("data-field_type"),r=e.closest("div.wccpf-cart-edit-wrapper").attr("data-product_id"),d=e.closest("div.wccpf-cart-edit-wrapper").attr("data-item_key");"radio"===c?(i.doValidate(e.closest("div.wccpf-cart-edit-wrapper").find("input")),t=e.closest("div.wccpf-cart-edit-wrapper").find("input:checked").val()):"checkbox"===c?(i.doValidate(e.closest("div.wccpf-cart-edit-wrapper").find("input")),t=e.closest("div.wccpf-cart-edit-wrapper").find("input:checked").map((function(){return this.value})).get()):(i.doValidate(e.closest("div.wccpf-cart-edit-wrapper").find(".wccpf-field")),t=e.closest("div.wccpf-cart-edit-wrapper").find(".wccpf-field").val()),i.isValid&&(_("wcff_update_cart_field_data","PUT",{product_id:r,cart_item_key:d,data:{field:a,name:l,value:t,field_type:c}}),p("update_cart_field_data",e))},this.responseHandler=function(t,i){if(l.status)if("inflate_field_for_edit"===t&&l.payload){var c="",r=e("head"),s=e(l.payload.html).find("td:last"),d='<button data-color_show="'+l.payload.color_showin+'" class="button wccpf-update-cart-field-btn">Update</button>';"file"!==l.payload.field_type&&(c='<div class="wccpf-cart-edit-wrapper wccpf-cart-edit-'+l.payload.field_type+'-wrapper" data-field_type="'+l.payload.field_type+'" data-field="'+i.attr("data-field")+'" data-field_name="'+i.attr("data-fieldname")+'" data-product_id="'+i.attr("data-productid")+'" data-item_key="'+i.attr("data-itemkey")+'">',c+='<a href="#" id="wccpf-cart-editor-close-btn" title="Close Editor"></a>',c+=s.html()+d,c=e(c+="<div>"),i.hide(),i.parent().append(c)),"email"==l.payload.field_type||"text"==l.payload.field_type||"number"==l.payload.field_type||"textarea"==l.payload.field_type?c.find("input").trigger("focus"):"colorpicker"==l.payload.field_type?r.append(l.payload.script):"datepicker"==l.payload.field_type&&(i.parent().find(".wccpf-field").val(a.payload.data.value),0==r.find("script[data-type=wpff-datepicker-script]").length&&r.append(l.payload.script),r.append(e(l.payload.html)[2]))}else if("update_cart_field_data"==t)l.payload.status?("colorpicker"!==l.payload.field_type?i.closest("div.wccpf-cart-edit-wrapper").parent().find("li.wcff_cart_editor_field").show().html("<p>"+decodeURI(l.payload.value)+"</p>"):"yes"===i.closest("div.wccpf-cart-edit-wrapper").parent().find("li.wcff_cart_editor_field").attr("data-color-box")?i.closest("div.wccpf-cart-edit-wrapper").parent().find("li.wcff_cart_editor_field").show().html('<p><span class="wcff-color-picker-color-show" style="background: '+decodeURI(l.payload.value)+';"></span></p>'):i.closest("div.wccpf-cart-edit-wrapper").parent().find("li.wcff_cart_editor_field").show().html("<p>"+decodeURI(l.payload.value)+"</p>"),i.closest("ul.wccpf-cart-editor-ul").addClass("wccpf-is-editable-yes"),i.closest("div.wccpf-cart-edit-wrapper").remove()):i.prev().html(l.payload.message).show();else if("wcff_ajax_get_negotiated_price"==t){var f=void 0===i?e("div.product"):"single"==wccpf_opt.is_page?i.closest("div.product"):i.closest("li.product");
9if(l.payload.status){var n=f.find(".wcff_pricing_rules_title_container"),o="";"show"==wccpf_opt.ajax_pricing_rules_title.trim()&&0!=l.payload.data.data_title.length&&(o+='<h4 class="wcff_pricing_rules_title_container">'+wccpf_opt.ajax_pricing_rules_title_header.trim()+"</h4>"),o+="<table><tbody>";for(var _=0;_<l.payload.data.data_title.length;_++)o+="<tr><td>"+l.payload.data.data_title[_].title+"</td><td>"+l.payload.data.data_title[_].amount+"</td></tr>";o+="</table></tbody>","show"==wccpf_opt.price_details&&(0!=n.length?(n.html(o),0==l.payload.data.data_title.length?e(".wcff_pricing_rules_title_container").hide():e(".wcff_pricing_rules_title_container").show()):f.find(".wccpf_fields_table:last").parent().after('<div class="wcff_pricing_rules_title_container">'+o+"</div>")),"archive"==wccpf_opt.is_page?f.find("span.price span.amount:last").replaceWith(l.payload.data.amount):"default"==wccpf_opt.ajax_pricing_rules_price_container_is||"both"==wccpf_opt.ajax_pricing_rules_price_container_is?(0!=e(".summary.entry-summary .woocommerce-variation-price:visible").length?e(".summary.entry-summary .woocommerce-variation-price").html(l.payload.data.amount):e(".summary.entry-summary .price .woocommerce-Price-amount").replaceWith(l.payload.data.amount),"both"==wccpf_opt.ajax_pricing_rules_price_container_is&&e(wccpf_opt.ajax_price_replace_container).html(l.payload.data.amount)):e(wccpf_opt.ajax_price_replace_container).html(l.payload.data.amount)}e(".woocommerce-variation-add-to-cart .button, button[name=add-to-cart]").removeClass("disabled")}else if("wcff_variation_fields"==t){if((u=e(".wcff-variation-field")).html(""),0!=u.length){var p=l.payload.data;for(_=0;_<p.length;_++)"color_picker_scripts"==p[_].location?e("body").append(p[_].html):e(".wcff-variation-field[data-area='"+p[_].location+"']").append(p[_].html)}var u=e(".wcff-variation-cloning-field-container");for(_=0;_<u.length;_++){var h=e(u[_]);0==h.find(".wcff-variation-field").children().length?h.hide():h.show()}e('[data-has_field_rules="yes"]').trigger("change")}}};function o(){var t=0,i=0,a={},l=[],c=Object.keys(wcff_color_picker_meta);for(t=0;t<c.length;t++){if(l=[],(a={}).color=wcff_color_picker_meta[c[t]].default_value,a.preferredFormat=wcff_color_picker_meta[c[t]].color_format,wcff_color_picker_meta[c[t]].palettes&&wcff_color_picker_meta[c[t]].palettes.length>0){for(a.showPalette=!0,"yes"==wcff_color_picker_meta[c[t]].show_palette_only&&(a.showPaletteOnly=!0),i=0;i<wcff_color_picker_meta[c[t]].palettes.length;i++)l.push(wcff_color_picker_meta[c[t]].palettes[i].split(","));a.palette=l}"yes"!=wcff_color_picker_meta[c[t]].show_palette_only&&"yes"==wcff_color_picker_meta[c[t]].color_text_field&&(a.showInput=!0),e("input.wccpf-color-"+c[t]).spectrum(a)}}function _(e,t,i,l){a={method:t,context:e,post:l,post_type:"wccpf",payload:i}}function p(c,r,s){i&&e.ajax({type:"POST",data:{action:"wcff_ajax",wcff_param:JSON.stringify(a)},dataType:"json",url:woocommerce_params.ajax_url,beforeSend:function(){i=!1,t&&r&&t.doMask(r)},success:function(t){var a,s,d;i=!0,a=t.status,s=t.message,d=t.data,(l={status:a,message:s,payload:d}).status&&function(t,i){if(!l.status)return;"wcff_variation_fields"===t?function(){var t=0,i=[];if(e("div.wccvf-loading-spinner").remove(),e("table.variations select").prop("disabled",!1),e("#wcff-variation-fields").removeClass("loading"),e("input[name=variation_id]").val()){if(e("#wcff-variation-fields").html(l.payload.html),l.payload.meta=JSON.parse(l.payload.meta),wcff_date_picker_meta)for(wcff_date_picker_meta=Array.isArray(wcff_date_picker_meta)?{}:wcff_date_picker_meta,i=Object.keys(l.payload.meta.date_picker_meta),t=0;t<i.length;t++)wcff_date_picker_meta[i[t]]=l.payload.meta.date_picker_meta[i[t]];if(wcff_color_picker_meta){for(wcff_color_picker_meta=Array.isArray(wcff_color_picker_meta)?{}:wcff_color_picker_meta,i=Object.keys(l.payload.meta.color_picker_meta),t=0;t<i.length;t++)wcff_color_picker_meta[i[t]]=l.payload.meta.color_picker_meta[i[t]];o()}if(wcff_fields_rules_meta)for(wcff_fields_rules_meta=Array.isArray(wcff_fields_rules_meta)?{}:wcff_fields_rules_meta,i=Object.keys(l.payload.meta.fields_rules_meta),t=0;t<i.length;t++)wcff_fields_rules_meta[i[t]]=l.payload.meta.fields_rules_meta[i[t]];if(wcff_pricing_rules_meta)for(wcff_pricing_rules_meta=Array.isArray(wcff_pricing_rules_meta)&&0==wcff_pricing_rules_meta.length?{}:wcff_pricing_rules_meta,i=Object.keys(l.payload.meta.pricing_rules_meta),t=0;t<i.length;t++)wcff_pricing_rules_meta[i[t]]=l.payload.meta.pricing_rules_meta[i[t]];setTimeout((function(){wcffPricingRulerObj.updatePrice()}),200)}}():wcffEditorObj&&wcffEditorObj.responseHandler(t,i)}(c,r)},error:function(e,t,a){i=!0},complete:function(){t.doUnMask()}})}function u(t,i){for(var a={},l=e(""),c=0;c<t.length;c++)if(0==(l=e(t[c])).closest(".wcff_is_hidden_from_field_rule").length)if(wcffValidatorObj&&"yes"===l.attr("data-mandatory")&&wcffValidatorObj.doValidate(l),l.is("[type=checkbox]")||l.is("[type=radio]")){if(l.is("[type=radio]"))a[l.attr("name")]=i.find('[name="'+l.attr("name")+'"]:checked').val();else if(l.is("[type=checkbox]")&&l.is(":checked")){var r=l.attr("name").replace("[]","");void 0===a[r]&&(a[r]=[]),a[r].push(l.val())}}else a[l.attr("name")]=i.find('[name="'+l.attr("name")+'"]').val();return a}e(document).on("focus","input.wccpf-datepicker",(function(){var t,i,a,l={},c=null,r=[],s=[],d=[],f=null,n="",o="",_=e(this).attr("data-fkey"),p=new Date;if(wcff_date_picker_meta&&wcff_date_picker_meta[_]){if(c=wcff_date_picker_meta[_],void 0!==e&&void 0!==e.datepicker&&("none"!=c.localize&&"en"!=c.localize?e.datepicker.setDefaults(e.extend({},e.datepicker.regional[c.localize])):e.datepicker.setDefaults(e.extend({},e.datepicker.regional["en-GB"]))),c.field.timepicker&&"yes"===c.field.timepicker&&(l.controlType="select",l.oneLine=!0,l.timeFormat="hh:mm tt",c.field.min_max_hours_minutes&&""!==c.field.min_max_hours_minutes&&2===(d=c.field.min_max_hours_minutes.split("|")).length&&(""!==d[0]&&2===(r=d[0].split(":")).length&&(l.hourMin=r[0],l.hourMax=r[1]),""!==d[1]&&2===(s=d[1].split(":")).length&&(l.minuteMin=s[0],l.minuteMax=s[1]))),l.dateFormat=c.dateFormat,c.field.display_in_dropdown&&"yes"===c.field.display_in_dropdown&&(l.changeMonth=!0,l.changeYear=!0,l.yearRange=c.year_range),c.field.disable_date&&""!==c.field.disable_date&&("future"===c.field.disable_date&&(l.maxDate=0),"past"===c.field.disable_date&&(l.minDate=new Date)),c.field.disable_next_x_day&&""!=c.field.disable_next_x_day){let e=p.getDay(),t=parseInt(c.field.disable_next_x_day,10);if(c.field.weekend_weekdays&&"weekends"==c.field.weekend_weekdays)if(6==e||0==e)6==e?t+=2:0==e&&(t+=1);else{e+t>5&&(t+=2)}l.minDate="+'"+t+"'d"}(c.field.allow_next_x_years&&""!=c.field.allow_next_x_years||c.field.allow_next_x_months&&""!=c.field.allow_next_x_months||c.field.allow_next_x_weeks&&""!=c.field.allow_next_x_weeks||
9c.field.allow_next_x_days&&""!=c.field.allow_next_x_days)&&(o="",c.field.allow_next_x_years&&""!=c.field.allow_next_x_years&&(o+="+"+c.field.allow_next_x_years.trim()+"y "),c.field.allow_next_x_months&&""!=c.field.allow_next_x_months&&(o+="+"+c.field.allow_next_x_months.trim()+"m "),c.field.allow_next_x_weeks&&""!=c.field.allow_next_x_weeks&&(o+="+"+c.field.allow_next_x_weeks.trim()+"w "),c.field.allow_next_x_days&&""!=c.field.allow_next_x_days&&(o+="+"+c.field.allow_next_x_days.trim()+"d"),l.minDate=0,l.maxDate=o.trim()),l.onSelect=function(t){e(this).trigger("change"),e(this).next().hide()},l.beforeShowDay=function(l){var r=0,s="",d=l.getDay(),o="",_="";if(c.field.disable_days&&c.field.disable_days.length>0)for(d=l.getDay(),o=c.field.disable_days,r=0;r<o.length;r++)if(d==(s="sunday"==(s=o[r])?0:"monday"==s?1:"tuesday"==s?2:"wednesday"==s?3:"thursday"==s?4:"friday"==s?5:"saturday"==s?6:""))return[!1];if(c.field.specific_date_all_months&&""!=c.field.specific_date_all_months){_=c.field.specific_date_all_months.split(",");for(r=0;r<_.length;r++)if(parseInt(_[r].trim())==l.getDate())return[!1]}if(c.field.specific_dates&&""!=c.field.specific_dates){n=c.field.specific_dates.split(",");for(r=0;r<n.length;r++)n[r]=n[r].trim();if(t=l.getMonth(),i=l.getDate(),a=l.getFullYear(),f=t+1+"-"+i+"-"+a,-1!=e.inArray(f,n))return[!1]}if(c.field.disable_next_x_day&&c.field.disable_next_x_day,c.field.weekend_weekdays&&""!=c.field.display_in_dropdown){if("weekdays"==c.field.weekend_weekdays)return[!e.datepicker.noWeekends(l)[0]];if("weekends"==c.field.weekend_weekdays)return e.datepicker.noWeekends(l)}return[!0]}}c.field.timepicker&&"yes"===c.field.timepicker?e(this).datetimepicker(l):e(this).datepicker(l)})),e(document).on("change","input[name=variation_id]",(function(){var t=e("input[name=variation_id]").val();""!=t.trim()?e("#wcff-variation-fields").length>0&&(e("table.variations select").prop("disabled",!0),e("#wcff-variation-fields").addClass("loading"),e("a.reset_variations").after(e('<div class="wccvf-loading-spinner"></div>')),_("wcff_variation_fields","GET",{variation_id:t},""),p("wcff_variation_fields",e("#wcff-variation-fields"))):e("#wcff-variation-fields").html("")})),e(document).on("reset_data",(function(){e("#wcff-variation-fields").html("")})),e(document).on("submit","form.cart",(function(){if(console.log("on submit called"),e(".wcff_is_hidden_from_field_rule").remove(),void 0!==wccpf_opt.location){var t=e(this);e(".wccpf_fields_table").each((function(){let i=e(this).closest("li.product");if(!(i&&i.length>0)&&0==e(this).closest("form.cart").length){var a=e(this).clone(!0);a.css("display","none"),"select"===e(this).find(".wccpf-field").attr("data-field-type")&&a.find("select.wccpf-field").val(e(this).find("select.wccpf-field").val()),t.append(a)}}))}})),e(document).ready((function(){if(t=new d,"undefined"!=typeof wccpf_opt){if(void 0!==wccpf_opt.cloning&&"yes"===wccpf_opt.cloning)(new r).init();void 0!==wccpf_opt.validation&&"yes"===wccpf_opt.validation&&(wcffValidatorObj=new s).init()}if((wcffFieldsRulerObj=new c).init(),(wcffPricingRulerObj=new f).init(),0!=e(".single-product").length||void 0!==wccpf_opt.editable&&"yes"===wccpf_opt.editable||0!=e("[data-is_pricing_rules=yes]").length)(wcffEditorObj=new n).init();else{var i=e("li.wcff_cart_editor_field");i.removeClass("wcff_cart_editor_field").removeAttr("title data-field data-fieldname data-productid data-itemkey"),i.closest(".wccpf-is-editable-yes").removeClass("wccpf-is-editable-yes")}"undefined"==typeof wcff_color_picker_meta||e.isEmptyObject(wcff_color_picker_meta)||o(),_("wcff_variation_fields","GET",{variation_id:0}),p("wcff_variation_fields"),"archive"===wccpf_opt.is_page&&"no"==wccpf_opt.is_ajax_add_to_cart&&e(document).on("click",".add_to_cart_button:not(.product_type_variable)",(function(t){var i=e(this).closest("li.product"),a=u(i.find(".wccpf_fields_table:not(.wcff_is_hidden_from_field_rule) .wccpf-field"),i),l="";for(var c in a)l+="&"+c+"="+a[c];""!=l&&e(this).attr("href",e(this).attr("href")+l)})),e(document).on("change",".wccpf-field",(function(t){var i=e(this);if(i.is("input[type=file]")&&"yes"===i.attr("data-preview")&&-1!==e.inArray(i.val().split(".").pop().toLowerCase(),["jpeg","jpg","png","gif","bmp"])){i.next().is(".wcff_image_prev_shop_continer")||i.after('<div class="wcff_image_prev_shop_continer" style="width:'+i.attr("data-preview-width")+'"></div>');for(var a="",l=0;l<i[0].files.length;l++)a+='<img class="wcff-prev-shop-image" src="'+URL.createObjectURL(i[0].files[l])+'">',i[0].files[l].name=i[0].files[l].name.replace(/'|$|,/g,""),i[0].files[l].name=i[0].files[l].name.replace("$","");i.next(".wcff_image_prev_shop_continer").html(a)}})),e(document).on("change",".wccpf-color-radio-btn-wrapper input[type=radio]",(function(){e(".wccpf-color-radio-btn-wrapper").removeClass("active"),e(".wccpf-color-radio-btn-wrapper").each((function(){e(this).find("input[type=radio]").is(":checked")&&e(this).addClass("active")}))})),e(document).on("change",".wccpf-image-radio-btn-wrapper input[type=radio]",(function(){e(".wccpf-image-radio-btn-wrapper").removeClass("active"),e(".wccpf-image-radio-btn-wrapper").each((function(){e(this).find("input[type=radio]").is(":checked")&&e(this).addClass("active")}))})),e(document).on("change",".wccpf-text-radio-btn-wrapper input[type=radio]",(function(){e(".wccpf-text-radio-btn-wrapper").removeClass("active"),e(".wccpf-text-radio-btn-wrapper").each((function(){e(this).find("input[type=radio]").is(":checked")&&e(this).addClass("active")}))})),e(document.body).on("adding_to_cart",(function(t,i,a){let l=null;if(i&&!i instanceof jQuery&&(i=e(i)),i instanceof jQuery&&(l=i.closest("li.product"),l&&0!=l.length||(l=i.closest("form.cart")),l&&!l instanceof jQuery&&(l=e(l)),l&&l.length>0)){let t=u(l.find(".wccpf_fields_table .wccpf-field"),l);e.extend(a,t)}})),setTimeout((function(){"archive"!=wccpf_opt.is_page&&wcffPricingRulerObj.updatePrice()}),200)}))}(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.