sweet-alerts.init.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /******/ (function() { // webpackBootstrap
  2. var __webpack_exports__ = {};
  3. /*!*************************************************!*\
  4. !*** ./resources/js/pages/sweet-alerts.init.js ***!
  5. \*************************************************/
  6. /*
  7. Template Name: Skote - Admin & Dashboard Template
  8. Author: Themesbrand
  9. Website: https://themesbrand.com/
  10. Contact: themesbrand@gmail.com
  11. File: Sweetalert Js File
  12. */
  13. !function ($) {
  14. "use strict";
  15. var SweetAlert = function SweetAlert() {}; //examples
  16. SweetAlert.prototype.init = function () {
  17. //Basic
  18. $('#sa-basic').on('click', function () {
  19. Swal.fire({
  20. title: 'Any fool can use a computer',
  21. confirmButtonColor: '#556ee6'
  22. });
  23. }); //A title with a text under
  24. $('#sa-title').click(function () {
  25. Swal.fire({
  26. title: "The Internet?",
  27. text: 'That thing is still around?',
  28. icon: 'question',
  29. confirmButtonColor: '#556ee6'
  30. });
  31. }); //Success Message
  32. $('#sa-success').click(function () {
  33. Swal.fire({
  34. title: 'Good job!',
  35. text: 'You clicked the button!',
  36. icon: 'success',
  37. showCancelButton: true,
  38. confirmButtonColor: '#556ee6',
  39. cancelButtonColor: "#f46a6a"
  40. });
  41. }); //Warning Message
  42. $('#sa-warning').click(function () {
  43. Swal.fire({
  44. title: "Are you sure?",
  45. text: "You won't be able to revert this!",
  46. icon: "warning",
  47. showCancelButton: true,
  48. confirmButtonColor: "#34c38f",
  49. cancelButtonColor: "#f46a6a",
  50. confirmButtonText: "Yes, delete it!"
  51. }).then(function (result) {
  52. if (result.value) {
  53. Swal.fire("Deleted!", "Your file has been deleted.", "success");
  54. }
  55. });
  56. }); //Parameter
  57. $('#sa-params').click(function () {
  58. Swal.fire({
  59. title: 'Are you sure?',
  60. text: "You won't be able to revert this!",
  61. icon: 'warning',
  62. showCancelButton: true,
  63. confirmButtonText: 'Yes, delete it!',
  64. cancelButtonText: 'No, cancel!',
  65. confirmButtonClass: 'btn btn-success mt-2',
  66. cancelButtonClass: 'btn btn-danger ms-2 mt-2',
  67. buttonsStyling: false
  68. }).then(function (result) {
  69. if (result.value) {
  70. Swal.fire({
  71. title: 'Deleted!',
  72. text: 'Your file has been deleted.',
  73. icon: 'success'
  74. });
  75. } else if ( // Read more about handling dismissals
  76. result.dismiss === Swal.DismissReason.cancel) {
  77. Swal.fire({
  78. title: 'Cancelled',
  79. text: 'Your imaginary file is safe :)',
  80. icon: 'error'
  81. });
  82. }
  83. });
  84. }); //Custom Image
  85. $('#sa-image').click(function () {
  86. Swal.fire({
  87. title: 'Sweet!',
  88. text: 'Modal with a custom image.',
  89. imageUrl: 'assets/images/logo-dark.png',
  90. imageHeight: 20,
  91. confirmButtonColor: "#556ee6",
  92. animation: false
  93. });
  94. }); //Auto Close Timer
  95. $('#sa-close').click(function () {
  96. var timerInterval;
  97. Swal.fire({
  98. title: 'Auto close alert!',
  99. html: 'I will close in <strong></strong> seconds.',
  100. timer: 2000,
  101. confirmButtonColor: "#556ee6",
  102. onBeforeOpen: function onBeforeOpen() {
  103. Swal.showLoading();
  104. timerInterval = setInterval(function () {
  105. Swal.getContent().querySelector('strong').textContent = Swal.getTimerLeft();
  106. }, 100);
  107. },
  108. onClose: function onClose() {
  109. clearInterval(timerInterval);
  110. }
  111. }).then(function (result) {
  112. if ( // Read more about handling dismissals
  113. result.dismiss === Swal.DismissReason.timer) {
  114. console.log('I was closed by the timer');
  115. }
  116. });
  117. }); //custom html alert
  118. $('#custom-html-alert').click(function () {
  119. Swal.fire({
  120. title: '<i>HTML</i> <u>example</u>',
  121. icon: 'info',
  122. html: 'You can use <b>bold text</b>, ' + '<a href="//Themesbrand.in/">links</a> ' + 'and other HTML tags',
  123. showCloseButton: true,
  124. showCancelButton: true,
  125. confirmButtonClass: 'btn btn-success',
  126. cancelButtonClass: 'btn btn-danger ms-1',
  127. confirmButtonColor: "#47bd9a",
  128. cancelButtonColor: "#f46a6a",
  129. confirmButtonText: '<i class="fas fa-thumbs-up me-1"></i> Great!',
  130. cancelButtonText: '<i class="fas fa-thumbs-down"></i>'
  131. });
  132. }); //position
  133. $('#sa-position').click(function () {
  134. Swal.fire({
  135. position: 'top-end',
  136. icon: 'success',
  137. title: 'Your work has been saved',
  138. showConfirmButton: false,
  139. timer: 1500
  140. });
  141. }); //Custom width padding
  142. $('#custom-padding-width-alert').click(function () {
  143. Swal.fire({
  144. title: 'Custom width, padding, background.',
  145. width: 600,
  146. padding: 100,
  147. confirmButtonColor: "#556ee6",
  148. background: '#fff url(//subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/geometry.png)'
  149. });
  150. }); //Ajax
  151. $('#ajax-alert').click(function () {
  152. Swal.fire({
  153. title: 'Submit email to run ajax request',
  154. input: 'email',
  155. showCancelButton: true,
  156. confirmButtonText: 'Submit',
  157. showLoaderOnConfirm: true,
  158. confirmButtonColor: "#556ee6",
  159. cancelButtonColor: "#f46a6a",
  160. preConfirm: function preConfirm(email) {
  161. return new Promise(function (resolve, reject) {
  162. setTimeout(function () {
  163. if (email === 'taken@example.com') {
  164. reject('This email is already taken.');
  165. } else {
  166. resolve();
  167. }
  168. }, 2000);
  169. });
  170. },
  171. allowOutsideClick: false
  172. }).then(function (email) {
  173. Swal.fire({
  174. icon: 'success',
  175. title: 'Ajax request finished!',
  176. html: 'Submitted email: ' + email,
  177. confirmButtonColor: "#556ee6"
  178. });
  179. });
  180. }); //chaining modal alert
  181. $('#chaining-alert').click(function () {
  182. Swal.mixin({
  183. input: 'text',
  184. confirmButtonText: 'Next &rarr;',
  185. showCancelButton: true,
  186. confirmButtonColor: "#556ee6",
  187. cancelButtonColor: "#74788d",
  188. progressSteps: ['1', '2', '3']
  189. }).queue([{
  190. title: 'Question 1',
  191. text: 'Chaining swal2 modals is easy'
  192. }, 'Question 2', 'Question 3']).then(function (result) {
  193. if (result.value) {
  194. Swal.fire({
  195. title: 'All done!',
  196. html: 'Your answers: <pre><code>' + JSON.stringify(result.value) + '</code></pre>',
  197. confirmButtonText: 'Lovely!',
  198. confirmButtonColor: "#556ee6"
  199. });
  200. }
  201. });
  202. }); //Danger
  203. $('#dynamic-alert').click(function () {
  204. swal.queue([{
  205. title: 'Your public IP',
  206. confirmButtonColor: "#556ee6",
  207. confirmButtonText: 'Show my public IP',
  208. text: 'Your public IP will be received ' + 'via AJAX request',
  209. showLoaderOnConfirm: true,
  210. preConfirm: function preConfirm() {
  211. return new Promise(function (resolve) {
  212. $.get('https://api.ipify.org?format=json').done(function (data) {
  213. swal.insertQueueStep(data.ip);
  214. resolve();
  215. });
  216. });
  217. }
  218. }])["catch"](swal.noop);
  219. });
  220. }, //init
  221. $.SweetAlert = new SweetAlert(), $.SweetAlert.Constructor = SweetAlert;
  222. }(window.jQuery), //initializing
  223. function ($) {
  224. "use strict";
  225. $.SweetAlert.init();
  226. }(window.jQuery);
  227. /******/ })()
  228. ;