Sha256: 0f0cb1cfbc18763619af316df9e31202256eba5f83c22d26173cf4d1187d0eff

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

const formHelper = () => {
    const loadingForm = document.querySelector(".pb_form_loading")
    if (loadingForm) {
        loadingForm.addEventListener("submit", function(event) {
            const submitButton = event['submitter'];
            const cancelButton = event['target'].querySelector('button[type="reset"]');

            if (submitButton) {
                let currentClass = submitButton.className;
                let newClass = currentClass.replace("_enabled", "_disabled_loading");

                let cancelClass = cancelButton ? cancelButton.className : "";
                let newCancelClass = cancelClass.replace("_enabled", "_disabled");

                submitButton.disabled = true;
                submitButton.className = newClass;

                if (cancelButton) {
                    cancelButton.disabled = true;
                    cancelButton.className = newCancelClass;
                }

                setTimeout(function() {
                    submitButton.disabled = false;
                    submitButton.className = currentClass;

                    if (cancelButton) {
                        cancelButton.disabled = false;
                        cancelButton.className = cancelClass;
                    }
                }, 5000);
            }

            this.submit();
        });
    }
};

export default formHelper;

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-14.5.0.pre.alpha.PLAY1510railsformloading3977 app/pb_kits/playbook/pb_form/formHelper.js