b0y-101 Mini Shell


Current Path : E:/www/raff/wp-content/plugins/wpforms/pro/assets/js/
File Upload :
Current File : E:/www/raff/wp-content/plugins/wpforms/pro/assets/js/wpforms-conditional-logic-fields.min.js

!function(k){"use strict";var x={init:function(){k(x.ready),x.bindUIActions()},ready:function(){k(".wpforms-form").each(function(){var e=k(this);x.initDefaultValues(e),x.processConditionals(e,!1)})},initDefaultValues:function(e){e.find(".wpforms-conditional-field input, .wpforms-conditional-field select, .wpforms-conditional-field textarea").each(function(){var e=k(this),t=e.val(),i=e.attr("type"),o=e.prop("tagName");switch(i=-1<["SELECT","BUTTON"].indexOf(o)?o.toLowerCase():i){case"button":case"submit":case"reset":case"hidden":break;case"checkbox":case"radio":e.is(":checked")&&e.attr("data-default-value","checked");break;default:""!==t&&e.attr("data-default-value",t)}})},bindUIActions:function(){k(document).on("change",".wpforms-conditional-trigger input, .wpforms-conditional-trigger select",function(){x.processConditionals(k(this),!0)}),k(document).on("input",".wpforms-conditional-trigger input[type=text], .wpforms-conditional-trigger input[type=email], .wpforms-conditional-trigger input[type=url], .wpforms-conditional-trigger input[type=number], .wpforms-conditional-trigger textarea",function(){x.processConditionals(k(this),!0)}),k(document).on("tinymce-editor-init",function(e,t){t.id.startsWith("wpforms-")&&t.on("keyup",function(){x.processConditionals(k("#"+t.id),!0)})}),k(".wpforms-form").submit(function(){x.resetHiddenFields(k(this))})},resetHiddenFields:function(e){window.location.hash&&"#wpformsdebug"===window.location.hash&&console.log("Resetting hidden fields...");var t,i,o,n,a=k(e);a.find(".wpforms-conditional-hide :input").each(function(){switch(t=k(this),i=t.attr("type"),o=t.prop("tagName"),i=-1<["SELECT","BUTTON"].indexOf(o)?o.toLowerCase():i){case"button":case"submit":case"reset":case"hidden":break;case"checkbox":case"radio":t.closest("ul").find("li").removeClass("wpforms-selected"),(n=t.closest("div.wpforms-field-rating-items")).length&&n.find("label").removeClass("selected"),t.is(":checked")&&t.prop("checked",!1).trigger("change");break;case"select":x.resetHiddenSelectField.init(t);break;default:""!==t.val()&&(t.hasClass("dropzone-input")&&k('[data-name="'+t[0].name+'"]',a)[0]&&k('[data-name="'+t[0].name+'"]',a)[0].dropzone.removeAllFiles(!0),t.val("").trigger("input"))}}),a.find(".wpforms-field-richtext.wpforms-conditional-hide").each(function(){var e=tinyMCE.get("wpforms-"+k(this).closest(".wpforms-form").data("formid")+"-field_"+k(this).data("field-id"));if(!e)return"";e.setContent("")})},resetHiddenSelectField:{$field:null,init:function(e){(this.$field=e).data("choicesjs")?this.modern():this.classic()},modern:function(){var e=this.$field.data("choicesjs"),t=e.getValue(!0);t&&t.length&&(e.removeActiveItems(),this.$field.trigger("change")),this.$field.prop("multiple")?k(e.input.element).removeClass(e.config.classNames.input+"--hidden"):(t=e.config.choices.filter(function(e){return e.placeholder}),Array.isArray(t)&&t.length&&e.setChoiceByValue(t[0].value))},classic:function(){var e=this.$field.find("option.placeholder").length?0:-1;e!==this.$field.prop("selectedIndex")&&this.$field.prop("selectedIndex",e).trigger("change")}},resetToDefaults:function(e){e.find(":input").each(function(){var e=k(this),t=e.attr("data-default-value"),i=e.attr("type"),o=e.prop("tagName");if(void 0!==t)switch(i=-1<["SELECT","BUTTON"].indexOf(o)?o.toLowerCase():i){case"button":case"submit":case"reset":case"hidden":break;case"checkbox":case"radio":"checked"===t&&(e.prop("checked",!0).closest("li").addClass("wpforms-selected"),e.trigger("change"));break;case"select":var n=e.data("choicesjs"),t=t.split(",");n?(t=t.filter(function(e){return""!==e}),n.getValue(!0)!==t&&(n.setChoiceByValue(t),e.trigger("change"))):e.val()!==t&&e.val(t).trigger("change");break;default:e.val()!==t&&e.val(t).trigger("input")}})},processConditionals:function(e,t){var i=k(e),o=i.closest(".wpforms-form"),n=o.data("formid"),a=!1;if("undefined"==typeof wpforms_conditional_logic||void 0===wpforms_conditional_logic[n])return!1;var r,s=wpforms_conditional_logic[n];for(r in s)if(s.hasOwnProperty(r)){window.location.hash&&"#wpformsdebug"===window.location.hash&&console.log("Processing conditionals for Field #"+r+"...");var l,c,d=s[r].logic,f=s[r].action,p=!1;for(l in d)if(d.hasOwnProperty(l)){var u,h=d[l],m=!0;for(u in h)if(h.hasOwnProperty(u)){var g,w=h[u],v="",y=!1,b="";if(window.location.hash&&"#wpformsdebug"===window.location.hash&&console.log(w),w.field){switch(null===(v=x.getElementValueByRule(w,o))&&(v=""),b=k.trim(v).toString().toLowerCase(),g=k.trim(w.value).toString().toLowerCase(),w.operator){case"==":y=b===g;break;case"!=":y=b!==g;break;case"c":y=-1<b.indexOf(g)&&0<b.length;break;case"!c":y=-1===b.indexOf(g)&&0<g.length;break;case"^":y=0===b.lastIndexOf(g,0);break;case"~":y=-1!==b.indexOf(g,b.length-g.length);break;case"e":y=0===b.length;break;case"!e":y=0<b.length;break;case">":y=""!==(b=b.replace(/[^-0-9.]/g,""))&&x.floatval(b)>x.floatval(g);break;case"<":y=""!==(b=b.replace(/[^-0-9.]/g,""))&&x.floatval(b)<x.floatval(g)}if(!y){m=!1;break}}}m&&(p=!0)}window.location.hash&&"#wpformsdebug"===window.location.hash&&console.log("Result: "+p),p&&"hide"===f||!p&&"hide"!==f?(o.find("#wpforms-"+n+"-field_"+r+"-container").hide().addClass("wpforms-conditional-hide").removeClass("wpforms-conditional-show"),a=!0):(c=o.find("#wpforms-"+n+"-field_"+r+"-container"),i.closest(".wpforms-field").attr("id")!==c.attr("id")&&c.hasClass("wpforms-conditional-hide")&&x.resetToDefaults(c),c.show().removeClass("wpforms-conditional-hide").addClass("wpforms-conditional-show"),i.trigger("wpformsShowConditionalsField")),k(document).trigger("wpformsProcessConditionalsField",[n,r,p,f])}a&&(x.resetHiddenFields(o),t&&(window.location.hash&&"#wpformsdebug"===window.location.hash&&console.log("Final Processing"),x.processConditionals(i,!1))),k(document).trigger("wpformsProcessConditionals",[i,o,n])},getElementValueByRule:function(e,t){return t.find("#wpforms-"+t.data("formid")+"-field_"+e.field).data("choicesjs")&&(e.value=k.trim(e.value)),"e"===e.operator||"!e"===e.operator?x.getElementValueByEmptyTypeRules(e,t):x.getElementValueByOtherTypeRules(e,t)},getElementValueByEmptyTypeRules:function(e,t){var i,o=t.data("formid"),n="";if(e.value="",-1<["radio","checkbox","select","payment-multiple","payment-checkbox","rating","net_promoter_score"].indexOf(e.type))i="select"===e.type?"option:selected:not(.placeholder)":"input:checked",t.find("#wpforms-"+o+"-field_"+e.field+"-container "+i).length&&(n=!0);else{if("richtext"===e.type)return x.getRichTextValue(t,o,e.field);n=(n=t.find("#wpforms-"+o+"-field_"+e.field).val())||""}return n},getElementValueByOtherTypeRules:function(e,t){var i=t.data("formid"),o="";if(-1<["radio","checkbox","select","payment-multiple","payment-checkbox","rating","net_promoter_score"].indexOf(e.type)){var n,a="select"===e.type?"option:selected:not(.placeholder)":"input:checked";(a=t.find("#wpforms-"+i+"-field_"+e.field+"-container "+a)).length&&k.each(a,function(){n=x.escapeText(k(this).val()),-1<["checkbox","payment-checkbox","select"].indexOf(e.type)&&e.value!==n||(o=n)})}else{if("richtext"===e.type)return x.getRichTextValue(t,i,e.field);o=t.find("#wpforms-"+i+"-field_"+e.field).val(),-1<["payment-select"].indexOf(e.type)&&(o=x.escapeText(o))}return o},getRichTextValue:function(e,t,i){if(e.find("#wpforms-"+t+"-field_"+i+"-container .wp-editor-wrap").hasClass("html-active"))return e.find("#wpforms-"+t+"-field_"+i).val();e=tinyMCE.get("wpforms-"+t+"-field_"+i);return e?e.getContent({format:"text"}):""},escapeText:function(e){if(null==e||!e.length)return null;var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};return e.replace(/[&<>"']/g,function(e){return t[e]})},floatval:function(e){return parseFloat(e)||0}};x.init(),window.wpformsconditionals=x}(jQuery);

Copyright © 2019 by b0y-101