(() => { "use strict"; MktoForms2 = window.MktoForms2; const _ = (msg) => { if (location.hash === '#debug') { console.log(msg); } }; let initCalled = false; const init = () => { if (initCalled) return; initCalled = true; if (typeof MktoForms2 === 'object') { MktoForms2.whenReady(formReadyHandler); // end form ready } else { _('MktoForms2 API not detected; exiting'); } }; const formReadyHandler = (form) => { //$('fieldset').css('border-width', '0px'); form.onValidate(function (builtInValid) { if (!builtInValid) return; form.submittable(true); if ($("input:checkbox:checked").length === 0) { _("showing error"); form.submittable(false); const cbShowError = $("input[name='LastName']").closest(".mktoFormRow"); form.showErrorMessage("Please choose at least one subscription option or unsubscribe", cbShowError); _("showed error"); } }); form.getFormElem().find('.mktoCheckboxList>label').append(''); // create spacing for checkbox label rows without affectiing togggle height if (jQuery(window).width() <= 577) { jQuery('label#optIntoMarketo, label#optIntoOutreach, label#LblUnsubscribed').parent().parent().parent().css("padding-bottom", "80px"); // .mktoForm .mktoFormRow } else { jQuery('label#optIntoMarketo, label#optIntoOutreach, label#LblUnsubscribed').parent().parent().parent().css("padding-bottom", "30px"); // .mktoForm .mktoFormRow } // toggle on/off email group checkboxes based on page tokens (onLoad) if (jQuery('span#mLead').text().length) { jQuery('#optIntoMarketo').prop('checked', true); } else { jQuery('#optIntoMarketo').prop('checked', false); } if (jQuery('span#oLead').text().length) { jQuery('#optIntoOutreach').prop('checked', true); } else { jQuery('#optIntoOutreach').prop('checked', false); } // toggle on/off email group checkboxes jQuery(':checkbox').change(function () { var Unsub = jQuery("#Unsubscribed"); var isUnsub = false; if (this.id == "Unsubscribed") { isUnsub = true; } if (isUnsub == true && Unsub.is(":checked")) { jQuery(":checkbox").not(Unsub).prop("checked", false); jQuery("#Unsubscribed").prop("checked", true); } if (isUnsub == false && jQuery(":checkbox").not(Unsub).is(":checked")) { jQuery("#Unsubscribed").prop("checked", false); // $(":checkbox").not(Unsub).prop("checked",true); } }); }; const pageshowHandler = () => { _('pageshow'); init(); }; _("adding hook for marketo handler"); window.addEventListener('pageshow', pageshowHandler); if (/complete|interactive/.test(document.readyState)) { _("page loaded, adding marketo handler"); init(); } })();