You've already forked Mottashaw-Consulting
All checks were successful
Publish to Server / Deploy (push) Successful in 7s
1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
!function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return o(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(e,t,n){"use strict";var r=e("./src/Form"),o=e("./src/helpers/on"),i=e("./src/helpers/trigger"),s=e("./src/helpers/isValidURL"),a=e("./src/helpers/addStyles"),u=(e("./src/helpers/messages"),"https://bootstrapstudio.io/smartform-handler"),l=null,c=document.createElement("iframe"),f=document.createElement("div"),p="",h={filter:"none",transform:"none","transform-style":"flat","backdrop-filter":"none",perspective:"none","content-visibility":"visible",contain:"none"};function g(){d(f),d(c),document.body.attributes.style&&(document.body.attributes.style.value=p),i(l.element,"smart-form-closed")}function d(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.parentNode.removeChild(e)}function y(e){m({operation:"showMessage",message:e.message||"",status:e.status||"loading",title:e.title||""},"*")}function m(e,t){c.contentWindow.postMessage(e,t)}function v(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};e.redirectURL&&s(e.redirectURL)?window.location.href=e.redirectURL:(i(l.element,"smart-form-sent"),y({status:"success",title:e.title,message:e.message}),l.reset())}function b(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};i(l.element,"smart-form-error"),y({status:"error",title:e.title,message:e.message})}a(c,{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",display:"block","max-width":"100%",width:"600px",height:"500px",background:"white",border:"none","border-radius":"10px","z-index":"9999"}),a(f,{position:"fixed",display:"block",top:"0",width:"100%",height:"100%","background-color":"rgba(0,0,0,0.7)","z-index":"9998"}),o(c,"load",null,(function(){l&&(10485760<l.getFileSize()?y({status:"error",title:l.getMessage("filesize","title",l.getMessage("error","title")),message:l.getMessage("filesize","message")}):m({operation:"showRecaptcha"},"*"))})),o(window,"message",null,(function(e){var t,n=e.data,r=n.operation,o=n.recaptchaToken;"submitEmail"===r?(t=o,l.submit(u,"POST",[{name:"recaptchaToken",value:t},{name:"sentFromURL",value:window.location.href}])):"closeIframe"===r&&g()})),o(document,"submit","form[data-bss-recipient]",(function(e){e.preventDefault(),l=new r(e.target,{onSuccess:v,onError:b,beforeSend:function(e){return y(Object.assign({status:"loading"},e))}}),function(){var e=new URL("https://bootstrapstudio.io/smartform-iframe?large=1"),t=new URLSearchParams(e.search.slice(1)),n=l.getMessage("close");t.append("closeBtnText",n),e.search=t.toString(),c.src=e.toString();var r=document.body;p=r.attributes.style?r.attributes.style.value:"",a(r,h,!0),r.appendChild(c),r.appendChild(f)}()}),!0),o(f,"click",null,g)},{"./src/Form":6,"./src/helpers/addStyles":10,"./src/helpers/isValidURL":11,"./src/helpers/messages":12,"./src/helpers/on":13,"./src/helpers/trigger":14}],2:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"get",value:function(t){t.method="GET",e.send(t)}},{key:"post",value:function(t){t.method="POST",e.send(t)}},{key:"send",value:function(e){var t=e.headers||{"X-Requested-With":"XMLHttpRequest"},n=e.body||null,r=e.method||(n?"POST":"GET"),o=e.url,i=new XMLHttpRequest;for(var s in e.beforeSend&&e.beforeSend(),i.open(r,o,!0),i.onload=function(t){if(4===i.readyState){var n={};try{n=JSON.parse(i.responseText),200===i.status?e.success&&e.success(n):e.error&&e.error(n)}catch(t){console.error(t)}}},i.onerror=function(t){e.error&&e.error({})},t)i.setRequestHeader(s,t[s]);i.send(n)}}]),e}();t.exports=o},{}],3:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./RadioButton"),i=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"getType",value:function(){return"checkbox"}},{key:"hasValue",value:function(){return!0}},{key:"getName",value:function(){return this.hasMultipleValues()?function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;var s=o.get;return void 0!==s?s.call(r):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"getName",this).call(this):""}},{key:"hasMultipleValues",value:function(){return!!this.getSiblings().length}}]),t}();t.exports=i},{"./RadioButton":8}],4:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.element=t,this.id=t.id.trim(),this.text=t.innerText.trim()}return r(e,[{key:"isTag",value:function(e){return this.element.tagName.toLowerCase()===e.toLowerCase()}},{key:"find",value:function(e){return this.element.querySelector(e)}},{key:"findAll",value:function(e){return this.element.querySelectorAll(e)}},{key:"getParentByTag",value:function(t){for(var n=this.element;(n=n.parentNode)&&n!==document;){var r=new e(n,this.form);if(r.isTag(t))return r}return null}}]),e}();t.exports=o},{}],5:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./FormField"),i=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"getType",value:function(){return"file"}},{key:"getData",value:function(){for(var e=[],t=0;t<this.element.files.length;t++)e.push({name:(this.isNameSet()?this.getName():this.identifier)+(1<this.element.files.length?"[]":""),value:this.element.files[t]});return e}},{key:"getSize",value:function(){for(var e=0,t=0;t<this.element.files.length;t++)e+=this.element.files[t].size;return e}}]),t}();t.exports=i},{"./FormField":7}],6:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./Component"),i=e("./Checkbox"),s=e("./FormField"),a=e("./RadioButton"),u=e("./Select"),l=e("./FileField"),c=e("./Ajax"),f=e("./helpers/messages"),p=function(e){function t(e,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.options=n,r.recipient=e.getAttribute("data-bss-recipient"),r.redirectURL=e.getAttribute("data-bss-redirect-url")||"",r.initialize(),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"initialize",value:function(){var e=this.element.querySelectorAll("input, textarea, select");this.fields=[];for(var t=0;t<e.length;t++)"submit"!==e[t].type&&this.fields.push(this.createChild(e[t],"field-"+t))}},{key:"createChild",value:function(e,t){var n=void 0;switch(e.tagName.toLowerCase()){case"input":n="radio"===e.type?new a(e,this,t):"checkbox"===e.type?new i(e,this,t):"file"===e.type?new l(e,this,t):new s(e,this,t);break;case"select":n=new u(e,this,t);break;default:n=new s(e,this,t)}return n}},{key:"getDataFields",value:function(){return this.fields.filter((function(e){return"file"!==e.getType()}))}},{key:"getFileFields",value:function(){return this.fields.filter((function(e){return"file"===e.getType()}))}},{key:"getData",value:function(){var e=this.getDataFields().slice(),t=[];return e.forEach((function(n){if(n.hasValue())if(n.hasMultipleValues()){var r={name:n.getName(),data:{type:n.getType(),value:[].concat(n.getValue())}};"checkbox"===n.getType()&&n.getSiblings().forEach((function(t){r.data.value.push(t.getValue()),e.splice(e.indexOf(t),1)})),t=t.concat(r)}else t=t.concat(n.getData())})),t}},{key:"getFiles",value:function(){var e=[];return this.getFileFields().forEach((function(t){t.hasValue()&&(e=e.concat(t.getData()))})),e}},{key:"getFieldsByType",value:function(e){return this.fields.filter((function(t){return t instanceof e}))}},{key:"getFileSize",value:function(){var e=this.getFieldsByType(l),t=0;return e.forEach((function(e){t+=e.getSize()})),t}},{key:"getAttributeForMessage",value:function(){return"data-bss-"+[0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",1<arguments.length&&void 0!==arguments[1]?arguments[1]:""].filter((function(e){return!!e})).join("-")}},{key:"getKeyForMessage",value:function(){return[0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",1<arguments.length&&void 0!==arguments[1]?arguments[1]:""].filter((function(e){return!!e})).join(".")}},{key:"getDefaultMessage",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";return f[this.getKeyForMessage(e,t)]||n}},{key:"getCustomMessage",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";return this.element.getAttribute(this.getAttributeForMessage(e,t))||n}},{key:"getMessage",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"";return this.getCustomMessage(e,t,n)||this.getDefaultMessage(e,t,n)||n}},{key:"submit",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],r=this.getFiles(),o=new FormData,i=[].filter.call(this.element.attributes,(function(e){return e.name.match(/^data-bss-/g)})).map((function(e){return{name:e.name.replace("data-bss-",""),value:e.value}}));r=r.concat(n,i);for(var s=0;s<r.length;s++)o.append(r[s].name,r[s].value);o.append("data",JSON.stringify(this.getData())),c.send({url:e,method:t,body:o,error:this.onError.bind(this),success:this.onSuccess.bind(this),beforeSend:this.beforeSend.bind(this)})}},{key:"reset",value:function(){this.element.reset()}},{key:"beforeSend",value:function(){var e={title:this.getMessage("loading","title"),message:this.getMessage("loading","message")};this.options.beforeSend&&this.options.beforeSend(e)}},{key:"onSuccess",value:function(e){var t={title:this.getMessage("success","title"),message:this.getMessage("success","message"),redirectURL:this.redirectURL};this.options.onSuccess&&this.options.onSuccess(t)}},{key:"onError",value:function(e){var t={};e&&e.error&&(t.title=this.getMessage(e.error.type,"title",this.getMessage("error","title")),t.message=this.getMessage(e.error.type,"message")),t.title&&t.message||(t.title=t.title||this.getMessage("error","title"),t.message=t.message||this.getMessage("error","message")),this.options.onError&&this.options.onError(t)}}]),t}();t.exports=p},{"./Ajax":2,"./Checkbox":3,"./Component":4,"./FileField":5,"./FormField":7,"./RadioButton":8,"./Select":9,"./helpers/messages":12}],7:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./Component"),i=function(e){function t(e,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.form=n,o.identifier=r,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"getType",value:function(){return this.element.type||"text"}},{key:"hasValue",value:function(){return!!this.getValue()}},{key:"hasMultipleValues",value:function(){return!!this.element.multiple}},{key:"getValue",value:function(){return this.element.value.trim()}},{key:"getName",value:function(){var e=this.element.name.trim();if(!e){var t=this.getLabel();e=t?t.text:this.element.placeholder?this.element.placeholder:this.id?this.id:this.getDefaultName()}return this.normalizeName(e)}},{key:"getDefaultName",value:function(){return"Not Defined"}},{key:"isNameSet",value:function(){return this.getName()!==this.getDefaultName()}},{key:"normalizeName",value:function(e){return e.trim()}},{key:"getData",value:function(){return{name:this.getName(),data:{type:this.getType(),value:this.getValue()}}}},{key:"getLabel",value:function(){var e=void 0;if(this.id&&(e=this.form.find("label[for="+this.id+"]")))return new o(e);if(e=this.getParentByTag("label"))return e;var t=this.element.previousElementSibling?new o(this.element.previousElementSibling):null;return t&&t.isTag("label")?t:null}},{key:"getSiblings",value:function(){var e=this;return this.element.name.trim()?this.form.getFieldsByType(this.constructor).filter((function(t){return t!==e&&t.element.name===e.element.name})):[]}}]),t}();t.exports=i},{"./Component":4}],8:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function e(t,n,r){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;var s=o.get;return void 0!==s?s.call(r):void 0},i=e("./FormField"),s=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i),r(t,[{key:"getType",value:function(){return"radio"}},{key:"hasValue",value:function(){return o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"hasValue",this).call(this)&&this.element.checked}},{key:"getValue",value:function(){var e=this.getLabel(),n=void 0;return e&&(n=e.text),{value:n||o(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"getValue",this).call(this),active:this.element.checked}}}]),t}();t.exports=s},{"./FormField":7}],9:[function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=e("./FormField"),i=function(e){function t(e,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));return r.options=r.element.options,r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,o),r(t,[{key:"getType",value:function(){return"select"}},{key:"getValue",value:function(){for(var e=[],t=0;t<this.options.length;t++)this.options[t].selected&&e.push({value:this.options[t].textContent});return e}}]),t}();t.exports=i},{"./FormField":7}],10:[function(e,t,n){"use strict";t.exports=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];for(var r in t)e.style.setProperty(r,t[r],n?"important":"")}},{}],11:[function(e,t,n){"use strict";t.exports=function(e){try{return e=/^https?:\/\//i.test(e)?new URL(e):new URL(e,window.location.origin),!0}catch(e){return!1}}},{}],12:[function(e,t,n){"use strict";t.exports={close:"Close","loading.title":"","loading.message":"Sending...","success.title":"Success","success.message":"Your message has been delivered.","error.title":"Oops...","error.message":"Something went wrong, please try again later.","filesize.title":"Oops, files are too big!","filesize.message":"Total size should be less than 10mb.","unknown-recipient.title":"Unknown recipient","unknown-recipient.message":"We couldn't locate the email address for sending this form.","empty-form.title":"The form is empty!","empty-form.message":"Please fill in the required fields and try again."}},{}],13:[function(e,t,n){"use strict";t.exports=function(e,t,n,r,o){var i,s=void 0;o=o||!1,(s=e?"string"==typeof e?document.querySelector(e):e:document)&&(i=o?function(e){for(var t=s.querySelectorAll(n),o=e.target,i=0,a=t.length;i<a;i++)for(var u=o,l=t[i];u&&u!==s;){if(u===l)return r.call(l,e);u=u.parentNode}}:r,s.addEventListener(t,i))}},{}],14:[function(e,t,n){"use strict";t.exports=function(e,t){var n=new Event(t,{bubbles:!0,cancelable:!0});setTimeout((function(){e.dispatchEvent(n)}),0)}},{}]},{},[1]); |