Dashboard sipadu mbip
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

modal.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. 'use strict';
  2. $(document).ready(function () {
  3. //Basic alert
  4. document.querySelector('.sweet-1').onclick = function(){
  5. swal("Here's a message!", "It's pretty, isn't it?")
  6. };
  7. //success message
  8. document.querySelector('.alert-success-msg').onclick = function(){
  9. swal("Good job!", "You clicked the button!", "success");
  10. };
  11. //Alert confirm
  12. document.querySelector('.alert-confirm').onclick = function(){
  13. swal({
  14. title: "Are you sure?",
  15. text: "Your will not be able to recover this imaginary file!",
  16. type: "warning",
  17. showCancelButton: true,
  18. confirmButtonClass: "btn-danger",
  19. confirmButtonText: "Yes, delete it!",
  20. closeOnConfirm: false
  21. },
  22. function(){
  23. swal("Deleted!", "Your imaginary file has been deleted.", "success");
  24. });
  25. };
  26. //Success or cancel alert
  27. document.querySelector('.alert-success-cancel').onclick = function(){
  28. swal({
  29. title: "Are you sure?",
  30. text: "You will not be able to recover this imaginary file!",
  31. type: "warning",
  32. showCancelButton: true,
  33. confirmButtonClass: "btn-danger",
  34. confirmButtonText: "Yes, delete it!",
  35. cancelButtonText: "No, cancel plx!",
  36. closeOnConfirm: false,
  37. closeOnCancel: false
  38. },
  39. function(isConfirm) {
  40. if (isConfirm) {
  41. swal("Deleted!", "Your imaginary file has been deleted.", "success");
  42. } else {
  43. swal("Cancelled", "Your imaginary file is safe :)", "error");
  44. }
  45. });
  46. };
  47. //prompt alert
  48. document.querySelector('.alert-prompt').onclick = function(){
  49. swal({
  50. title: "An input!",
  51. text: "Write something interesting:",
  52. type: "input",
  53. showCancelButton: true,
  54. closeOnConfirm: false,
  55. inputPlaceholder: "Write something"
  56. }, function (inputValue) {
  57. if (inputValue === false) return false;
  58. if (inputValue === "") {
  59. swal.showInputError("You need to write something!");
  60. return false
  61. }
  62. swal("Nice!", "You wrote: " + inputValue, "success");
  63. });
  64. };
  65. //Ajax alert
  66. document.querySelector('.alert-ajax').onclick = function(){
  67. swal({
  68. title: "Ajax request example",
  69. text: "Submit to run ajax request",
  70. type: "info",
  71. showCancelButton: true,
  72. closeOnConfirm: false,
  73. showLoaderOnConfirm: true
  74. }, function () {
  75. setTimeout(function () {
  76. swal("Ajax request finished!");
  77. }, 2000);
  78. });
  79. };
  80. $('#openBtn').on('click',function () {
  81. $('#myModal').modal({
  82. show: true
  83. })
  84. });
  85. $(document).on('show.bs.modal', '.modal', function (event) {
  86. var zIndex = 1040 + (10 * $('.modal:visible').length);
  87. $(this).css('z-index', zIndex);
  88. setTimeout(function() {
  89. $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
  90. }, 0);
  91. });
  92. });