bootbox-sweetalert.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/advanced/bootbox-sweetalert", ["jquery", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(require("jquery"), require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(global.jQuery, global.Site);
  11. global.advancedBootboxSweetalert = mod.exports;
  12. }
  13. })(this, function (_jquery, _Site) {
  14. "use strict";
  15. _jquery = babelHelpers.interopRequireDefault(_jquery);
  16. (0, _jquery.default)(document).ready(function ($$$1) {
  17. (0, _Site.run)();
  18. }); // $('#exampleModal').on('show.bs.modal', function(event) {
  19. // var button = $(event.relatedTarget);
  20. // var recipient = button.data('whatever');
  21. // var modal = $(this);
  22. // modal.find('.modal-title').text('New message to ' + recipient);
  23. // modal.find('.modal-body input').val(recipient);
  24. // });
  25. window.exampleBootboxAlertCallback = function () {
  26. toastr.info("Hello world callback");
  27. };
  28. window.exampleBootboxConfirmCallback = function (result) {
  29. toastr.info("Confirm result: " + result);
  30. };
  31. window.exampleBootboxPromptCallback = function (result) {
  32. if (result === null) {
  33. toastr.info("Prompt dismissed");
  34. } else {
  35. toastr.info("Hi <b>" + result + "</b>");
  36. }
  37. }; // Example Examples
  38. // ----------------
  39. (function () {
  40. (0, _jquery.default)('#exampleBootboxPromptDefaultValue').on('click', function () {
  41. bootbox.prompt({
  42. title: "What is your real name?",
  43. value: "makeusabrew",
  44. callback: function callback(result) {
  45. if (result === null) {
  46. toastr.info("Prompt dismissed");
  47. } else {
  48. toastr.info("Hi <b>" + result + "</b>");
  49. }
  50. }
  51. });
  52. });
  53. (0, _jquery.default)('#exampleBootboxCustomDialog').on('click', function () {
  54. bootbox.dialog({
  55. message: "I am a custom dialog",
  56. title: "Custom title",
  57. buttons: {
  58. success: {
  59. label: "Success!",
  60. className: "btn-success",
  61. callback: function callback() {
  62. toastr.info("great success");
  63. }
  64. },
  65. danger: {
  66. label: "Danger!",
  67. className: "btn-danger",
  68. callback: function callback() {
  69. toastr.info("uh oh, look out!");
  70. }
  71. },
  72. main: {
  73. label: "Click ME!",
  74. className: "btn-primary",
  75. callback: function callback() {
  76. toastr.info("Primary button");
  77. }
  78. }
  79. }
  80. });
  81. });
  82. (0, _jquery.default)('#exampleBootboxCustomHtmlContents').on('click', function () {
  83. bootbox.dialog({
  84. title: "That html",
  85. message: 'You can also use <b>html</b>'
  86. });
  87. });
  88. (0, _jquery.default)('#exampleBootboxCustomHtmlForms').on('click', function () {
  89. bootbox.dialog({
  90. title: "This is a form in a modal.",
  91. message: '<form class="form-horizontal">' + '<div class="form-group row">' + '<label class="col-md-4 form-control-label" for="name">Name</label>' + '<div class="col-md-6">' + '<input type="text" class="form-control input-md" id="name" name="name" placeholder="Your name"> ' + '<span class="text-help">Here goes your name</span></div>' + '</div>' + '<div class="form-group row">' + '<label class="col-md-4 form-control-label" for="awesomeness">How awesome is this?</label>' + '<div class="col-md-6"><div class="radio-custom radio-primary">' + '<input type="radio" name="awesomeness" id="awesomeness-0" value="Really awesome" checked>' + '<label for="awesomeness-0">Really awesome </label>' + '</div><div class="radio-custom radio-primary">' + '<input type="radio" name="awesomeness" id="awesomeness-1" value="Super awesome">' + '<label for="awesomeness-1">Super awesome </label>' + '</div>' + '</div></div>' + '</form>',
  92. buttons: {
  93. success: {
  94. label: "Save",
  95. className: "btn-success",
  96. callback: function callback() {
  97. var name = (0, _jquery.default)('#name').val();
  98. var answer = (0, _jquery.default)("input[name='awesomeness']:checked").val();
  99. toastr.info("Hello " + name + ". You've chosen <b>" + answer + "</b>");
  100. }
  101. }
  102. }
  103. });
  104. });
  105. })(); // Example Styles
  106. // --------------
  107. (function () {
  108. (0, _jquery.default)('#exampleSuccessMessage').on("click", function () {
  109. swal({
  110. title: "Good job!",
  111. text: "You clicked the button!",
  112. type: "success",
  113. showCancelButton: false,
  114. confirmButtonClass: "btn-success",
  115. confirmButtonText: 'OK',
  116. closeOnConfirm: false
  117. });
  118. });
  119. (0, _jquery.default)('#exampleWarningConfirm').on("click", function () {
  120. swal({
  121. title: "Are you sure?",
  122. text: "You will not be able to recover this imaginary file!",
  123. type: "warning",
  124. showCancelButton: true,
  125. confirmButtonClass: "btn-warning",
  126. confirmButtonText: 'Yes, delete it!',
  127. closeOnConfirm: false //closeOnCancel: false
  128. }, function () {
  129. swal("Deleted!", "Your imaginary file has been deleted!", "success");
  130. });
  131. });
  132. (0, _jquery.default)('#exampleWarningCancel').on("click", function () {
  133. swal({
  134. title: "Are you sure?",
  135. text: "You will not be able to recover this imaginary file!",
  136. type: "warning",
  137. showCancelButton: true,
  138. confirmButtonClass: "btn-warning",
  139. confirmButtonText: 'Yes, delete it!',
  140. cancelButtonText: "No, cancel plx!",
  141. closeOnConfirm: false,
  142. closeOnCancel: false
  143. }, function (isConfirm) {
  144. if (isConfirm) {
  145. swal("Deleted!", "Your imaginary file has been deleted!", "success");
  146. } else {
  147. swal("Cancelled", "Your imaginary file is safe :)", "error");
  148. }
  149. });
  150. });
  151. })();
  152. });