<div class="modal fade modal-clean" id="GDPRNoticeModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="vertical-alignment-helper">
        <div class="modal-dialog modal-dialog-centered" role="document" style="width:500px;">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title">@Loc.PersonalDataProtection.ToUpper() <small>(GDPR)</small></h2>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="GDPR-form">
                        <input type="hidden" id="GDPRDomainName" name="GDPRDomainName" />
                        <input type="hidden" id="GDPRUsername" name="GDPRUsername" />
                        <div class="modal-form">
                            <div class="form-group">
                                <span>
                                    <input type="checkbox" id="GDPRConfirm" name="GDPRConfirm" placeholder="@Loc.CurrentPassword" />
                                    @Html.Raw(string.Format(Loc.AgreeWithPersonalDataprotection, "https://datalab.si/politika-zasebnosti/", "http://ftp.datalab.si/Marketing/Pogodbe/2018/Posebni%20pogoji%20za%20aplikacijo%20Pantheon.pdf"))
                                </span>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-default block m-b form-submit">Nadaljuj <i id="confirmButtonIcon"></i></button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    function openGDPRNoticeModal(domainName, username) {
        if (domainName) {
            $('#GDPRNoticeModal #GDPRDomainName').val(domainName);
        }

        if (username) {
            $('#GDPRNoticeModal #GDPRUsername').val(username);
        }

        $('#GDPRNoticeModal').modal('show');
    }

    function closeGDPRNoticeModal() {
        $('#GDPRNoticeModal').modal('hide');
        $('#GDPR-form').trigger('GDPRNoticeDone');
    };

    document.addEventListener('DOMContentLoaded', function () {
        $('#GDPR-form').submit(function (e) {
            e.preventDefault();
            var form = $(this);

            if ($("#GDPRConfirm").is(":checked")) {
                $('#confirmButtonIcon').addClass('fa fa-spinner fa-spin fa-lg fa-fw');
                $.post('@Url.Action("ConfirmGDPR", "Account")', form.serialize()).done(function (data) {
                    $('#confirmButtonIcon').removeClass('fa fa-spinner fa-spin fa-lg fa-fw');

                    if (data === true) {
                        closeGDPRNoticeModal();
                    }
                }).fail(function () {
                    $('#confirmButtonIcon').removeClass('fa fa-spinner fa-spin fa-lg fa-fw');
                });
            } else {
                closeGDPRNoticeModal();
            }
        });
    }, false);
</script>