toastr.min.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Note that this is toastr v2.1.3, the "latest" version in url has no more maintenance,
  3. * please go to https://cdnjs.com/libraries/toastr.js and pick a certain version you want to use,
  4. * make sure you copy the url from the website since the url may change between versions.
  5. * */
  6. !function (e) {
  7. e(["jquery"], function (e) {
  8. return function () {
  9. function t(e, t, n) {
  10. return g({type: O.error, iconClass: m().iconClasses.error, message: e, optionsOverride: n, title: t})
  11. }
  12. function n(t, n) {
  13. return t || (t = m()), v = e("#" + t.containerId), v.length ? v : (n && (v = d(t)), v)
  14. }
  15. function o(e, t, n) {
  16. return g({type: O.info, iconClass: m().iconClasses.info, message: e, optionsOverride: n, title: t})
  17. }
  18. function s(e) {
  19. C = e
  20. }
  21. function i(e, t, n) {
  22. return g({
  23. type: O.success,
  24. iconClass: m().iconClasses.success,
  25. message: e,
  26. optionsOverride: n,
  27. title: t
  28. })
  29. }
  30. function a(e, t, n) {
  31. return g({
  32. type: O.warning,
  33. iconClass: m().iconClasses.warning,
  34. message: e,
  35. optionsOverride: n,
  36. title: t
  37. })
  38. }
  39. function r(e, t) {
  40. var o = m();
  41. v || n(o), u(e, o, t) || l(o)
  42. }
  43. function c(t) {
  44. var o = m();
  45. return v || n(o), t && 0 === e(":focus", t).length ? void h(t) : void (v.children().length && v.remove())
  46. }
  47. function l(t) {
  48. for (var n = v.children(), o = n.length - 1; o >= 0; o--) u(e(n[o]), t)
  49. }
  50. function u(t, n, o) {
  51. var s = !(!o || !o.force) && o.force;
  52. return !(!t || !s && 0 !== e(":focus", t).length) && (t[n.hideMethod]({
  53. duration: n.hideDuration,
  54. easing: n.hideEasing,
  55. complete: function () {
  56. h(t)
  57. }
  58. }), !0)
  59. }
  60. function d(t) {
  61. return v = e("<div/>").attr("id", t.containerId).addClass(t.positionClass), v.appendTo(e(t.target)), v
  62. }
  63. function p() {
  64. return {
  65. tapToDismiss: !0,
  66. toastClass: "toast",
  67. containerId: "toast-container",
  68. debug: !1,
  69. showMethod: "fadeIn",
  70. showDuration: 300,
  71. showEasing: "swing",
  72. onShown: void 0,
  73. hideMethod: "fadeOut",
  74. hideDuration: 1e3,
  75. hideEasing: "swing",
  76. onHidden: void 0,
  77. closeMethod: !1,
  78. closeDuration: !1,
  79. closeEasing: !1,
  80. closeOnHover: !0,
  81. extendedTimeOut: 1e3,
  82. iconClasses: {
  83. error: "toast-error",
  84. info: "toast-info",
  85. success: "toast-success",
  86. warning: "toast-warning"
  87. },
  88. iconClass: "toast-info",
  89. positionClass: "toast-top-right",
  90. timeOut: 5e3,
  91. titleClass: "toast-title",
  92. messageClass: "toast-message",
  93. escapeHtml: !1,
  94. target: "body",
  95. closeHtml: '<button type="button">&times;</button>',
  96. closeClass: "toast-close-button",
  97. newestOnTop: !0,
  98. preventDuplicates: !1,
  99. progressBar: !1,
  100. progressClass: "toast-progress",
  101. rtl: !1
  102. }
  103. }
  104. function f(e) {
  105. C && C(e)
  106. }
  107. function g(t) {
  108. function o(e) {
  109. return null == e && (e = ""), e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
  110. }
  111. function s() {
  112. c(), u(), d(), p(), g(), C(), l(), i()
  113. }
  114. function i() {
  115. var e = "";
  116. switch (t.iconClass) {
  117. case"toast-success":
  118. case"toast-info":
  119. e = "polite";
  120. break;
  121. default:
  122. e = "assertive"
  123. }
  124. I.attr("aria-live", e)
  125. }
  126. function a() {
  127. E.closeOnHover && I.hover(H, D), !E.onclick && E.tapToDismiss && I.click(b), E.closeButton && j && j.click(function (e) {
  128. e.stopPropagation ? e.stopPropagation() : void 0 !== e.cancelBubble && e.cancelBubble !== !0 && (e.cancelBubble = !0), E.onCloseClick && E.onCloseClick(e), b(!0)
  129. }), E.onclick && I.click(function (e) {
  130. E.onclick(e), b()
  131. })
  132. }
  133. function r() {
  134. I.hide(), I[E.showMethod]({
  135. duration: E.showDuration,
  136. easing: E.showEasing,
  137. complete: E.onShown
  138. }), E.timeOut > 0 && (k = setTimeout(b, E.timeOut), F.maxHideTime = parseFloat(E.timeOut), F.hideEta = (new Date).getTime() + F.maxHideTime, E.progressBar && (F.intervalId = setInterval(x, 10)))
  139. }
  140. function c() {
  141. t.iconClass && I.addClass(E.toastClass).addClass(y)
  142. }
  143. function l() {
  144. E.newestOnTop ? v.prepend(I) : v.append(I)
  145. }
  146. function u() {
  147. if (t.title) {
  148. var e = t.title;
  149. E.escapeHtml && (e = o(t.title)), M.append(e).addClass(E.titleClass), I.append(M)
  150. }
  151. }
  152. function d() {
  153. if (t.message) {
  154. var e = t.message;
  155. E.escapeHtml && (e = o(t.message)), B.append(e).addClass(E.messageClass), I.append(B)
  156. }
  157. }
  158. function p() {
  159. E.closeButton && (j.addClass(E.closeClass).attr("role", "button"), I.prepend(j))
  160. }
  161. function g() {
  162. E.progressBar && (q.addClass(E.progressClass), I.prepend(q))
  163. }
  164. function C() {
  165. E.rtl && I.addClass("rtl")
  166. }
  167. function O(e, t) {
  168. if (e.preventDuplicates) {
  169. if (t.message === w) return !0;
  170. w = t.message
  171. }
  172. return !1
  173. }
  174. function b(t) {
  175. var n = t && E.closeMethod !== !1 ? E.closeMethod : E.hideMethod,
  176. o = t && E.closeDuration !== !1 ? E.closeDuration : E.hideDuration,
  177. s = t && E.closeEasing !== !1 ? E.closeEasing : E.hideEasing;
  178. if (!e(":focus", I).length || t) return clearTimeout(F.intervalId), I[n]({
  179. duration: o,
  180. easing: s,
  181. complete: function () {
  182. h(I), clearTimeout(k), E.onHidden && "hidden" !== P.state && E.onHidden(), P.state = "hidden", P.endTime = new Date, f(P)
  183. }
  184. })
  185. }
  186. function D() {
  187. (E.timeOut > 0 || E.extendedTimeOut > 0) && (k = setTimeout(b, E.extendedTimeOut), F.maxHideTime = parseFloat(E.extendedTimeOut), F.hideEta = (new Date).getTime() + F.maxHideTime)
  188. }
  189. function H() {
  190. clearTimeout(k), F.hideEta = 0, I.stop(!0, !0)[E.showMethod]({
  191. duration: E.showDuration,
  192. easing: E.showEasing
  193. })
  194. }
  195. function x() {
  196. var e = (F.hideEta - (new Date).getTime()) / F.maxHideTime * 100;
  197. q.width(e + "%")
  198. }
  199. var E = m(), y = t.iconClass || E.iconClass;
  200. if ("undefined" != typeof t.optionsOverride && (E = e.extend(E, t.optionsOverride), y = t.optionsOverride.iconClass || y), !O(E, t)) {
  201. T++, v = n(E, !0);
  202. var k = null, I = e("<div/>"), M = e("<div/>"), B = e("<div/>"), q = e("<div/>"),
  203. j = e(E.closeHtml), F = {intervalId: null, hideEta: null, maxHideTime: null},
  204. P = {toastId: T, state: "visible", startTime: new Date, options: E, map: t};
  205. return s(), r(), a(), f(P), E.debug && console && console.log(P), I
  206. }
  207. }
  208. function m() {
  209. return e.extend({}, p(), b.options)
  210. }
  211. function h(e) {
  212. v || (v = n()), e.is(":visible") || (e.remove(), e = null, 0 === v.children().length && (v.remove(), w = void 0))
  213. }
  214. var v, C, w, T = 0, O = {error: "error", info: "info", success: "success", warning: "warning"}, b = {
  215. clear: r,
  216. remove: c,
  217. error: t,
  218. getContainer: n,
  219. info: o,
  220. options: {},
  221. subscribe: s,
  222. success: i,
  223. version: "2.1.3",
  224. warning: a
  225. };
  226. return b
  227. }()
  228. })
  229. }("function" == typeof define && define.amd ? define : function (e, t) {
  230. "undefined" != typeof module && module.exports ? module.exports = t(require("jquery")) : window.toastr = t(window.jQuery)
  231. });
  232. //# sourceMappingURL=toastr.js.map