File Editor
Directories:
.. (Back)
Files:
admin-utils.js
admin-utils.min.js
contrast-checker.js
contrast-checker.min.js
list-table-ext.js
list-table-ext.min.js
xor.js
xor.min.js
Create New File
Create
Edit File: admin-utils.min.js
const wpf={cachedFields:{},savedState:!1,initialSave:!0,orders:{fields:[],choices:{}},init(){wpf.bindUIActions(),wpf.initRadioGroupForCheckboxes(),jQuery(wpf.ready)},ready(){wpf.savedState=wpf.getFormState("#wpforms-builder-form"),wpf.setFieldOrders(),wpf.setChoicesOrders()},bindUIActions(){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(){wpf.orders.fields=[],jQuery(".wpforms-field-option").each(function(){wpf.orders.fields.push(jQuery(this).data("field-id"))})},setChoicesOrders(){wpf.orders.choices={},jQuery(".choices-list").each(function(){const 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(e){const r=[];return jQuery("#wpforms-field-option-"+e).find(".choices-list li").each(function(){r.push(jQuery(this).data("key"))}),r},initMultipleSelectWithSearch(e){const r=jQuery(e.passedElement.element),t=jQuery(e.input.element);r.prop("multiple")&&(t.data("placeholder",t.attr("placeholder")),t.data("style",t.attr("style")),e.getValue(!0).length&&t.removeAttr("placeholder"),r.on("change",function(){e.getValue(!0).length?t.removeAttr("placeholder"):t.attr("placeholder",t.data("placeholder")).attr("style",t.data("style"))}))},showMoreButtonForChoices(e){var r,t;"select-one"!==jQuery(e).data("type")&&(r=jQuery(e).find(".choices__list--multiple .choices__item").first(),t=jQuery(e).find(".choices__list--multiple .choices__item").last(),jQuery(e).removeClass("choices__show-more"),0<r.length)&&0<t.length&&r.position().top!==t.position().top&&jQuery(e).addClass("choices__show-more")},initializeChoicesEventHandlers(){jQuery(document).on("addItem removeItem",".choices:not(.is-disabled)",function(){wpf.showMoreButtonForChoices(this)}),jQuery(document).on("hideDropdown",".choices:not(.is-disabled)",function(){jQuery(this).find(".choices__inner input.choices__input").trigger("blur")})},reInitShowMoreChoices(e){setTimeout(()=>{e.find(".choices select").each(function(){var e=jQuery(this).data("choicesjs");wpf.showMoreButtonForChoices(e.containerOuter.element)})},100)},fieldUpdate(){var e=wpf.getFields();jQuery(document).trigger("wpformsFieldUpdate",[e]),wpf.debug("fieldUpdate triggered")},getFields(e=void 0,r=void 0,t=void 0,i=void 0){let o;if((r=r||!1)&&!jQuery.isEmptyObject(wpf.cachedFields))o=jQuery.extend({},wpf.cachedFields),wpf.debug("getFields triggered (cached)");else{var r=wpf.formObject("#wpforms-field-options"),n=["captcha","content","divider","entry-preview","html","internal-information","pagebreak","layout"];if(!(o=r.fields))return!1;for(const d in o)(!o[d].type||-1<jQuery.inArray(o[d].type,n))&&delete o[d],"repeater"===o[d]?.type&&(Object.values(o[d]["columns-json"]??{}).forEach(e=>{Object.values(e?.fields??[]).forEach(e=>{o[e]&&(o[e].label+=" ("+o[d].label+")",o[e].isRepeater=!0)})}),delete o[d]);wpf.addAdditionalFields(o),wpf.cachedFields=jQuery.extend({},o),wpf.debug("getFields triggered")}if(!t)for(const a in o)o[a]?.isRepeater&&delete o[a];if(i)for(const p in i)delete o[p];if(e&&e.constructor===Array)for(const c in o)-1===jQuery.inArray(o[c].type,e)&&delete o[c];if(0===Object.keys(o).length)return!1;var s=[];for(const u in wpf.orders.fields){var l=wpf.orders.fields[u];o[l]&&s.push(o[l])}return Object.assign({},s)},addAdditionalFields(e){for(const t in e){var r;if(["name","date-time"].includes(e[t]?.type)&&(r=e[t].format,e[t].additional=r.split("-")),"address"===e[t]?.type){const i=Object.keys(e[t]).filter(e=>e.includes("_placeholder"));i.forEach((e,r)=>{i[r]=e.replace("_placeholder","")}),e[t].additional=i}}return e},getField(e){e=wpf.formObject("#wpforms-field-option-"+e);return Object.keys(e).length?e.fields[Object.keys(e.fields)[0]]:{}},fieldOptionLoading(e,r=void 0){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(e){return jQuery(e).serialize()},removeArrayItem(r,t){let i=0;for(let e=0;e<r.length;e++)r[e]===t&&(r.splice(e,1),i++,e--);return i},sanitizeString(e){return"string"==typeof e||e instanceof String?e.trim():e},updateQueryString(e,r,t=null){t=t||window.location.href;t=new URL(t);return null!=r?t.searchParams.set(e,r):t.searchParams.delete(e),t.toString()},getQueryString(e){e=new RegExp("[?&]"+e+"=([^&]*)").exec(window.location.search);return e&&decodeURIComponent(e[1].replace(/\+/g," "))},removeQueryParam(e){wpf.getQueryString(e)&&(e=new RegExp("[\\?&]"+e+"=[^&]+"),history.replaceState)&&history.replaceState(null,"",location.pathname+location.search.replace(e,"").replace(/^&/,"?")+location.hash)},isNumber(e){return!isNaN(parseFloat(e))&&isFinite(e)},amountSanitize(e){return e=String(e).replace(wpforms_builder.currency_symbol,"").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(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(e){e=wpf.amountSanitize(e),e=wpf.amountFormat(e);let r;return r="right"===wpforms_builder.currency_symbol_pos?e+" "+wpforms_builder.currency_symbol:wpforms_builder.currency_symbol+e},numberFormat(e,r,t,i){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var o,n,s,e=isFinite(+e)?+e:0,r=isFinite(+r)?Math.abs(r):0,i=void 0===i?",":i,t=void 0===t?".":t,l="";return 3<(l=(r?(o=e,n=r,s=Math.pow(10,n),""+(Math.round(o*s)/s).toFixed(n)):""+Math.round(e)).split("."))[0].length&&(l[0]=l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,i)),(l[1]||"").length<r&&(l[1]=l[1]||"",l[1]+=new Array(r-l[1].length+1).join("0")),l.join(t)},empty(e){var r;let t,i;var o=[void 0,null,!1,0,"","0"];for(i=0,r=o.length;i<r;i++)if(e===o[i])return!0;if("object"!=typeof e)return!1;for(t in e)if(e.hasOwnProperty(t))return!1;return!0},debug(...e){wpf.isDebug()&&console.log("%cWPForms Debug: ","color: #cd6622;",...e)},isDebug(){return window.location.hash&&"#wpformsdebug"===window.location.hash||window.wpforms_builder?.debug},focusCaretToEnd(e){e.trigger("focus");var r=e.val();e.val("").val(r)},formObject(e){var r=jQuery(e).find("[name]"),o={},n={};for(let e=0;e<r.length;e++){var s=jQuery(r[e]),l=s.prop("name").replace(/\]/gi,"").split("[");let t=s.val(),i={};if(!s.is(":radio")&&!s.is(":checkbox")||s.is(":checked")){for(let r=l.length-1;0<=r;r--){let e=l[r];if(0===(e=void 0===e?"":e).length&&(i=[],void 0===n[l[r-1]]?n[l[r-1]]=0:n[l[r-1]]+=1,e=n[l[r-1]]),r===l.length-1){if(t)if("true"===t)t=!0;else if("false"===t)t=!1;else if(isNaN(parseFloat(t))||parseFloat(t).toString()!==t)if("string"!=typeof t||"{"!==t.substr(0,1)&&"["!==t.substr(0,1)){if("object"==typeof t&&t.length&&s.is("select")){var d={};for(let e=0;e<t.length;e++)d["n"+e]=t[e];t=d}}else try{t=JSON.parse(t)}catch(e){}else t=parseFloat(t);i[e]=t}else{var a=i;(i={})[e]=a}}jQuery.extend(!0,o,i)}}return o},initTooltips(e=null){if(void 0!==jQuery.fn.tooltipster){const r=jQuery("body").hasClass("rtl")?"left":"right";(e?jQuery(e).find(".wpforms-help-tooltip"):jQuery(".wpforms-help-tooltip")).each(function(){var e=jQuery(this);e.tooltipster({contentAsHTML:!0,position:e.data("tooltip-position")||r,maxWidth:300,multiple:!0,interactive:!0,debug:!1,IEmin:11,zIndex:99999999})})}},restoreTooltips(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(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(e=void 0,r=void 0){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(e){return(e="string"!=typeof e?e.toString():e).replace(/[\u00A0-\u9999<>&]/gim,function(e){return"&#"+e.charCodeAt(0)+";"})},decodeAllowedHTMLEntities(e){"string"!=typeof e&&(e=e.toString());var r=wp.hooks.applyFilters("wpforms.allowedHTMLEntities",{"&":"&"," ":" "});for(const t in r)e=e.replaceAll(t,r[t]);return e},initRadioGroupForCheckboxes(){const n=jQuery;n(document).on("change",'input[type="checkbox"].wpforms-radio-group',function(){var r=n(this);if(r.prop("checked")){const t=r.data("radio-group"),i=n(".wpforms-radio-group-"+t),o=r.attr("id");let e;i.each(function(){(e=n(this)).attr("id")!==o&&e.prop("checked",!1)})}})},listPluck(e,r){return e.map(function(e){return void 0!==e?e[r]:e})},triggerEvent(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(i,e=!0){const o=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>",o[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(o).length&&(i=i.replace(new RegExp(Object.keys(o).join("|"),"gi"),function(e){return o[e]}))}return i},initMediaLibrary(r){const t=wp.media.frames.wpforms_media_frame=wp.media({className:"media-frame wpforms-media-frame",multiple:!1,title:r.title,library:{type:r.extensions},button:{text:r.buttonText}});return t.on("uploader:ready",function(){var e=r.extensions.join(",");jQuery('.wpforms-media-frame .moxie-shim-html5 input[type="file"]').attr("accept",e)}).on("library:selection:add",function(){var e=t.state().get("selection").first().toJSON();r.extensions.includes(e.file.type)||(alert(r.extensionsError),t.state().get("selection").reset())}),t},isInViewport(e){e=e[0].getBoundingClientRect();return 0<=e.top&&0<=e.left&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}};wpf.init();
Save Changes
Rename File
Rename