File "admin-utils.min.js"

Full Path: /home/ycoalition/public_html/blog/wp-admin/js/widgets/plugins/wpforms-lite/assets/js/admin-utils.min.js
File size: 11.4 KB
MIME-type: text/plain
Charset: utf-8

var wpf={cachedFields:{},savedState:!1,initialSave:!0,orders:{fields:[],choices:{}},init:function(){wpf.bindUIActions(),wpf.initRadioGroupForCheckboxes(),jQuery(wpf.ready)},ready:function(){wpf.savedState=wpf.getFormState("#wpforms-builder-form"),wpf.setFieldOrders(),wpf.setChoicesOrders()},bindUIActions:function(){jQuery(document).on("wpformsFieldAdd",wpf.setFieldOrders),jQuery(document).on("wpformsFieldDelete",wpf.setFieldOrders),jQuery(document).on("wpformsFieldMove",wpf.setFieldOrders),jQuery(document).on("wpformsFieldAdd",wpf.setChoicesOrders),jQuery(document).on("wpformsFieldChoiceAdd",wpf.setChoicesOrders),jQuery(document).on("wpformsFieldChoiceDelete",wpf.setChoicesOrders),jQuery(document).on("wpformsFieldChoiceMove",wpf.setChoicesOrders),jQuery(document).on("wpformsFieldAdd",wpf.fieldUpdate),jQuery(document).on("wpformsFieldDelete",wpf.fieldUpdate),jQuery(document).on("wpformsFieldMove",wpf.fieldUpdate),jQuery(document).on("focusout",".wpforms-field-option-row-label input",wpf.fieldUpdate),jQuery(document).on("wpformsFieldChoiceAdd",wpf.fieldUpdate),jQuery(document).on("wpformsFieldChoiceDelete",wpf.fieldUpdate),jQuery(document).on("wpformsFieldChoiceMove",wpf.fieldUpdate),jQuery(document).on("wpformsFieldDynamicChoiceToggle",wpf.fieldUpdate),jQuery(document).on("focusout",".wpforms-field-option-row-choices input.label",wpf.fieldUpdate)},setFieldOrders:function(){wpf.orders.fields=[],jQuery(".wpforms-field-option").each(function(){wpf.orders.fields.push(jQuery(this).data("field-id"))})},setChoicesOrders:function(){wpf.orders.choices={},jQuery(".choices-list").each(function(){var e=jQuery(this).data("field-id");wpf.orders.choices["field_"+e]=[],jQuery(this).find("li").each(function(){wpf.orders.choices["field_"+e].push(jQuery(this).data("key"))})})},getChoicesOrder:function(e){var r=[];return jQuery("#wpforms-field-option-"+e).find(".choices-list li").each(function(){r.push(jQuery(this).data("key"))}),r},initMultipleSelectWithSearch:function(e){const r=jQuery(e.passedElement.element),t=jQuery(e.input.element);r.prop("multiple")&&(t.data("placeholder",t.attr("placeholder")),e.getValue(!0).length&&t.removeAttr("placeholder"),r.on("change",function(){e.getValue(!0).length?t.removeAttr("placeholder"):t.attr("placeholder",t.data("placeholder"))}))},fieldUpdate:function(){var e=wpf.getFields();jQuery(document).trigger("wpformsFieldUpdate",[e]),wpf.debug("fieldUpdate triggered")},getFields:function(e,r){if((r=r||!1)&&!jQuery.isEmptyObject(wpf.cachedFields)){var t=jQuery.extend({},wpf.cachedFields);wpf.debug("getFields triggered (cached)")}else{var i=["captcha","content","divider","entry-preview","html","internal-information","layout","pagebreak"];if(!(t=wpf.formObject("#wpforms-field-options").fields))return!1;for(n in t)(!t[n].type||-1<jQuery.inArray(t[n].type,i))&&delete t[n];wpf.cachedFields=jQuery.extend({},t),wpf.debug("getFields triggered")}if(e&&e.constructor===Array)for(var n in t)-1===jQuery.inArray(t[n].type,e)&&delete t[n];return t},getField:function(e){e=wpf.formObject("#wpforms-field-option-"+e);return e.fields[Object.keys(e.fields)[0]]},fieldOptionLoading:function(e,r){var e=jQuery(e),t=e.find("label");(r=void 0!==r)?(t.find(".wpforms-loading-spinner").remove(),t.find(".wpforms-help-tooltip").show(),e.find("input,select,textarea").prop("disabled",!1)):(t.append('<i class="wpforms-loading-spinner wpforms-loading-inline"></i>'),t.find(".wpforms-help-tooltip").hide(),e.find("input,select,textarea").prop("disabled",!0))},getFormState:function(e){return jQuery(e).serialize()},removeArrayItem:function(e,r){for(var t=0,i=0;i<e.length;i++)e[i]===r&&(e.splice(i,1),t++,i--);return t},sanitizeString:function(e){return"string"==typeof e||e instanceof String?e.trim():e},updateQueryString:function(e,r,t){t=t||window.location.href;var i,n=new RegExp("([?&])"+e+"=.*?(&|#|$)(.*)","gi");return n.test(t)?null!=r?t.replace(n,"$1"+e+"="+r+"$2$3"):(t=(i=t.split("#"))[0].replace(n,"$1$3").replace(/(&|\?)$/,""),void 0!==i[1]&&null!==i[1]&&(t+="#"+i[1]),t):(null!=r&&(n=-1!==t.indexOf("?")?"&":"?",t=(i=t.split("#"))[0]+n+e+"="+r,void 0!==i[1])&&null!==i[1]&&(t+="#"+i[1]),t)},getQueryString:function(e){e=new RegExp("[?&]"+e+"=([^&]*)").exec(window.location.search);return e&&decodeURIComponent(e[1].replace(/\+/g," "))},removeQueryParam:function(e){wpf.getQueryString(e)&&(e=new RegExp("[\\?&]"+e+"=[^&]+"),history.replaceState)&&history.replaceState(null,"",location.pathname+location.search.replace(e,"").replace(/^&/,"?")+location.hash)},isNumber:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},amountSanitize:function(e){return e=String(e).replace(/[^0-9.,]/g,""),","===wpforms_builder.currency_decimal?("."===wpforms_builder.currency_thousands&&-1!==e.indexOf(wpforms_builder.currency_thousands)?e=e.replace(new RegExp("\\"+wpforms_builder.currency_thousands,"g"),""):""===wpforms_builder.currency_thousands&&-1!==e.indexOf(".")&&(e=e.replace(/\./g,"")),e=e.replace(wpforms_builder.currency_decimal,".")):","===wpforms_builder.currency_thousands&&-1!==e.indexOf(wpforms_builder.currency_thousands)&&(e=e.replace(new RegExp("\\"+wpforms_builder.currency_thousands,"g"),"")),wpf.numberFormat(e,wpforms_builder.currency_decimals,".","")},amountFormat:function(e){var r;return e=String(e),","===wpforms_builder.currency_decimal&&-1!==e.indexOf(wpforms_builder.currency_decimal)&&(r=e.indexOf(wpforms_builder.currency_decimal),e=e.substr(0,r)+"."+e.substr(r+1,e.length-1)),","===wpforms_builder.currency_thousands&&-1!==e.indexOf(wpforms_builder.currency_thousands)&&(e=e.replace(/,/g,"")),wpf.empty(e)&&(e=0),wpf.numberFormat(e,wpforms_builder.currency_decimals,wpforms_builder.currency_decimal,wpforms_builder.currency_thousands)},amountFormatCurrency:function(e){e=wpf.amountSanitize(e),e=wpf.amountFormat(e),e="right"===wpforms_builder.currency_symbol_pos?e+" "+wpforms_builder.currency_symbol:wpforms_builder.currency_symbol+" "+e;return e},numberFormat:function(e,r,t,i){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var n,o,p,e=isFinite(+e)?+e:0,r=isFinite(+r)?Math.abs(r):0,i=void 0===i?",":i,t=void 0===t?".":t,s="";return 3<(s=(r?(n=e,o=r,p=Math.pow(10,o),""+(Math.round(n*p)/p).toFixed(o)):""+Math.round(e)).split("."))[0].length&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(s[1]||"").length<r&&(s[1]=s[1]||"",s[1]+=new Array(r-s[1].length+1).join("0")),s.join(t)},empty:function(e){for(var r,t=[void 0,null,!1,0,"","0"],i=0,n=t.length;i<n;i++)if(e===t[i])return!0;if("object"!=typeof e)return!1;for(r in e)if(e.hasOwnProperty(r))return!1;return!0},debug:function(...e){wpf.isDebug()&&console.log("%cWPForms Debug: ","color: #cd6622;",...e)},isDebug:function(){return window.location.hash&&"#wpformsdebug"===window.location.hash||wpforms_builder.debug},focusCaretToEnd:function(e){e.trigger("focus");var r=e.val();e.val("").val(r)},formObject:function(e){for(var r=jQuery(e).find("[name]"),t={},i={},n=0;n<r.length;n++){var o=jQuery(r[n]),p=o.prop("name").replace(/\]/gi,"").split("["),s=o.val(),c={};if(!o.is(":radio")&&!o.is(":checkbox")||o.is(":checked")){for(var d=p.length-1;0<=d;d--){var l=p[d];if(0===(l=void 0===l?"":l).length&&(c=[],void 0===i[p[d-1]]?i[p[d-1]]=0:i[p[d-1]]+=1,l=i[p[d-1]]),d===p.length-1){if(s)if("true"===s)s=!0;else if("false"===s)s=!1;else if(isNaN(parseFloat(s))||parseFloat(s).toString()!==s)if("string"!=typeof s||"{"!==s.substr(0,1)&&"["!==s.substr(0,1)){if("object"==typeof s&&s.length&&o.is("select")){for(var a={},d=0;d<s.length;d++)a["n"+d]=s[d];s=a}}else try{s=JSON.parse(s)}catch(e){}else s=parseFloat(s);c[l]=s}else{var u=c;(c={})[l]=u}}jQuery.extend(!0,t,c)}}return t},initTooltips:function(){void 0!==jQuery.fn.tooltipster&&jQuery(".wpforms-help-tooltip").tooltipster({contentAsHTML:!0,position:"right",maxWidth:300,multiple:!0,interactive:!0,debug:!1,IEmin:11})},restoreTooltips:function(e){(e=void 0!==e&&e&&0<e.length?e.find(".wpforms-help-tooltip"):jQuery(".wpforms-help-tooltip")).each(function(){var e=jQuery(this);0!==jQuery.tooltipster.instances(this).length&&e.attr("title",e.tooltipster("content"))})},isURL:function(e){return"string"==typeof e&&!!(e=e.match(/^(?:http(?:s?):)?\/\/(\S+)/))&&!(!(e=e[1])||!/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/.test(e)&&!/^[^\s\.]+\.\S{2,}$/.test(e))},sanitizeHTML:function(e,r){var t=window.DOMPurify;if(void 0===t||void 0===e)return e;"string"!=typeof e&&(e=e.toString());var i={ADD_ATTR:["target"]};return void 0!==r&&(i.ALLOWED_TAGS=r),t.sanitize(e,i).trim()},encodeHTMLEntities:function(e){return(e="string"!=typeof e?e.toString():e).replace(/[\u00A0-\u9999<>&]/gim,function(e){return"&#"+e.charCodeAt(0)+";"})},initRadioGroupForCheckboxes:function(){var i=jQuery;i(document).on("change",'input[type="checkbox"].wpforms-radio-group',function(){var e,r=i(this),t=r.attr("id");r.prop("checked")&&(r=r.data("radio-group"),i(".wpforms-radio-group-"+r).each(function(){(e=i(this)).attr("id")!==t&&e.prop("checked",!1)}))})},listPluck:function(e,r){return e.map(function(e){return void 0!==e?e[r]:e})},triggerEvent:function(e,r){return console.warn('WARNING! Function "wpf.triggerEvent( $element, eventName )" has been deprecated, please use the new "WPFormsUtils.triggerEvent( $element, eventName, args )" function instead!'),WPFormsUtils.triggerEvent(e,r)},wpautop:function(i,e=!0){let n=new Map;if("string"==typeof i||i instanceof String){if(""===i.trim())return"";-1<(i+="\n").indexOf("<pre")&&(t=(r=i.split("</pre>")).pop(),i="",r.forEach(function(e,r){var t=e.indexOf("<pre");-1===t?i+=e:(r="<pre wp-pre-tag-"+r+"></pre>",n[r]=e.substring(t)+"</pre>",i+=e.substring(0,t)+r)}),i+=t);var r="(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)",t=(i=(i=-1<(i=-1<(i=-1<(i=0===(i=(i=(i=(i=i.replace(/<br \/>\s*<br \/>/,"\n\n")).replace(new RegExp("(<"+r+"[^>]*>)","gmi"),"\n$1")).replace(new RegExp("(</"+r+">)","gmi"),"$1\n\n")).replace(/\r\n|\r/,"\n")).indexOf("\n")?i.substring(1):i).indexOf("<option")?(i=i.replace(/(?=(\s*))\2<option'/gim,"<option")).replace(/<\/option>\s*/gim,"</option>"):i).indexOf("</object>")?(i=(i=i.replace(/(<object[^>]*>)\s*/gim,"$1")).replace(/(?=(\s*))\2<\/object>/gim,"</object>")).replace(/(?=(\s*))\2(<\/?(?:param|embed)[^>]*>)((?=(\s*))\2)/gim,"$1"):i).indexOf("<source")||-1<i.indexOf("<track")?(i=(i=i.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/gim,"$1")).replace(/(?=(\s*))\2([<\[]\/(?:audio|video)[>\]])/gim,"$1")).replace(/(?=(\s*))\2(<(?:source|track)[^>]*>)(?=(\s*))\2/gim,"$1"):i).replace(/\n\n+/gim,"\n\n")).split(/\n\s*\n/);i="",t.forEach(function(e){i+="<p>"+e.replace(/^(?:\s+|\s+)$/g,"")+"</p>\n"}),i=(i=(i=(i=(i=(i=(i=(i=i.replace(/<p>\s*<\/p>/gim,"")).replace(/<p>([^<]+)<\/(div|address|form)>/gim,"<p>$1</p></$2>")).replace(new RegExp("<p>s*(</?"+r+"[^>]*>)s*</p>","gmi"),"$1",i)).replace(/<p>(<li.+?)<\/p>/gim,"$1")).replace(/<p><blockquote([^>]*)>/gim,"<blockquote$1><p>")).replace(/<\/blockquote><\/p>/gim,"</p></blockquote>")).replace(new RegExp("<p>s*(</?"+r+"[^>]*>)","gmi"),"$1")).replace(new RegExp("(</?"+r+"[^>]*>)s*</p>","gmi"),"$1"),i=(i=(i=(i=e?(i=(i=i.replace(/<(script|style)(?:.|\n)*?<\/\\1>/gim,function(e){return e[0].replace("\n","<WPPreserveNewline />")})).replace(/(<br \/>)?((?=(\s*))\2)\n/gim,"<br />\n")).replace("<WPPreserveNewline />","\n"):i).replace(new RegExp("(</?"+r+"[^>]*>)s*<br />","gmi"),"$1")).replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/gim,"$1")).replace(/\n<\/p>$/gim,"</p>"),Object.keys(n).length&&(i=i.replace(new RegExp(Object.keys(n).join("|"),"gi"),function(e){return n[e]}))}return i}};wpf.init();