<!--
 ~ Copyright 2022 youngmonkeys.org
 ~ 
 ~ Licensed under the ezyplatform, Version 1.0.0 (the "License");
 ~ you may not use this file except in compliance with the License.
 ~ You may obtain a copy of the License at
 ~ 
 ~     https://youngmonkeys.org/licenses/ezyplatform-1.0.0.txt
 ~ 
 ~ Unless required by applicable law or agreed to in writing, software
 ~ distributed under the License is distributed on an "AS IS" BASIS,
 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ~ See the License for the specific language governing permissions and
 ~ limitations under the License.
-->

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:ezy="http://www.ezyplatform.com/thymeleaf/layout">
<body>
<th:block th:fragment="content">
    <th:block th:if="${commonFragments != null && commonFragments.get('alert') != null && commonFragments.get('alert').content != 'alert'}">
        <ezy:block ezy:utext="${commonFragments.get('alert').content}" />
    </th:block>
    <th:block th:if="${commonFragments == null || commonFragments.get('alert') == null || commonFragments.get('alert').content == 'alert'}">
        <div class="modal fade pt-4rem" role="dialog" id="global-alert-modal">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">[[#{alert}]]</h5>
                        <button type="button" class="btn-close" data-dismiss="modal" data-bs-dismiss="modal" aria-label="Close">
                        </button>
                    </div>
                    <div class="modal-body">
                        <p id="global-alert-modal-body" class="mt-3"></p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal" data-bs-dismiss="modal">
                            [[#{close}]]
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </th:block>
</th:block>
<th:block th:fragment="scripts">
    <th:block th:if="${commonFragments != null && commonFragments.get('alert') != null && !#strings.isEmpty(commonFragments.get('alert').additionalFoot)}">
        <ezy:block ezy:utext="${commonFragments.get('alert').additionalFoot}" />
    </th:block>
    <th:block th:if="${commonFragments == null || commonFragments.get('alert') == null || #strings.isEmpty(commonFragments.get('alert').additionalFoot)}">
        <script>
            var showAlert = function(message) {
                $('#global-alert-modal-body').html(message);
                $('#global-alert-modal').modal('show');
            }
        </script>
    </th:block>
</th:block>
</body>
</html>
