Plugin Directory

Changeset 3349046


Ignore:
Timestamp:
08/23/2025 05:28:38 PM (7 months ago)
Author:
mosparo
Message:

Fixed multiple issues with the Gravity Forms module.

Location:
mosparo-integration
Files:
3 edited
65 copied

Legend:

Unmodified
Added
Removed
  • mosparo-integration/tags/1.14.2/mosparo-integration.php

    r3347189 r3349046  
    1515 * Author URI:        https://mosparo.io/
    1616 * License:           MIT
    17  * Version:           1.14.1
     17 * Version:           1.14.2
    1818 * Text Domain:       mosparo-integration
    1919 * Domain Path:       /languages
  • mosparo-integration/tags/1.14.2/readme.txt

    r3347189 r3349046  
    55Tested up to: 6.8.1
    66Requires PHP: 7.4
    7 Stable tag: 1.14.1
     7Stable tag: 1.14.2
    88License: MIT
    99
     
    105105== Changelog ==
    106106
     107= 1.14.2 =
     108*Release Date: 23rd August 2025*
     109
     110* [Bugfix] Fixed multiple issues with the Gravity Forms module in combination with the AJAX submitting method and the invisible mosparo mode.
     111
    107112= 1.14.1 =
    108113*Release Date: 19th August 2025*
  • mosparo-integration/tags/1.14.2/src/MosparoIntegration/Helper/FrontendHelper.php

    r3347189 r3349046  
    146146
    147147        return sprintf('
    148             if (typeof mosparoInstances == "undefined") {
     148            if (typeof mosparoInstances === "undefined") {
    149149                var mosparoInstances = [];
    150150            }
     
    152152            (function () {
    153153                let scriptEl = null;
    154                 if (typeof mosparo == "undefined") {
     154                if (typeof mosparo === "undefined") {
    155155                    scriptEl = document.createElement("script");
    156156                    scriptEl.setAttribute("src", "%s");
     
    158158                }
    159159               
    160                 let initializeMosparo = function () {
     160                let initializeMosparo = function (ev) {
    161161                    let id = "mosparo-box-%s";
    162162                    if (typeof mosparoInstances[id] !== "undefined") {
     
    255255                    });
    256256                   
    257                     if (typeof(gform) !== "undefined") {
     257                    if (typeof gform !== "undefined") {
    258258                        gform.addAction("gform_after_refresh_field_preview", function (fieldId) {
    259259                            let id = "mosparo-box-%s";
     
    276276            return [
    277277                'before' => '
     278                    // Remove the existing mosparo box if the initialization is executed again.
     279                    // This can happen if the form is submitted by AJAX and a validation error occurred.
     280                    if (mosparoFieldEl.querySelector(".mosparo__row") !== null) {
     281                        mosparoFieldEl.querySelector(".mosparo__row").remove();
     282                    }
     283                   
     284                    options.onGetFormData = function (formEl, formData) {
     285                        // Remove the version_hash ignored field since it was not available
     286                        // when the validation was executed.
     287                        const vhIndex = formData.ignoredFields.indexOf("version_hash");
     288                        if (vhIndex > -1) {
     289                            formData.ignoredFields.splice(vhIndex, 1);   
     290                        }
     291                       
     292                        return formData;
     293                    };
     294                   
    278295                    options.doSubmitFormInvisible = function () {
    279296                        formEl.submit();
     
    285302                        jQuery("#gform_ajax_spinner_" + formId).remove();
    286303                    };
    287                     ',
    288                 'after' => $afterCode,
     304                ',
     305                'after' => sprintf('
     306                    document.addEventListener("gform/theme/scripts_loaded", (ev) => {
     307                        gform.utils.addAsyncFilter("gform/submission/pre_submission", async (data) => {
     308                            if (typeof data.form === "undefined" || parseInt(data.form.getAttribute("data-formid")) !== %d) {
     309                                return data;
     310                            }
     311                           
     312                            // Get the ID from the form directly, because if the form is included with AJAX, the mosparo
     313                            // field receives a new ID everytime the form is submitted.
     314                            const mosparoEl = data.form.querySelector(".mosparo__container");
     315                            id = mosparoEl.getAttribute("id");
     316                           
     317                            if (typeof mosparoInstances[id] === "undefined") {
     318                                return data;
     319                            }
     320                           
     321                            if (!mosparoInstances[id].checkboxFieldElement.checked || !mosparoInstances[id].verifyCheckedFormData()) {
     322                                data.abort = true;
     323                                mosparoInstances[id].onSubmit(ev);
     324                            }
     325                           
     326                            return data;
     327                        });
     328                    });
     329                ', $field->formId) . $afterCode,
    289330            ];
    290331        }
  • mosparo-integration/trunk/mosparo-integration.php

    r3347189 r3349046  
    1515 * Author URI:        https://mosparo.io/
    1616 * License:           MIT
    17  * Version:           1.14.1
     17 * Version:           1.14.2
    1818 * Text Domain:       mosparo-integration
    1919 * Domain Path:       /languages
  • mosparo-integration/trunk/readme.txt

    r3347189 r3349046  
    55Tested up to: 6.8.1
    66Requires PHP: 7.4
    7 Stable tag: 1.14.1
     7Stable tag: 1.14.2
    88License: MIT
    99
     
    105105== Changelog ==
    106106
     107= 1.14.2 =
     108*Release Date: 23rd August 2025*
     109
     110* [Bugfix] Fixed multiple issues with the Gravity Forms module in combination with the AJAX submitting method and the invisible mosparo mode.
     111
    107112= 1.14.1 =
    108113*Release Date: 19th August 2025*
  • mosparo-integration/trunk/src/MosparoIntegration/Helper/FrontendHelper.php

    r3347189 r3349046  
    146146
    147147        return sprintf('
    148             if (typeof mosparoInstances == "undefined") {
     148            if (typeof mosparoInstances === "undefined") {
    149149                var mosparoInstances = [];
    150150            }
     
    152152            (function () {
    153153                let scriptEl = null;
    154                 if (typeof mosparo == "undefined") {
     154                if (typeof mosparo === "undefined") {
    155155                    scriptEl = document.createElement("script");
    156156                    scriptEl.setAttribute("src", "%s");
     
    158158                }
    159159               
    160                 let initializeMosparo = function () {
     160                let initializeMosparo = function (ev) {
    161161                    let id = "mosparo-box-%s";
    162162                    if (typeof mosparoInstances[id] !== "undefined") {
     
    255255                    });
    256256                   
    257                     if (typeof(gform) !== "undefined") {
     257                    if (typeof gform !== "undefined") {
    258258                        gform.addAction("gform_after_refresh_field_preview", function (fieldId) {
    259259                            let id = "mosparo-box-%s";
     
    276276            return [
    277277                'before' => '
     278                    // Remove the existing mosparo box if the initialization is executed again.
     279                    // This can happen if the form is submitted by AJAX and a validation error occurred.
     280                    if (mosparoFieldEl.querySelector(".mosparo__row") !== null) {
     281                        mosparoFieldEl.querySelector(".mosparo__row").remove();
     282                    }
     283                   
     284                    options.onGetFormData = function (formEl, formData) {
     285                        // Remove the version_hash ignored field since it was not available
     286                        // when the validation was executed.
     287                        const vhIndex = formData.ignoredFields.indexOf("version_hash");
     288                        if (vhIndex > -1) {
     289                            formData.ignoredFields.splice(vhIndex, 1);   
     290                        }
     291                       
     292                        return formData;
     293                    };
     294                   
    278295                    options.doSubmitFormInvisible = function () {
    279296                        formEl.submit();
     
    285302                        jQuery("#gform_ajax_spinner_" + formId).remove();
    286303                    };
    287                     ',
    288                 'after' => $afterCode,
     304                ',
     305                'after' => sprintf('
     306                    document.addEventListener("gform/theme/scripts_loaded", (ev) => {
     307                        gform.utils.addAsyncFilter("gform/submission/pre_submission", async (data) => {
     308                            if (typeof data.form === "undefined" || parseInt(data.form.getAttribute("data-formid")) !== %d) {
     309                                return data;
     310                            }
     311                           
     312                            // Get the ID from the form directly, because if the form is included with AJAX, the mosparo
     313                            // field receives a new ID everytime the form is submitted.
     314                            const mosparoEl = data.form.querySelector(".mosparo__container");
     315                            id = mosparoEl.getAttribute("id");
     316                           
     317                            if (typeof mosparoInstances[id] === "undefined") {
     318                                return data;
     319                            }
     320                           
     321                            if (!mosparoInstances[id].checkboxFieldElement.checked || !mosparoInstances[id].verifyCheckedFormData()) {
     322                                data.abort = true;
     323                                mosparoInstances[id].onSubmit(ev);
     324                            }
     325                           
     326                            return data;
     327                        });
     328                    });
     329                ', $field->formId) . $afterCode,
    289330            ];
    290331        }
Note: See TracChangeset for help on using the changeset viewer.