From 18ba2ab35ff81e627038a4060955389b6759cdbb Mon Sep 17 00:00:00 2001
From: Sherv '+e.message+"{var n;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function o(e){return function(e,t){var r,n,a,l,s,d,c,u,f,m=1,_=e.length,p="";for(n=0;n<_;n++)if("string"==typeof e[n])p+=e[n];else if("object"==typeof e[n]){if((l=e[n]).keys)for(r=t[m],a=0;a").addClass("frm_grid_container frm_sorting").append(e)))}),r}function We(e){var t=s("ul",{className:"frm_grid_container frm_sorting"}),r=s("li",{className:"frm_field_box",child:t});e.replaceWith(r),t.append(e),$(t),X(r,".frm-move")}function Ue(e,t){var r,n,i=/id="(\S+)"/.exec(e),o=document.getElementById(i[1]),l="#"+i[1]+".edit_field_type_divider ul.frm_sorting.start_divider",s=jQuery(l),c=o.getAttribute("data-type");r=e,(n=d()).innerHTML=r,n.querySelectorAll(".form-field").forEach(Ve);var u,f,m=!1;if(Pi(),V(l),"quantity"===c&&function(e){var t=e.getAttribute("data-fid"),r=document.getElementById("field_options[product_field_"+t+"]");null!==r&&(rt(r),oi(document.getElementById("frm-single-settings-"+t)))}(o),"product"!==c&&"quantity"!==c||Ie(),s.length)s.parent(".frm_field_box").children(".frm_no_section_fields").addClass("frm_block");else{var _=jQuery(o).closest("ul.frm_sorting.start_divider");_.length&&(Sn(_),m=!0)}e.includes("frm-collapse-page")&&Fr(),f="frm-newly-added",(u=o).classList?u.classList.add(f):u.className+=" "+f,setTimeout(function(){o.classList.remove("frm-newly-added")},1e3);var p,g=o.querySelector("#frm-last-row-fields-order");if(g&&((p=JSON.parse(g.value))&&"object"===a(p)&&Object.keys(p).forEach(function(e){var t=document.querySelector('input[name="field_options[field_order_'+e+']"]');t&&(t.value=p[e])})),t){var y=o.getBoundingClientRect(),h=document.getElementById("post-body-content");y.top>=0&&y.left>=0&&y.right<=(window.innerWidth||document.documentElement.clientWidth)&&y.bottom<=(window.innerHeight||document.documentElement.clientHeight)||h.scroll({top:h.scrollHeight,left:0,behavior:"smooth"}),!1===m&&Sn(s)}Ke(),co(),document.getElementById("frm-show-fields").classList.remove("frm-over-droppable"),function(e){var t=document.getElementById(e);t&&t.dataset.limit&&kr(e)>=t.dataset.limit&&t.classList.add("frm_at_limit")}(c),o.querySelectorAll("[data-toggle]").forEach(function(e){return e.setAttribute("data-bs-toggle",e.getAttribute("data-toggle"))}),o.querySelectorAll(".frm-dropdown-menu").forEach(function(e){return e.classList.add("dropdown-menu")});var v=new Event("frm_added_field",{bubbles:!1});v.frmField=o,v.frmSection=l,v.frmType=c,v.frmToggles=m,document.dispatchEvent(v)}function Ve(e){if(e.dataset.fid){var t=document.getElementById("draft_fields");t&&(""===t.value?t.value=e.dataset.fid:t.value.split(",").includes(e.dataset.fid)||(t.value+=","+e.dataset.fid))}}function $e(e){jQuery("#new_fields .frm-single-settings").addClass("frm_hidden"),jQuery("#frm-options-panel > .frm-single-settings").removeClass("frm_hidden"),Ke(e)}function Ke(e){jQuery("li.ui-state-default.selected").removeClass("selected"),jQuery(".frm-show-field-settings.selected").removeClass("selected"),e||yr()}function Je(){var e=this.value,t=function(e){var t,r=[],n=e.split(""),i=n.length,a=["{","[","("],l={"}":"{",")":"(","]":"["},s=[];for(t=0;t0||s.length>0?o.unmatched_parens+"\n\n":""}(e);t+=function(e,t){var r=function(e,t){var r="";return function(e){return jQuery(e).siblings('label[for^="calc_type"]').children("input").prop("checked")}(t)||/\[(date|time|email|ip)\]/.test(e)&&(r=o.text_shortcodes+"\n\n"),r}(e,t);return r+=function(e){var t="";return/\[id\]|\[key\]|\[if\s\w+\]|\[foreach\s\w+\]|\[created-at(\s*)?/g.test(e)&&(t+=o.view_shortcodes+"\n\n"),t}(e)}(e,this),""!==t&&M(e+"\n\n"+t)}function Xe(e,t){for(var r=!1,n=0;n
6?(t.append(Gt(e,"even")),t):(5!==e&&t.append(Gt(e,"even")),e%2==1&&t.append(Gt(e,"middle")),e<6?(t.append(Gt(e,"left")),t.append(Gt(e,"right"))):((r=d()).classList.add("frm_fourth"),t.prepend(r)),t)}(e),null!==(o=t.closest("ul.frm_sorting"))&&function(e,t){var r,n,i;for(r=t.children.length,n=0;n
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),eo(e)))})}function to(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function ro(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function no(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function io(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function oo(e){var t,r,n=e.target.value;lo(n),ao.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function ao(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function lo(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),xo.call(document.querySelector(".frm-auto-search")))}}function so(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function co(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function uo(e){e.preventDefault(),_o(this,"frm_multiple_addons")}function fo(e){e.preventDefault(),_o(this,"frm_activate_addon")}function mo(e){e.preventDefault(),_o(this,"frm_install_addon")}function _o(e,t){r(1105).toggleAddonState(e,t)}function po(){yo()}function go(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function yo(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function ho(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function vo(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),jo(t,r,this)}function bo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),jo(this,t,r)}function jo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;r'+e.message+"
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),Zi(e)))})}function eo(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function to(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function ro(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function no(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function io(e){var t,r,n=e.target.value;ao(n),oo.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function oo(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function ao(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),Qo.call(document.querySelector(".frm-auto-search")))}}function lo(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function so(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function co(e){e.preventDefault(),mo(this,"frm_multiple_addons")}function uo(e){e.preventDefault(),mo(this,"frm_activate_addon")}function fo(e){e.preventDefault(),mo(this,"frm_install_addon")}function mo(e,t){r(1105).toggleAddonState(e,t)}function _o(){go()}function po(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function go(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function yo(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function ho(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),bo(t,r,this)}function vo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),bo(this,t,r)}function bo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;rThe sum of ' + a + ' and ' + b + ' plus ' + c + + ' is ' + ( a + b + c ) + '
'; -// INCORRECT - Impure function with side effects -let total = 0; -const calculateTotal = ( items ) => { - items.forEach( ( item ) => { - total += item.price; // Mutates external state - } ); -}; +// Good +const html = 'The sum of ' + a + ' and ' + b + ' plus ' + c + + ' is ' + ( a + b + c ) + '
'; ``` -### Default Parameters - -Use default parameters instead of conditional logic. +Lines should be broken into logical groups if it improves readability: ```javascript -// CORRECT -function createUser( name, role = 'subscriber' ) { - return { name, role }; -} +// Acceptable +const baz = ( true === conditionalStatement() ) ? 'thing 1' : 'thing 2'; -// INCORRECT -function createUser( name, role ) { - role = role || 'subscriber'; - return { name, role }; -} +// Better +const baz = firstCondition( foo ) && secondCondition( bar ) ? + qux( foo, bar ) : + foo; ``` -### Rest Parameters - -Use rest parameters instead of `arguments` object. +When a conditional is too long to fit on one line, each operand of a logical operator in the boolean expression must appear on its own line: ```javascript -// CORRECT -function sum( ...numbers ) { - return numbers.reduce( ( total, n ) => total + n, 0 ); -} - -// INCORRECT -function sum() { - return Array.prototype.slice.call( arguments ).reduce( ( t, n ) => t + n, 0 ); +if ( + firstCondition() && + secondCondition() && + thirdCondition() +) { + doStuff(); } ``` -### Early Returns +### Chained Method Calls -Use early returns to avoid deep nesting. +When a chain of method calls is too long to fit on one line, there must be one call per line, with the first call on a separate line from the object the methods are called on: ```javascript -// CORRECT -function processUser( user ) { - if ( ! user ) { - return null; - } - - if ( ! user.isActive ) { - return { error: 'User inactive' }; - } - - return { data: user.profile }; -} - -// INCORRECT -function processUser( user ) { - if ( user ) { - if ( user.isActive ) { - return { data: user.profile }; - } else { - return { error: 'User inactive' }; - } - } else { - return null; - } -} +elements + .addClass( 'foo' ) + .children() + .html( 'hello' ) + .end() + .appendTo( 'body' ); ``` --- -## 4. Objects and Arrays - -### Object Shorthand +## 4. Assignments and Globals -Use shorthand property and method syntax. +### Declaring Variables with const and let -```javascript -// CORRECT -const name = 'John'; -const age = 30; -const user = { - name, - age, - greet() { - return `Hello, ${ this.name }`; - }, -}; +For code written using ES2015 or newer, `const` and `let` should always be used in place of `var`. A declaration should use `const` unless its value will be reassigned, in which case `let` is appropriate. -// INCORRECT -const user = { - name: name, - age: age, - greet: function () { - return 'Hello, ' + this.name; - }, -}; -``` +Unlike `var`, it is not necessary to declare all variables at the top of a function. Instead, they are to be declared at the point at which they are first used. -### Destructuring +### Globals -Use destructuring for objects and arrays. +All globals used within a file should be documented at the top of that file. Multiple globals can be comma-separated. ```javascript -// CORRECT -const { name, email } = user; -const [ first, second ] = items; -const { data: userData } = response; - -function processUser( { name, email, role = 'user' } ) { - // Use destructured values -} - -// INCORRECT -const name = user.name; -const email = user.email; -const first = items[ 0 ]; +/* global passwordStrength:true */ ``` -### Spread Operator +The "true" after `passwordStrength` means that this global is being defined within this file. If you are accessing a global which is defined elsewhere, omit `:true` to designate the global as read-only. -Use spread for copying and merging. +### Common Libraries -```javascript -// CORRECT -const newArray = [ ...oldArray, newItem ]; -const newObject = { ...oldObject, newProperty: value }; -const merged = { ...defaults, ...options }; - -// INCORRECT -const newArray = oldArray.concat( [ newItem ] ); -const newObject = Object.assign( {}, oldObject, { newProperty: value } ); -``` +The global `wp` object is registered as an allowed global. -### Computed Property Names +**Legacy Note:** Backbone, jQuery, and Underscore were common in older WordPress code but should be avoided in new code. Use native JavaScript and ES6+ features instead. -Use computed property names when needed. +Files which add to, or modify, the `wp` object must safely access the global: ```javascript -// CORRECT -const key = 'dynamicKey'; -const obj = { - [ key ]: value, - [ `prefix_${ key }` ]: otherValue, -}; +// At the top of the file, set "wp" to its existing value (if present) +window.wp = window.wp || {}; ``` --- -## 5. Modules - -### ES Modules Only +## 5. Naming Conventions -Use ES modules (import/export) for all new code. +Variable and function names should be full words, using camel case with a lowercase first letter. Names should be descriptive, but not excessively so. Exceptions are allowed for iterators, such as the use of `i` to represent the index in a loop. -```javascript -// CORRECT -import { getState, setState } from './shared'; -import defaultExport from './module'; -export const myFunction = () => {}; -export default mainFunction; - -// INCORRECT -const module = require( './module' ); -module.exports = myFunction; -``` +| Type | Convention | Example | +| ----------- | -------------------- | ---------------------------- | +| Variables | camelCase | `currentUser`, `itemCount` | +| Functions | camelCase | `getUserData`, `handleClick` | +| Classes | PascalCase | `UserManager`, `Earth` | +| Constants | SCREAMING_SNAKE_CASE | `MAX_ITEMS`, `API_URL` | -### Named Exports Preferred +### Abbreviations and Acronyms -Prefer named exports over default exports for better refactoring. +Acronyms must be written with each of its composing letters capitalized. All other abbreviations must be written as camel case. ```javascript -// CORRECT -export const processData = ( data ) => {}; -export const validateData = ( data ) => {}; +// "Id" is an abbreviation of "Identifier": +const userId = 1; + +// "DOM" is an acronym of "Document Object Model": +const currentDOMDocument = window.document; -// Use -import { processData, validateData } from './utils'; +// Acronyms at the start follow camelcase rules +const domDocument = window.document; +class DOMDocument {} +class IdCollection {} ``` -### Single Import Per Module +### Class Definitions -Import from a module only once per file. +Constructors intended for use with `new` should have a capital first letter (UpperCamelCase). A `class` definition must use the UpperCamelCase convention. ```javascript -// CORRECT -import { foo, bar, baz } from './utils'; +class Earth { + static addHuman( human ) { + Earth.humans.push( human ); + } -// INCORRECT -import { foo } from './utils'; -import { bar } from './utils'; + static getHumans() { + return Earth.humans; + } +} + +Earth.humans = []; ``` -### No Wildcard Imports +All `@wordpress/element` Components, including stateless function components, should be named using Class Definition naming rules. -Avoid wildcard imports in production code. +### Constants -```javascript -// CORRECT -import { specificFunction } from './utils'; - -// INCORRECT -import * as utils from './utils'; -``` +An exception to camel case is made for constant values which are never intended to be reassigned or mutated. Such variables must use the SCREAMING_SNAKE_CASE convention. --- -## 6. DOM Manipulation - -### Query Selectors +## 6. Comments -Use native query selectors. +Comments come before the code to which they refer, and should always be preceded by a blank line. Capitalize the first letter of the comment, and include a period at the end when writing full sentences. There must be a single space between the comment token (`//`) and the comment text. ```javascript -// Single element -const element = document.querySelector( '.my-class' ); -const byId = document.getElementById( 'my-id' ); +someStatement(); -// Multiple elements -const elements = document.querySelectorAll( '.my-class' ); +// Explanation of something complex on the next line +document.querySelector( 'p' ).doSomething(); -// Scoped query -const child = parent.querySelector( '.child' ); +// This is a comment that is long enough to warrant being stretched +// over the span of multiple lines. ``` -### Element Creation - -```javascript -// Create element -const div = document.createElement( 'div' ); -div.className = 'my-class'; -div.textContent = 'Hello'; -div.dataset.id = '123'; +JSDoc comments should use the `/**` multi-line comment opening. -// Append -container.appendChild( div ); +Inline comments are allowed as an exception when used to annotate special arguments: -// Insert HTML (use with caution, escape user input) -container.insertAdjacentHTML( 'beforeend', '' ); +```javascript +function foo( types, selector, data, fn, /* INTERNAL */ one ) { + // Do stuff +} ``` -### Event Handling +--- -```javascript -// Add listener -element.addEventListener( 'click', handleClick ); +## 7. Equality -// Remove listener -element.removeEventListener( 'click', handleClick ); +Strict equality checks (`===`) must be used in favor of abstract equality checks (`==`). -// Event delegation -container.addEventListener( 'click', ( event ) => { - if ( event.target.matches( '.button' ) ) { - handleButtonClick( event ); - } -} ); +--- -// Custom events -element.dispatchEvent( new CustomEvent( 'custom-event', { detail: data } ) ); -``` +## 8. Type Checks -### Class Manipulation +These are the preferred ways of checking the type of an object: -```javascript -element.classList.add( 'active' ); -element.classList.remove( 'active' ); -element.classList.toggle( 'active' ); -element.classList.contains( 'active' ); -element.classList.replace( 'old', 'new' ); -``` +| Type | Check | +| --------- | -------------------------------------------- | +| String | `typeof object === 'string'` | +| Number | `typeof object === 'number'` | +| Boolean | `typeof object === 'boolean'` | +| Object | `typeof object === 'object'` | +| Function | `typeof object === 'function'` | +| Array | `Array.isArray( object )` | +| Element | `object.nodeType` | +| null | `object === null` | +| undefined | `typeof variable === 'undefined'` (globals) | +| undefined | `variable === undefined` (local) | --- -## 7. Async Operations - -### Fetch API +## 9. Strings -Use Fetch API instead of XMLHttpRequest or jQuery.ajax. +Use single-quotes for string literals: ```javascript -// GET request -const response = await fetch( '/api/data' ); -const data = await response.json(); - -// POST request -const response = await fetch( '/api/submit', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify( payload ), -} ); +const myStr = 'strings should be contained in single quotes'; ``` -### Async/Await - -Prefer async/await over Promise chains. +When a string contains single quotes, they need to be escaped with a backslash (`\`): ```javascript -// CORRECT -async function loadData() { - try { - const response = await fetch( url ); - if ( ! response.ok ) { - throw new Error( 'Network error' ); - } - const data = await response.json(); - return processData( data ); - } catch ( error ) { - handleError( error ); - return null; - } -} - -// INCORRECT - Promise chain for simple operations -function loadData() { - return fetch( url ) - .then( ( response ) => response.json() ) - .then( ( data ) => processData( data ) ) - .catch( ( error ) => handleError( error ) ); -} -``` - -### Parallel Async Operations - -Use Promise.all for independent parallel operations. - -```javascript -// CORRECT - Parallel execution -const [ users, posts, comments ] = await Promise.all( [ - fetchUsers(), - fetchPosts(), - fetchComments(), -] ); - -// INCORRECT - Sequential when parallel is possible -const users = await fetchUsers(); -const posts = await fetchPosts(); -const comments = await fetchComments(); +// Escape single quotes within strings: +'Note the backslash before the \'single quotes\''; ``` --- -## 8. Error Handling +## 10. Switch Statements -### Try-Catch for Async +The usage of `switch` statements is generally discouraged, but can be useful when there are a large number of cases. -Always wrap async operations in try-catch. +When using `switch` statements: -```javascript -async function fetchData() { - try { - const response = await fetch( url ); - return await response.json(); - } catch ( error ) { - console.error( 'Fetch failed:', error.message ); - return null; - } -} -``` +- Use a `break` for each case other than `default`. When allowing statements to "fall through," note that explicitly. +- Indent `case` statements one tab within the `switch`. -### Meaningful Error Messages +```javascript +switch ( event.key ) { -Provide context in error messages. + // ENTER and SPACE both trigger x() + case 'Enter': + case ' ': + x(); + break; -```javascript -// CORRECT -throw new Error( `Failed to load template: ${ templateId }` ); + case 'Escape': + y(); + break; -// INCORRECT -throw new Error( 'Error' ); + default: + z(); +} ``` +It is not recommended to return a value from within a switch statement: use the `case` blocks to set values, then `return` those values at the end. + --- -## 9. State Management +## 11. Best Practices -### Encapsulated State +### Arrays -Use closures or modules for state management. +Creating arrays in JavaScript should be done using the shorthand `[]` constructor rather than the `new Array()` notation. ```javascript -// CORRECT - Module pattern from codebase -import { - getState, - getSingleState, - setState, - setSingleState, -} from 'core/page-skeleton'; - -// Initialize state -setState( { - currentView: 'list', - selectedItem: null, - isLoading: false, -} ); - -// Update state -setSingleState( 'isLoading', true ); - -// Read state -const { currentView, selectedItem } = getState(); +const myArray = []; +const myArray = [ 1, 'WordPress', 2, 'Blog' ]; ``` -### Immutable Updates +### Objects -Never mutate state directly. +Object literal notation, `{}`, is both the most performant, and also the easiest to read. ```javascript -// CORRECT -const newState = { - ...state, - items: [ ...state.items, newItem ], -}; - -// INCORRECT -state.items.push( newItem ); +const myObj = {}; ``` ---- - -## 10. Anti-Patterns to Avoid +Object literal notation should be used unless the object requires a specific prototype, in which case the object should be created by calling a constructor function with `new`. -### Global Variable Pollution +Object properties should be accessed via dot notation, unless the key is a variable or a string that would not be a valid identifier: ```javascript -// INCORRECT -myGlobalVar = 'value'; -window.myApp = {}; - -// CORRECT - Use modules -export const myValue = 'value'; +prop = object.propertyName; +prop = object[ variableKey ]; +prop = object[ 'key-with-hyphens' ]; ``` -### Callback Hell +### Iteration -```javascript -// INCORRECT -getData( ( data ) => { - processData( data, ( result ) => { - saveData( result, ( response ) => { - // Deeply nested - } ); - } ); -} ); - -// CORRECT -const data = await getData(); -const result = await processData( data ); -const response = await saveData( result ); -``` - -### Modifying Built-in Prototypes - -```javascript -// NEVER DO THIS -Array.prototype.customMethod = function () {}; -String.prototype.myHelper = function () {}; -``` - -### Using eval() or Function() +When iterating over a large collection using a `for` loop, it is recommended to store the loop's max value as a variable rather than re-computing the maximum every time: ```javascript -// NEVER DO THIS -eval(userInput); -new Function(userInput)(); -``` - -### Magic Numbers/Strings +// Good & Efficient +const max = getItemCount(); -```javascript -// INCORRECT -if ( status === 3 ) { +// getItemCount() gets called once +for ( let i = 0; i < max; i++ ) { + // Do stuff } -element.style.width = '768px'; - -// CORRECT -const STATUS_COMPLETE = 3; -const TABLET_BREAKPOINT = '768px'; -if ( status === STATUS_COMPLETE ) { +// Bad & Potentially Inefficient: +// getItemCount() gets called every time +for ( let i = 0; i < getItemCount(); i++ ) { + // Do stuff } -element.style.width = TABLET_BREAKPOINT; -``` - -### Excessive DOM Queries - -```javascript -// INCORRECT -document.querySelector( '.item' ).classList.add( 'active' ); -document.querySelector( '.item' ).textContent = 'Updated'; -document.querySelector( '.item' ).dataset.id = '123'; - -// CORRECT - Cache the reference -const item = document.querySelector( '.item' ); -item.classList.add( 'active' ); -item.textContent = 'Updated'; -item.dataset.id = '123'; -``` - -### DOM Manipulation in Loops - -```javascript -// INCORRECT - Causes reflow on each iteration -items.forEach( ( item ) => { - container.appendChild( createItem( item ) ); -} ); - -// CORRECT - Use DocumentFragment -const fragment = document.createDocumentFragment(); -items.forEach( ( item ) => { - fragment.appendChild( createItem( item ) ); -} ); -container.appendChild( fragment ); -``` - ---- - -## 11. Project Structure - -Follow modular folder structure as in form-templates and onboarding-wizard. - -```text -module-name/ -├── index.js # Entry point, exports public API -├── initializeModule.js # Initialization logic -├── elements/ # DOM element references -│ ├── elements.js -│ └── index.js -├── events/ # Event listeners -│ ├── clickListener.js -│ └── index.js -├── shared/ # Shared state and constants -│ ├── constants.js -│ ├── pageState.js -│ └── index.js -├── ui/ # UI manipulation functions -│ ├── showModal.js -│ └── index.js -└── utils/ # Utility functions - ├── validation.js - └── index.js ``` --- @@ -743,7 +440,7 @@ module-name/ ```javascript // Actions -wp.hooks.doAction( 'myPlugin.beforeInit', { getState, setState } ); +wp.hooks.doAction( 'myPlugin.beforeInit', { data } ); wp.hooks.addAction( 'myPlugin.afterSave', 'myPlugin', handleAfterSave ); // Filters @@ -756,7 +453,6 @@ wp.hooks.addFilter( 'myPlugin.filterValue', 'myPlugin', modifyValue ); ```javascript import domReady from '@wordpress/dom-ready'; import { __ } from '@wordpress/i18n'; -import apiFetch from '@wordpress/api-fetch'; domReady( () => { initializeModule(); @@ -765,362 +461,22 @@ domReady( () => { --- -## Formatting - -### Spacing - -- Use tabs for indentation -- Space inside parentheses for function calls with arguments -- Space after `!` negation operator -- Spaces around operators - -```javascript -if ( condition ) { - doSomething( arg1, arg2 ); -} - -const isValid = ! isEmpty && hasValue; -const total = a + b * c; -``` +## JSHint -### Line Length +JSHint is an automated code quality tool, designed to catch errors in your JavaScript code. -Keep lines under 100 characters. Break after operators. +### JSHint Settings -```javascript -const result = - veryLongVariableName + anotherLongVariableName + yetAnotherVariable; -``` +The configuration options used for JSHint are stored within a `.jshintrc` file. -### Trailing Commas +### JSHint Overrides: Ignore Blocks -Use trailing commas in multiline structures. +To exclude a specific file region from being processed by JSHint, enclose it in JSHint directive comments: ```javascript -const obj = { - property1: 'value1', - property2: 'value2', -}; - -const arr = [ 'item1', 'item2' ]; -``` - ---- - -## 13. React Best Practices - -These patterns apply when writing React components for WordPress (blocks, admin pages, etc.). - -### Functional Components Only - -Never use class components. Use functional components with hooks. - -```jsx -// CORRECT -function MyComponent( { title, onSave } ) { - const [ isLoading, setIsLoading ] = useState( false ); - - return'+e.message+"
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),Zi(e)))})}function eo(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function to(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function ro(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function no(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function io(e){var t,r,n=e.target.value;ao(n),oo.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function oo(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function ao(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),Qo.call(document.querySelector(".frm-auto-search")))}}function lo(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function so(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function co(e){e.preventDefault(),mo(this,"frm_multiple_addons")}function uo(e){e.preventDefault(),mo(this,"frm_activate_addon")}function fo(e){e.preventDefault(),mo(this,"frm_install_addon")}function mo(e,t){r(1105).toggleAddonState(e,t)}function _o(){go()}function po(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function go(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function yo(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function ho(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),bo(t,r,this)}function vo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),bo(this,t,r)}function bo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;r'+e.message+"
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),Zi(e)))})}function eo(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function to(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function ro(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function no(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function io(e){var t,r,n=e.target.value;ao(n),oo.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function oo(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function ao(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),Qo.call(document.querySelector(".frm-auto-search")))}}function lo(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function so(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function co(e){e.preventDefault(),mo(this,"frm_multiple_addons")}function uo(e){e.preventDefault(),mo(this,"frm_activate_addon")}function fo(e){e.preventDefault(),mo(this,"frm_install_addon")}function mo(e,t){r(1105).toggleAddonState(e,t)}function _o(){go()}function po(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function go(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function yo(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function ho(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),bo(t,r,this)}function vo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),bo(this,t,r)}function bo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;r'+e.message+"
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),Zi(e)))})}function eo(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function to(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function ro(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function no(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function io(e){var t,r,n=e.target.value;ao(n),oo.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function oo(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function ao(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),Qo.call(document.querySelector(".frm-auto-search")))}}function lo(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function so(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function co(e){e.preventDefault(),mo(this,"frm_multiple_addons")}function uo(e){e.preventDefault(),mo(this,"frm_activate_addon")}function fo(e){e.preventDefault(),mo(this,"frm_install_addon")}function mo(e,t){r(1105).toggleAddonState(e,t)}function _o(){go()}function po(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function go(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function yo(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function ho(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),bo(t,r,this)}function vo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),bo(this,t,r)}function bo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;r'+e.message+"
Imported '+r.data.name+"
",e.find(".status").prepend(n),e.find(".status").show(),C.importQueue=jQuery.grep(C.importQueue,function(e){return e!=t}),C.imported++,0===C.importQueue.length?(e.find(".process-count").hide(),e.find(".forms-completed").text(C.imported),e.find(".process-completed").show()):(e.find(".form-current").text(C.imported+1),Zi(e)))})}function eo(e){e.preventDefault();var t=!1,r=jQuery('input[name="frm_export_forms[]"]');jQuery('input[name="frm_export_forms[]"]:checked').val()||(r.closest(".frm-table-box").addClass("frm_blank_field"),t="stop");var n=jQuery('input[name="type[]"]');if(jQuery('input[name="type[]"]:checked').val()||"checkbox"!==n.attr("type")||(n.closest("p").addClass("frm_blank_field"),t="stop"),"stop"===t)return!1;e.stopPropagation(),this.submit()}function to(){var e=jQuery(this).closest(".frm_blank_field");if(void 0!==e){var t=this.name;("type[]"===t&&jQuery('input[name="type[]"]:checked').val()||"frm_export_forms[]"===t&&jQuery(this).val())&&e.removeClass("frm_blank_field")}}function ro(){null!==jQuery(this).val().match(/\.csv$/i)?jQuery(".show_csv").fadeIn():jQuery(".show_csv").fadeOut()}function no(){var e=document.querySelector('select[name="format"]');return e?e.value:""}function io(e){var t,r,n=e.target.value;ao(n),oo.call(e.target),t=n,r=document.getElementById("frm-export-select-all"),"csv"===t?(r.checked=!1,r.disabled=!0):r.disabled=!1}function oo(){var e=jQuery(this),t=e.find(":selected"),r=t.data("support"),n=r.indexOf("|");jQuery('input[name="type[]"]').each(function(){this.checked=!1,r.includes(this.value)?(this.disabled=!1,-1===n&&(this.checked=!0)):this.disabled=!0}),"csv"===e.val()?(jQuery(".csv_opts").show(),jQuery(".xml_opts").hide()):(jQuery(".csv_opts").hide(),jQuery(".xml_opts").show());var i=t.data("count"),o=jQuery('input[name="frm_export_forms[]"]');"single"===i?(o.prop("multiple",!1),o.prop("checked",!1)):(o.prop("multiple",!0),o.prop("disabled",!1)),e.trigger("change")}function ao(e){if(""!==e){var t=document.querySelectorAll(".frm-is-repeater");t.length&&("csv"===e?t.forEach(function(e){e.classList.remove("frm_hidden")}):t.forEach(function(e){e.classList.add("frm_hidden")}),Qo.call(document.querySelector(".frm-auto-search")))}}function lo(){var e=jQuery("select[name=format]").find(":selected").data("count"),t=jQuery('input[name="frm_export_forms[]"]');"single"===e&&this.checked?(t.prop("disabled",!0),this.removeAttribute("disabled")):t.prop("disabled",!1)}function so(){jQuery(".frm_multiselect").hide().each(frmDom.bootstrap.multiselect.init)}function co(e){e.preventDefault(),mo(this,"frm_multiple_addons")}function uo(e){e.preventDefault(),mo(this,"frm_activate_addon")}function fo(e){e.preventDefault(),mo(this,"frm_install_addon")}function mo(e,t){r(1105).toggleAddonState(e,t)}function _o(){go()}function po(e){!function(e,t,r){var n=jQuery("#frm_leave_email_error");n.removeClass("frm_hidden").attr("frm-error",r),jQuery("#frm_leave_email").one("keyup",function(){n.addClass("frm_hidden")})}(0,0,e)}function go(){var e=document.getElementById("frmapi-email-form");jQuery.ajax({dataType:"json",url:e.getAttribute("data-url"),success:function(t){var r=t.renderedHtml;r=r.replace(/]*(formidableforms.css|action=frmpro_css)[^>]*>/gi,""),e.innerHTML=r}})}function yo(e){frmDom.autocomplete.initSelectionAutocomplete(e)}function ho(e){var t=this.parentNode.parentNode,r=t.elements.type.value;e.preventDefault(),this.classList.add("frm_loading_button"),bo(t,r,this)}function vo(e){var t=this.elements.type.value,r=this.querySelector("button");e.preventDefault(),r.classList.add("frm_loading_button"),bo(this,t,r)}function bo(e,t,r){var n=function(e){var t,r,n={},i=e.elements;for(r=0;r'+e.message+"
'+e.message+"