File size: 2,465 Bytes
b9a69cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{% extends 'base.html' %} {% block head %}
<link rel="stylesheet" href="../static/notification.css" />
{% endblock %} {% block conteudo %}
<dialog id="modalPageCandidato">
  <div id="modal-content-page-candidato"></div>
</dialog>
<main>
  <div class="buttons">
    <button

      onclick="showToast(successMsg)"

      type="button"

      class="btn btn-success"

    >
      Success
    </button>
    <button onclick="showToast(warningMsg)" type="button" class="btn btn-info">
      Info
    </button>
    <button onclick="showToast(errorMsg)" type="button" class="btn btn-warning">
      Warning
    </button>
    <button id="modalclick">Modal</button>
  </div>
</main>
<div id="toastBoxInetum"></div>

{% endblock %} {% block finalscript %}
<script>

  let toastBox = document.getElementById("toastBoxInetum");

  let successMsg =

    '<i class="bi bi-check-circle-fill"></i> Candidato adicionado com sucesso!';

  let errorMsg =

    '<i class="bi bi-exclamation-triangle-fill"></i> Erro ao adicionar candidato!';

  let warningMsg = '<i class="bi bi-hourglass-split"></i> Iniciando...';

  function showToast(msg) {

    let toast = document.createElement("div");

    toast.classList.add("toastInetum");

    toast.innerHTML = msg;

    toastBox.appendChild(toast);



    if (msg.includes("Erro")) {

      toast.classList.add("error-proccess");

      setTimeout(() => {

        toast.style.transition = "opacity 0.5s ease";

        toast.style.opacity = 0;

        setTimeout(() => {

          toast.remove();

        }, 500);

      }, 6000);

    }

    if (msg.includes("Iniciando")) {

      toast.classList.add("warning-proccess");

      setTimeout(() => {

        toast.style.transition = "opacity 0.5s ease";

        toast.style.opacity = 0;

        setTimeout(() => {

          toast.remove();

        }, 500);

      }, 3000);

    }

    if (msg.includes("adicionado")) {

      toast.classList.add("success-proccess");

      setTimeout(() => {

        toast.style.transition = "opacity 0.4s ease";

        toast.style.opacity = 0;

        setTimeout(() => {

          toast.remove();

        }, 500);

      }, 6000);

    }

  }

</script>
<script>

  var dialog = $("#modalPageCandidato");

  var modalContent = $("#modal-content-page-candidato");

  modalContent.text("Dados atualizados com sucesso");

  $("#modalclick").click(function () {

    dialog.fadeIn();

  });

</script>
{% endblock %}