{#
/**
 * @file
 * Default theme implementation to display a marketo_form field.
 *
 * Available variables:
 * - forms: field items:
      - subscription_url
      - munchkin_id
      - form_id
 * - entity: items getEntity
 *
 * @ingroup themeable
 */
#}
{% for form in forms %}
    <script src="//{{ form.subscription_url }}/js/forms2/js/forms2.js"></script>
    {% if entity.parade_enable_linkedin_autofill.value %}
        <script type="IN/Form2" data-form="mktoForm_{{ form.form_id }}" data-field-firstname="FirstName" data-field-lastname="LastName" data-field-phone="MobilePhone" data-field-email="Email" data-field-company="Company" data-parade-title="Title" data-field-city="City" data-field-state="State" data-field-country="Country" data-field-zip="ZipCode"></script>
    {% endif %}
    <form id="mktoForm_{{ form.form_id }}"></form>
    {% if entity.parade_enable_confirm_message.value and entity.rendered_confirmation_message %}
        <script>
            MktoForms2.loadForm("//{{ form.subscription_url }}", "{{ form.munchkin_id }}", {{ form.form_id }}, function(form) {
                form.onSuccess(function(values, followUpUrl) {
                    form.getFormElem().hide();
                    document.getElementById('marketo_confirmform_{{ form.form_id }}').style.visibility = 'visible';
                    return false;
                });
            });
        </script>
        <div id="marketo_confirmform_{{ form.form_id }}" style="visibility: hidden;">{{ entity.rendered_confirmation_message }}</div>
    {% else %}
        <script>
            try {
                MktoForms2.loadForm("//{{ form.subscription_url }}", "{{ form.munchkin_id }}", {{ form.form_id }});
            } catch (err) {
                if (typeof MktoForms2 === "undefined") {
                    if (typeof MktoForms2 === "undefined") {
                        document.getElementById('mktoForm_{{ form.form_id }}').innerHTML = '<div role="contentinfo" aria-label="{{ "Status message"|t }}" class="messages messages--warning">' +
                            '<h2 class="visually-hidden">{{ "Status message"|t }}</h2>{{ "In case when you see this notification, that\\'s a possible sign of that you have an ad blocker feature enabled in your browser, which holds up loading this form properly. If you want to use this form to submit information to us, then we would kindly request you to take the time of changing the settings of your adblocker allowing %subscription_url. After this is done, the reloaded page should display the form properly."|t({'%subscription_url': form.subscription_url}) }}' +
                            '</div>';
                    }
                }
            }
        </script>
    {% endif %}
{% endfor %}
