{"version":3,"file":"general.js","names":["KTSigninGeneral","form","submitButton","validator","init","document","querySelector","FormValidation","formValidation","fields","email","validators","regexp","message","notEmpty","password","plugins","trigger","Trigger","bootstrap","Bootstrap5","rowSelector","eleInvalidClass","eleValidClass","addEventListener","e","preventDefault","validate","then","status","setAttribute","disabled","setTimeout","removeAttribute","Swal","fire","text","icon","buttonsStyling","confirmButtonText","customClass","confirmButton","result","isConfirmed","value","redirectUrl","getAttribute","location","href","KTUtil","onDOMContentLoaded"],"sources":["authentication/sign-in/general.js"],"mappings":"AAAA,aAGA,IAAIA,gBAAkB,WAElB,IAAIC,EACAC,EACAC,EA2KJ,MAAO,CAEHC,KAAM,WACFH,EAAOI,SAASC,cAAc,oBAC9BJ,EAAeG,SAASC,cAAc,sBA1K1CH,EAAYI,eAAeC,eAChCP,EACA,CACCQ,OAAQ,CACPC,MAAS,CACUC,WAAY,CACRC,OAAQ,CACJA,OAAQ,6BACRC,QAAS,0CAElCC,SAAU,CACTD,QAAS,+BAIGE,SAAY,CACRJ,WAAY,CACRG,SAAU,CACND,QAAS,+BAKrCG,QAAS,CACRC,QAAS,IAAIV,eAAeS,QAAQE,QACpCC,UAAW,IAAIZ,eAAeS,QAAQI,WAAW,CAC9BC,YAAa,UACbC,gBAAiB,GACjBC,cAAe,QAS/BrB,EAAasB,iBAAiB,SAAS,SAAUC,GAE7CA,EAAEC,iBAGFvB,EAAUwB,WAAWC,MAAK,SAAUC,GAClB,SAAVA,GAEA3B,EAAa4B,aAAa,oBAAqB,MAG/C5B,EAAa6B,UAAW,EAIxBC,YAAW,WAEP9B,EAAa+B,gBAAgB,qBAG7B/B,EAAa6B,UAAW,EAGxBG,KAAKC,KAAK,CACNC,KAAM,mCACNC,KAAM,UACNC,gBAAgB,EAChBC,kBAAmB,cACnBC,YAAa,CACTC,cAAe,qBAEpBb,MAAK,SAAUc,GACd,GAAIA,EAAOC,YAAa,CACpB1C,EAAKK,cAAc,kBAAkBsC,MAAO,GAC5C3C,EAAKK,cAAc,qBAAqBsC,MAAO,GAG/C,IAAIC,EAAc5C,EAAK6C,aAAa,wBAChCD,IACAE,SAASC,KAAOH,EAExB,CACJ,GACJ,GAAG,MAGHX,KAAKC,KAAK,CACNC,KAAM,sEACNC,KAAM,QACNC,gBAAgB,EAChBC,kBAAmB,cACnBC,YAAa,CACTC,cAAe,oBAI/B,GACV,GAiFM,EAER,CA1LsB,GA6LtBQ,OAAOC,oBAAmB,WACtBlD,gBAAgBI,MACpB","sourcesContent":["\"use strict\";\r\n\r\n// Class definition\r\nvar KTSigninGeneral = function() {\r\n // Elements\r\n var form;\r\n var submitButton;\r\n var validator;\r\n\r\n // Handle form\r\n var handleValidation = function(e) {\r\n // Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/\r\n validator = FormValidation.formValidation(\r\n\t\t\tform,\r\n\t\t\t{\r\n\t\t\t\tfields: {\t\t\t\t\t\r\n\t\t\t\t\t'email': {\r\n validators: {\r\n regexp: {\r\n regexp: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\r\n message: 'The value is not a valid email address',\r\n },\r\n\t\t\t\t\t\t\tnotEmpty: {\r\n\t\t\t\t\t\t\t\tmessage: 'Email address is required'\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t},\r\n 'password': {\r\n validators: {\r\n notEmpty: {\r\n message: 'The password is required'\r\n }\r\n }\r\n } \r\n\t\t\t\t},\r\n\t\t\t\tplugins: {\r\n\t\t\t\t\ttrigger: new FormValidation.plugins.Trigger(),\r\n\t\t\t\t\tbootstrap: new FormValidation.plugins.Bootstrap5({\r\n rowSelector: '.fv-row',\r\n eleInvalidClass: '', // comment to enable invalid state icons\r\n eleValidClass: '' // comment to enable valid state icons\r\n })\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\t\r\n }\r\n\r\n var handleSubmitDemo = function(e) {\r\n // Handle form submit\r\n submitButton.addEventListener('click', function (e) {\r\n // Prevent button default action\r\n e.preventDefault();\r\n\r\n // Validate form\r\n validator.validate().then(function (status) {\r\n if (status == 'Valid') {\r\n // Show loading indication\r\n submitButton.setAttribute('data-kt-indicator', 'on');\r\n\r\n // Disable button to avoid multiple click \r\n submitButton.disabled = true;\r\n \r\n\r\n // Simulate ajax request\r\n setTimeout(function() {\r\n // Hide loading indication\r\n submitButton.removeAttribute('data-kt-indicator');\r\n\r\n // Enable button\r\n submitButton.disabled = false;\r\n\r\n // Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/\r\n Swal.fire({\r\n text: \"You have successfully logged in!\",\r\n icon: \"success\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n }).then(function (result) {\r\n if (result.isConfirmed) { \r\n form.querySelector('[name=\"email\"]').value= \"\";\r\n form.querySelector('[name=\"password\"]').value= \"\"; \r\n \r\n //form.submit(); // submit form\r\n var redirectUrl = form.getAttribute('data-kt-redirect-url');\r\n if (redirectUrl) {\r\n location.href = redirectUrl;\r\n }\r\n }\r\n });\r\n }, 2000); \t\t\t\t\t\t\r\n } else {\r\n // Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/\r\n Swal.fire({\r\n text: \"Sorry, looks like there are some errors detected, please try again.\",\r\n icon: \"error\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n });\r\n }\r\n });\r\n\t\t});\r\n }\r\n\r\n var handleSubmitAjax = function(e) {\r\n // Handle form submit\r\n submitButton.addEventListener('click', function (e) {\r\n // Prevent button default action\r\n e.preventDefault();\r\n\r\n // Validate form\r\n validator.validate().then(function (status) {\r\n if (status == 'Valid') {\r\n // Hide loading indication\r\n submitButton.removeAttribute('data-kt-indicator');\r\n\r\n // Enable button\r\n submitButton.disabled = false;\r\n \r\n // Check axios library docs: https://axios-http.com/docs/intro \r\n axios.post('/your/ajax/login/url', {\r\n email: form.querySelector('[name=\"email\"]').value, \r\n password: form.querySelector('[name=\"password\"]').value \r\n }).then(function (response) {\r\n if (response) {\r\n form.querySelector('[name=\"email\"]').value= \"\";\r\n form.querySelector('[name=\"password\"]').value= \"\"; \r\n\r\n const redirectUrl = form.getAttribute('data-kt-redirect-url');\r\n \r\n if (redirectUrl) {\r\n location.href = redirectUrl;\r\n }\r\n } else {\r\n // Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/\r\n Swal.fire({\r\n text: \"Sorry, the email or password is incorrect, please try again.\",\r\n icon: \"error\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n });\r\n }\r\n }).catch(function (error) {\r\n Swal.fire({\r\n text: \"Sorry, looks like there are some errors detected, please try again.\",\r\n icon: \"error\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n });\r\n });\r\n } else {\r\n // Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/\r\n Swal.fire({\r\n text: \"Sorry, looks like there are some errors detected, please try again.\",\r\n icon: \"error\",\r\n buttonsStyling: false,\r\n confirmButtonText: \"Ok, got it!\",\r\n customClass: {\r\n confirmButton: \"btn btn-primary\"\r\n }\r\n });\r\n }\r\n });\r\n\t\t});\r\n }\r\n\r\n // Public functions\r\n return {\r\n // Initialization\r\n init: function() {\r\n form = document.querySelector('#kt_sign_in_form');\r\n submitButton = document.querySelector('#kt_sign_in_submit');\r\n \r\n handleValidation();\r\n handleSubmitDemo(); // used for demo purposes only, if you use the below ajax version you can uncomment this one\r\n //handleSubmitAjax(); // use for ajax submit\r\n }\r\n };\r\n}();\r\n\r\n// On document ready\r\nKTUtil.onDOMContentLoaded(function() {\r\n KTSigninGeneral.init();\r\n});\r\n"]}