PageSourceSearch

https://www.accessorize.com/on/demandware.static/Sites-accessorize…/js/global/DynamicFormValidator.js

js accessorize.com collected 2026-09-25 15:06:21 UTC 6,010 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkmnsn=self.webpackChunkmnsn||[]).push([[8476],{35917:function(e,t,i){i.r(t),i.d(t,{default:function(){return p}});var r=i(90540),n=i(8207),o=i(75451),s=i(43047);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function l(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function c(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},u.apply(null,arguments)}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}var p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&f(e,t)}(c,e);var t,i,r=function(e){var t=d();return function(){var i,r=h(e);if(t){var n=h(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return function(e,t){if(t&&("object"==a(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,i)}}(c);function c(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),r.apply(this,arguments)}return t=c,(i=[{key:"updateSelectors",value:function(){this.selectors.countrySelector=this.element.querySelector(s.FIELD_COUNTRY_ELEMENT_SELECTOR),this.fieldsToUpdate={},this.fieldsToUpdate.postalCode=this.element.querySelector(s.FIELD_POSTALCODE_ELEMENT_SELECTOR);var e=this.element.querySelector(s.FIELD_STATECODE_BLOCK_SELECTOR);e&&!e.hidden?this.fieldsToUpdate.stateCode=this.element.querySelector(s.FIELD_STATECODE_ELEMENT_SELECTOR):this.fieldsToUpdate.stateCode=this.element.querySelector(s.FIELD_STATE_ELEMENT_SELECTOR)}},{key:"initCache",value:function(){u(h(c.prototype),"initCache",this).call(this),this.updateSelectors()}},{key:"initState",value:function(){u(h(c.prototype),"initState",this).call(this),this.selectors.countrySelector&&this.initDynamicValidator()}},{key:"initDynamicValidator",value:function(e){if(this.options.rules){e&&e.detail&&"updateSelectors"in e.detail&&e.detail.updateSelectors&&this.updateSelectors();var t=this.selectors.countrySelector.value,i=this.options.rules[t]||this.options.rules.default;t&&i&&this.processRules(i)}}},{key:"asciiToHexa",value:function(e){return"\\x"+Number(e.charCodeAt(0)).toString(16)}},{key:"processRules",value:function(e){for(var t in e)if(this.fieldsToUpdate[t]){var i=this.fieldsToUpdate[t],r=e[t];this.updateRequired(i,r),this.updateRegexp(i,r,t),this.updateLabel(i,r,t),this.updateMaxLength(i,r)}}},{key:"updateLabel",value:function(e,t,i){var r=e.closest(s.FIELD_CONTAINER_SELECTOR),n=r?r.querySelector("label"):null;if(n){var o=t.label?t.label:this.options.rules.default[i].label;if(o){var a=this.options.locale&&o[this.options.locale]?this.options.locale:"default";n.innerHTML=n.innerHTML.replace(/[\w\s]+/,o[a])}}}},{key:"updateRequired",value:function(e,t){var i="required";t[i]?(e.setAttribute(i,i),e.closest(s.FIELD_CONTAINER_SELECTOR).classList.add(s.FORM_GROUP_REQUIRED_CLASS)):(e.removeAttribute(i),e.closest(s.FIELD_CONTAINER_SELECTOR).classList.remove(s.FORM_GROUP_REQUIRED_CLASS)),this.resetField(e)}},{key:"updateMaxLength",value:function(e,t){var i="maxlength",r=t[i]?t[i]:0;r>0?e.setAttribute(i,r):e.removeAttribute(i),this.resetField(e)}},{key:"updateRegexp",value:function(e,t,i){var r=t.regexp?t.regexp:this.options.rules.default[i].regexp;r&&(r.indexOf('"')>-1&&(r=r.replace('"',this.asciiToHexa('"'))),r.indexOf("&")>-1&&(r=r.replace("&",this.asciiToHexa("&"))),r.indexOf("<")>-1&&(r=r.replace("<",this.asciiToHexa("<"))),e.setAttribute("pattern",r),this.resetField(e))}},{key:"deferredInit",value:function(){this.updateSelectors(),this.selectors.countrySelector&&(n.J.on("field.country:changed",this.initDynamicValidator,this),(0,o.on)("change",this.selectors.countrySelector,this.initDynamicValidator.bind(this)),this.initDynamicValidator(),n.J.off("dynamic.form:loaded",this.deferredInit,this))}},{key:"bindEvents",value:function(){u(h(c.prototype),"bindEvents",this).call(this),this.selectors.countrySelector?((0,o.on)("change",this.selectors.countrySelector,this.initDynamicValidator.bind(this)),n.J.on("field.country:changed",this.initDynamicValidator,this)):n.J.on("dynamic.form:loaded",this.deferredInit,this)}},{key:"destroy",value:function(){u(h(c.prototype),"destroy",this).call(this),this.selectors.countrySelector&&(0,o.AU)("change",this.selectors.countrySelector,this.initDynamicValidator),n.J.off("dynamic.form:loaded",this.deferredInit,this),n.J.off("field.country:changed",this.initDynamicValidator,this)}}
1])&&l(t.prototype,i),Object.defineProperty(t,"prototype",{writable:!1}),c}(r.default)}}]);

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.