sweet-alert.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. $(function(e) {
  2. "use strict";
  3. // Message
  4. $(document).on("click", "#but1", function(e) {
  5. $('body').removeClass('timer-alert');
  6. var message = $("#message").val();
  7. if (message == "") {
  8. message = "Your message";
  9. }
  10. swal(message);
  11. });
  12. // With message and title
  13. $(document).on("click", "#but2", function(e) {
  14. $('body').removeClass('timer-alert');
  15. var message = $("#message").val();
  16. var title = $("#title").val();
  17. if (message == "") {
  18. message = "Your message";
  19. }
  20. if (title == "") {
  21. title = "Your message";
  22. }
  23. swal(title, message);
  24. });
  25. // Show image
  26. $(document).on("click", "#but3", function(e) {
  27. $('body').removeClass('timer-alert');
  28. var message = $("#message").val();
  29. var title = $("#title").val();
  30. if (message == "") {
  31. message = "Your message";
  32. }
  33. if (title == "") {
  34. title = "Your message";
  35. }
  36. swal({
  37. title: title,
  38. text: message,
  39. imageUrl: '../assets/images/brand/logo-2.png'
  40. });
  41. });
  42. // Timer
  43. $(document).on("click", "#but4", function(e) {
  44. $('body').addClass('timer-alert');
  45. var message = $("#message").val();
  46. var title = $("#title").val();
  47. if (message == "") {
  48. message = "Your message";
  49. }
  50. if (title == "") {
  51. title = "Your message";
  52. }
  53. message += "(close after 2 seconds)";
  54. swal({
  55. title: title,
  56. text: message,
  57. timer: 2000,
  58. showConfirmButton: false
  59. });
  60. });
  61. //
  62. $(document).on("click", "#click", function(e) {
  63. $('body').removeClass('timer-alert');
  64. var type = $("#type").val();
  65. swal({
  66. title: "Title",
  67. text: "Your message",
  68. type: type
  69. });
  70. });
  71. // Prompt
  72. $(document).on("click", "#prompt", function(e) {
  73. $('body').removeClass('timer-alert');
  74. swal({
  75. title: "Add",
  76. text: "Enter your message",
  77. type: "input",
  78. showCancelButton: true,
  79. closeOnConfirm: false,
  80. inputPlaceholder: "Your message"
  81. }, function(inputValue) {
  82. if (inputValue != "") {
  83. swal("Input", "You have entered : " + inputValue);
  84. }
  85. });
  86. });
  87. // Confirm
  88. $(document).on("click", "#confirm", function(e) {
  89. $('body').removeClass('timer-alert');
  90. swal({
  91. title: "Alert",
  92. text: "Are you really want to exit",
  93. type: "warning",
  94. showCancelButton: true,
  95. confirmButtonText: 'Exit',
  96. cancelButtonText: 'Stay on the page'
  97. });
  98. });
  99. $(document).on("click", "#click", function(e) {
  100. swal('Congratulations!', 'Your message has been succesfully sent', 'success');
  101. });
  102. //payment alert
  103. $(document).on("click", "#click-payment", function(e) {
  104. swal('Congratulations!', 'Your Order is Placed', 'success');
  105. });
  106. $(document).on("click", "#click1", function(e) {
  107. $('body').removeClass('timer-alert');
  108. swal({
  109. title: "Alert",
  110. text: "Waring alert",
  111. type: "warning",
  112. showCancelButton: true,
  113. confirmButtonText: 'Exit',
  114. cancelButtonText: 'Stay on the page'
  115. });
  116. });
  117. $(document).on("click", "#click2", function(e) {
  118. $('body').removeClass('timer-alert');
  119. swal({
  120. title: "Alert",
  121. text: "Danger alert",
  122. type: "error",
  123. showCancelButton: true,
  124. confirmButtonText: 'Exit',
  125. cancelButtonText: 'Stay on the page'
  126. });
  127. });
  128. $(document).on("click", "#click3", function(e) {
  129. $('body').removeClass('timer-alert');
  130. swal({
  131. title: "Alert",
  132. text: "Info alert",
  133. type: "info",
  134. showCancelButton: true,
  135. confirmButtonText: 'Exit',
  136. cancelButtonText: 'Stay on the page'
  137. });
  138. });
  139. });