fixed:重新导入okToastr源码
parent
6915d8a0a9
commit
d7cf8e5bdb
|
|
@ -410,11 +410,11 @@
|
|||
"href": "pages/tripartite/countup.html"
|
||||
},
|
||||
{
|
||||
"title": "toastr.js",
|
||||
"title": "okToastr.js",
|
||||
"href": "pages/tripartite/okToastr.html"
|
||||
},
|
||||
{
|
||||
"title": "md5.js",
|
||||
"title": "okMd5.js",
|
||||
"href": "pages/tripartite/okMd5.html"
|
||||
},
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,533 +1,494 @@
|
|||
/*
|
||||
* Note that this is toastr v2.1.3, the "latest" version in url has no more maintenance,
|
||||
* please go to https://cdnjs.com/libraries/toastr.js and pick a certain version you want to use,
|
||||
* make sure you copy the url from the website since the url may change between versions.
|
||||
* */
|
||||
!function (e) {
|
||||
e(["jquery"], function (e) {
|
||||
return function () {
|
||||
function t(e, t, n) {
|
||||
return g({type: O.error, iconClass: m().iconClasses.error, message: e, optionsOverride: n, title: t})
|
||||
* Toastr
|
||||
* Copyright 2012-2015
|
||||
* Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
|
||||
* All Rights Reserved.
|
||||
* Use, reproduction, distribution, and modification of this code is subject to the terms and
|
||||
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* ARIA Support: Greta Krafsig
|
||||
*
|
||||
* Project: https://github.com/CodeSeven/toastr
|
||||
*/
|
||||
/* global define */
|
||||
(function (define) {
|
||||
define(['jquery'], function ($) {
|
||||
return (function () {
|
||||
var $container;
|
||||
var listener;
|
||||
var toastId = 0;
|
||||
var toastType = {
|
||||
error: 'error',
|
||||
info: 'info',
|
||||
success: 'success',
|
||||
warning: 'warning'
|
||||
};
|
||||
|
||||
var toastr = {
|
||||
clear: clear,
|
||||
remove: remove,
|
||||
error: error,
|
||||
getContainer: getContainer,
|
||||
info: info,
|
||||
options: {},
|
||||
subscribe: subscribe,
|
||||
success: success,
|
||||
version: '2.1.4',
|
||||
warning: warning
|
||||
};
|
||||
|
||||
var previousToast;
|
||||
|
||||
return toastr;
|
||||
|
||||
////////////////
|
||||
|
||||
function error(message, title, optionsOverride) {
|
||||
return notify({
|
||||
type: toastType.error,
|
||||
iconClass: getOptions().iconClasses.error,
|
||||
message: message,
|
||||
optionsOverride: optionsOverride,
|
||||
title: title
|
||||
});
|
||||
}
|
||||
|
||||
function n(t, n) {
|
||||
return t || (t = m()), v = e("#" + t.containerId), v.length ? v : (n && (v = d(t)), v)
|
||||
function getContainer(options, create) {
|
||||
if (!options) {
|
||||
options = getOptions();
|
||||
}
|
||||
$container = $('#' + options.containerId);
|
||||
if ($container.length) {
|
||||
return $container;
|
||||
}
|
||||
if (create) {
|
||||
$container = createContainer(options);
|
||||
}
|
||||
return $container;
|
||||
}
|
||||
|
||||
function o(e, t, n) {
|
||||
return g({type: O.info, iconClass: m().iconClasses.info, message: e, optionsOverride: n, title: t})
|
||||
function info(message, title, optionsOverride) {
|
||||
return notify({
|
||||
type: toastType.info,
|
||||
iconClass: getOptions().iconClasses.info,
|
||||
message: message,
|
||||
optionsOverride: optionsOverride,
|
||||
title: title
|
||||
});
|
||||
}
|
||||
|
||||
function s(e) {
|
||||
C = e
|
||||
function subscribe(callback) {
|
||||
listener = callback;
|
||||
}
|
||||
|
||||
function i(e, t, n) {
|
||||
return g({
|
||||
type: O.success,
|
||||
iconClass: m().iconClasses.success,
|
||||
message: e,
|
||||
optionsOverride: n,
|
||||
title: t
|
||||
})
|
||||
function success(message, title, optionsOverride) {
|
||||
return notify({
|
||||
type: toastType.success,
|
||||
iconClass: getOptions().iconClasses.success,
|
||||
message: message,
|
||||
optionsOverride: optionsOverride,
|
||||
title: title
|
||||
});
|
||||
}
|
||||
|
||||
function a(e, t, n) {
|
||||
return g({
|
||||
type: O.warning,
|
||||
iconClass: m().iconClasses.warning,
|
||||
message: e,
|
||||
optionsOverride: n,
|
||||
title: t
|
||||
})
|
||||
function warning(message, title, optionsOverride) {
|
||||
return notify({
|
||||
type: toastType.warning,
|
||||
iconClass: getOptions().iconClasses.warning,
|
||||
message: message,
|
||||
optionsOverride: optionsOverride,
|
||||
title: title
|
||||
});
|
||||
}
|
||||
|
||||
function r(e, t) {
|
||||
var o = m();
|
||||
v || n(o), u(e, o, t) || l(o)
|
||||
function clear($toastElement, clearOptions) {
|
||||
var options = getOptions();
|
||||
if (!$container) {
|
||||
getContainer(options);
|
||||
}
|
||||
if (!clearToast($toastElement, options, clearOptions)) {
|
||||
clearContainer(options);
|
||||
}
|
||||
}
|
||||
|
||||
function c(t) {
|
||||
var o = m();
|
||||
return v || n(o), t && 0 === e(":focus", t).length ? void h(t) : void (v.children().length && v.remove())
|
||||
function remove($toastElement) {
|
||||
var options = getOptions();
|
||||
if (!$container) {
|
||||
getContainer(options);
|
||||
}
|
||||
if ($toastElement && $(':focus', $toastElement).length === 0) {
|
||||
removeToast($toastElement);
|
||||
return;
|
||||
}
|
||||
if ($container.children().length) {
|
||||
$container.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function l(t) {
|
||||
for (var n = v.children(), o = n.length - 1; o >= 0; o--) u(e(n[o]), t)
|
||||
// internal functions
|
||||
|
||||
function clearContainer(options) {
|
||||
var toastsToClear = $container.children();
|
||||
for (var i = toastsToClear.length - 1; i >= 0; i--) {
|
||||
clearToast($(toastsToClear[i]), options);
|
||||
}
|
||||
}
|
||||
|
||||
function u(t, n, o) {
|
||||
var s = !(!o || !o.force) && o.force;
|
||||
return !(!t || !s && 0 !== e(":focus", t).length) && (t[n.hideMethod]({
|
||||
duration: n.hideDuration,
|
||||
easing: n.hideEasing,
|
||||
complete: function () {
|
||||
h(t)
|
||||
}
|
||||
}), !0)
|
||||
function clearToast($toastElement, options, clearOptions) {
|
||||
var force = clearOptions && clearOptions.force ? clearOptions.force : false;
|
||||
if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
|
||||
$toastElement[options.hideMethod]({
|
||||
duration: options.hideDuration,
|
||||
easing: options.hideEasing,
|
||||
complete: function () {
|
||||
removeToast($toastElement);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function d(t) {
|
||||
return v = e("<div/>").attr("id", t.containerId).addClass(t.positionClass), v.appendTo(e(t.target)), v
|
||||
function createContainer(options) {
|
||||
$container = $('<div/>')
|
||||
.attr('id', options.containerId)
|
||||
.addClass(options.positionClass);
|
||||
|
||||
$container.appendTo($(options.target));
|
||||
return $container;
|
||||
}
|
||||
|
||||
function p() {
|
||||
function getDefaults() {
|
||||
return {
|
||||
tapToDismiss: !0,
|
||||
toastClass: "toast",
|
||||
containerId: "toast-container",
|
||||
debug: !1,
|
||||
showMethod: "fadeIn",
|
||||
tapToDismiss: true,
|
||||
toastClass: 'toast',
|
||||
containerId: 'toast-container',
|
||||
debug: false,
|
||||
|
||||
showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
|
||||
showDuration: 300,
|
||||
showEasing: "swing",
|
||||
onShown: void 0,
|
||||
hideMethod: "fadeOut",
|
||||
hideDuration: 1e3,
|
||||
hideEasing: "swing",
|
||||
onHidden: void 0,
|
||||
closeMethod: !1,
|
||||
closeDuration: !1,
|
||||
closeEasing: !1,
|
||||
closeOnHover: !0,
|
||||
extendedTimeOut: 1e3,
|
||||
showEasing: 'swing', //swing and linear are built into jQuery
|
||||
onShown: undefined,
|
||||
hideMethod: 'fadeOut',
|
||||
hideDuration: 1000,
|
||||
hideEasing: 'swing',
|
||||
onHidden: undefined,
|
||||
closeMethod: false,
|
||||
closeDuration: false,
|
||||
closeEasing: false,
|
||||
closeOnHover: true,
|
||||
|
||||
extendedTimeOut: 1000,
|
||||
iconClasses: {
|
||||
error: "toast-error",
|
||||
info: "toast-info",
|
||||
success: "toast-success",
|
||||
warning: "toast-warning"
|
||||
error: 'toast-error',
|
||||
info: 'toast-info',
|
||||
success: 'toast-success',
|
||||
warning: 'toast-warning'
|
||||
},
|
||||
iconClass: "toast-info",
|
||||
positionClass: "toast-top-right",
|
||||
timeOut: 5e3,
|
||||
titleClass: "toast-title",
|
||||
messageClass: "toast-message",
|
||||
escapeHtml: !1,
|
||||
target: "body",
|
||||
iconClass: 'toast-info',
|
||||
positionClass: 'toast-top-right',
|
||||
timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
|
||||
titleClass: 'toast-title',
|
||||
messageClass: 'toast-message',
|
||||
escapeHtml: false,
|
||||
target: 'body',
|
||||
closeHtml: '<button type="button">×</button>',
|
||||
closeClass: "toast-close-button",
|
||||
newestOnTop: !0,
|
||||
preventDuplicates: !1,
|
||||
progressBar: !1,
|
||||
progressClass: "toast-progress",
|
||||
rtl: !1
|
||||
}
|
||||
closeClass: 'toast-close-button',
|
||||
newestOnTop: true,
|
||||
preventDuplicates: false,
|
||||
progressBar: false,
|
||||
progressClass: 'toast-progress',
|
||||
rtl: false
|
||||
};
|
||||
}
|
||||
|
||||
function f(e) {
|
||||
C && C(e)
|
||||
function publish(args) {
|
||||
if (!listener) {
|
||||
return;
|
||||
}
|
||||
listener(args);
|
||||
}
|
||||
|
||||
function g(t) {
|
||||
function o(e) {
|
||||
return null == e && (e = ""), e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">")
|
||||
function notify(map) {
|
||||
var options = getOptions();
|
||||
var iconClass = map.iconClass || options.iconClass;
|
||||
|
||||
if (typeof (map.optionsOverride) !== 'undefined') {
|
||||
options = $.extend(options, map.optionsOverride);
|
||||
iconClass = map.optionsOverride.iconClass || iconClass;
|
||||
}
|
||||
|
||||
function s() {
|
||||
c(), u(), d(), p(), g(), C(), l(), i()
|
||||
if (shouldExit(options, map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function i() {
|
||||
var e = "";
|
||||
switch (t.iconClass) {
|
||||
case"toast-success":
|
||||
case"toast-info":
|
||||
e = "polite";
|
||||
toastId++;
|
||||
|
||||
$container = getContainer(options, true);
|
||||
|
||||
var intervalId = null;
|
||||
var $toastElement = $('<div/>');
|
||||
var $titleElement = $('<div/>');
|
||||
var $messageElement = $('<div/>');
|
||||
var $progressElement = $('<div/>');
|
||||
var $closeElement = $(options.closeHtml);
|
||||
var progressBar = {
|
||||
intervalId: null,
|
||||
hideEta: null,
|
||||
maxHideTime: null
|
||||
};
|
||||
var response = {
|
||||
toastId: toastId,
|
||||
state: 'visible',
|
||||
startTime: new Date(),
|
||||
options: options,
|
||||
map: map
|
||||
};
|
||||
|
||||
personalizeToast();
|
||||
|
||||
displayToast();
|
||||
|
||||
handleEvents();
|
||||
|
||||
publish(response);
|
||||
|
||||
if (options.debug && console) {
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
return $toastElement;
|
||||
|
||||
function escapeHtml(source) {
|
||||
if (source == null) {
|
||||
source = '';
|
||||
}
|
||||
|
||||
return source
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
}
|
||||
|
||||
function personalizeToast() {
|
||||
setIcon();
|
||||
setTitle();
|
||||
setMessage();
|
||||
setCloseButton();
|
||||
setProgressBar();
|
||||
setRTL();
|
||||
setSequence();
|
||||
setAria();
|
||||
}
|
||||
|
||||
function setAria() {
|
||||
var ariaValue = '';
|
||||
switch (map.iconClass) {
|
||||
case 'toast-success':
|
||||
case 'toast-info':
|
||||
ariaValue = 'polite';
|
||||
break;
|
||||
default:
|
||||
e = "assertive"
|
||||
ariaValue = 'assertive';
|
||||
}
|
||||
I.attr("aria-live", e)
|
||||
$toastElement.attr('aria-live', ariaValue);
|
||||
}
|
||||
|
||||
function a() {
|
||||
E.closeOnHover && I.hover(H, D), !E.onclick && E.tapToDismiss && I.click(b), E.closeButton && j && j.click(function (e) {
|
||||
e.stopPropagation ? e.stopPropagation() : void 0 !== e.cancelBubble && e.cancelBubble !== !0 && (e.cancelBubble = !0), E.onCloseClick && E.onCloseClick(e), b(!0)
|
||||
}), E.onclick && I.click(function (e) {
|
||||
E.onclick(e), b()
|
||||
})
|
||||
}
|
||||
function handleEvents() {
|
||||
if (options.closeOnHover) {
|
||||
$toastElement.hover(stickAround, delayedHideToast);
|
||||
}
|
||||
|
||||
function r() {
|
||||
I.hide(), I[E.showMethod]({
|
||||
duration: E.showDuration,
|
||||
easing: E.showEasing,
|
||||
complete: E.onShown
|
||||
}), 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)))
|
||||
}
|
||||
if (!options.onclick && options.tapToDismiss) {
|
||||
$toastElement.click(hideToast);
|
||||
}
|
||||
|
||||
function c() {
|
||||
t.iconClass && I.addClass(E.toastClass).addClass(y)
|
||||
}
|
||||
if (options.closeButton && $closeElement) {
|
||||
$closeElement.click(function (event) {
|
||||
if (event.stopPropagation) {
|
||||
event.stopPropagation();
|
||||
} else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
|
||||
event.cancelBubble = true;
|
||||
}
|
||||
|
||||
function l() {
|
||||
E.newestOnTop ? v.prepend(I) : v.append(I)
|
||||
}
|
||||
if (options.onCloseClick) {
|
||||
options.onCloseClick(event);
|
||||
}
|
||||
|
||||
function u() {
|
||||
if (t.title) {
|
||||
var e = t.title;
|
||||
E.escapeHtml && (e = o(t.title)), M.append(e).addClass(E.titleClass), I.append(M)
|
||||
hideToast(true);
|
||||
});
|
||||
}
|
||||
|
||||
if (options.onclick) {
|
||||
$toastElement.click(function (event) {
|
||||
options.onclick(event);
|
||||
hideToast();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function d() {
|
||||
if (t.message) {
|
||||
var e = t.message;
|
||||
E.escapeHtml && (e = o(t.message)), B.append(e).addClass(E.messageClass), I.append(B)
|
||||
}
|
||||
}
|
||||
function displayToast() {
|
||||
$toastElement.hide();
|
||||
|
||||
function p() {
|
||||
E.closeButton && (j.addClass(E.closeClass).attr("role", "button"), I.prepend(j))
|
||||
}
|
||||
$toastElement[options.showMethod](
|
||||
{duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
|
||||
);
|
||||
|
||||
function g() {
|
||||
E.progressBar && (q.addClass(E.progressClass), I.prepend(q))
|
||||
}
|
||||
|
||||
function C() {
|
||||
E.rtl && I.addClass("rtl")
|
||||
}
|
||||
|
||||
function O(e, t) {
|
||||
if (e.preventDuplicates) {
|
||||
if (t.message === w) return !0;
|
||||
w = t.message
|
||||
}
|
||||
return !1
|
||||
}
|
||||
|
||||
function b(t) {
|
||||
var n = t && E.closeMethod !== !1 ? E.closeMethod : E.hideMethod,
|
||||
o = t && E.closeDuration !== !1 ? E.closeDuration : E.hideDuration,
|
||||
s = t && E.closeEasing !== !1 ? E.closeEasing : E.hideEasing;
|
||||
if (!e(":focus", I).length || t) return clearTimeout(F.intervalId), I[n]({
|
||||
duration: o,
|
||||
easing: s,
|
||||
complete: function () {
|
||||
h(I), clearTimeout(k), E.onHidden && "hidden" !== P.state && E.onHidden(), P.state = "hidden", P.endTime = new Date, f(P)
|
||||
if (options.timeOut > 0) {
|
||||
intervalId = setTimeout(hideToast, options.timeOut);
|
||||
progressBar.maxHideTime = parseFloat(options.timeOut);
|
||||
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
||||
if (options.progressBar) {
|
||||
progressBar.intervalId = setInterval(updateProgress, 10);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function D() {
|
||||
(E.timeOut > 0 || E.extendedTimeOut > 0) && (k = setTimeout(b, E.extendedTimeOut), F.maxHideTime = parseFloat(E.extendedTimeOut), F.hideEta = (new Date).getTime() + F.maxHideTime)
|
||||
}
|
||||
|
||||
function H() {
|
||||
clearTimeout(k), F.hideEta = 0, I.stop(!0, !0)[E.showMethod]({
|
||||
duration: E.showDuration,
|
||||
easing: E.showEasing
|
||||
})
|
||||
}
|
||||
|
||||
function x() {
|
||||
var e = (F.hideEta - (new Date).getTime()) / F.maxHideTime * 100;
|
||||
q.width(e + "%")
|
||||
}
|
||||
|
||||
var E = m(), y = t.iconClass || E.iconClass;
|
||||
if ("undefined" != typeof t.optionsOverride && (E = e.extend(E, t.optionsOverride), y = t.optionsOverride.iconClass || y), !O(E, t)) {
|
||||
T++, v = n(E, !0);
|
||||
var k = null, I = e("<div/>"), M = e("<div/>"), B = e("<div/>"), q = e("<div/>"),
|
||||
j = e(E.closeHtml), F = {intervalId: null, hideEta: null, maxHideTime: null},
|
||||
P = {toastId: T, state: "visible", startTime: new Date, options: E, map: t};
|
||||
return s(), r(), a(), f(P), E.debug && console && console.log(P), I
|
||||
}
|
||||
}
|
||||
|
||||
function m() {
|
||||
return e.extend({}, p(), b.options)
|
||||
}
|
||||
|
||||
function h(e) {
|
||||
v || (v = n()), e.is(":visible") || (e.remove(), e = null, 0 === v.children().length && (v.remove(), w = void 0))
|
||||
}
|
||||
|
||||
var v, C, w, T = 0, O = {error: "error", info: "info", success: "success", warning: "warning"}, b = {
|
||||
clear: r,
|
||||
remove: c,
|
||||
error: t,
|
||||
getContainer: n,
|
||||
info: o,
|
||||
options: {},
|
||||
subscribe: s,
|
||||
success: i,
|
||||
version: "2.1.3",
|
||||
warning: a
|
||||
};
|
||||
return b
|
||||
}()
|
||||
})
|
||||
}("function" == typeof define && define.amd ? define : function (e, t) {
|
||||
"undefined" != typeof module && module.exports ? module.exports = t(require("jquery")) : window.toastr = t(window.jQuery)
|
||||
});
|
||||
//# sourceMappingURL=toastr.js.map
|
||||
/*
|
||||
* Note that this is toastr v2.1.3, the "latest" version in url has no more maintenance,
|
||||
* please go to https://cdnjs.com/libraries/toastr.js and pick a certain version you want to use,
|
||||
* make sure you copy the url from the website since the url may change between versions.
|
||||
* */
|
||||
!function (e) {
|
||||
e(["jquery"], function (e) {
|
||||
return function () {
|
||||
function t(e, t, n) {
|
||||
return g({type: O.error, iconClass: m().iconClasses.error, message: e, optionsOverride: n, title: t})
|
||||
}
|
||||
|
||||
function n(t, n) {
|
||||
return t || (t = m()), v = e("#" + t.containerId), v.length ? v : (n && (v = d(t)), v)
|
||||
}
|
||||
|
||||
function o(e, t, n) {
|
||||
return g({type: O.info, iconClass: m().iconClasses.info, message: e, optionsOverride: n, title: t})
|
||||
}
|
||||
|
||||
function s(e) {
|
||||
C = e
|
||||
}
|
||||
|
||||
function i(e, t, n) {
|
||||
return g({
|
||||
type: O.success,
|
||||
iconClass: m().iconClasses.success,
|
||||
message: e,
|
||||
optionsOverride: n,
|
||||
title: t
|
||||
})
|
||||
}
|
||||
|
||||
function a(e, t, n) {
|
||||
return g({
|
||||
type: O.warning,
|
||||
iconClass: m().iconClasses.warning,
|
||||
message: e,
|
||||
optionsOverride: n,
|
||||
title: t
|
||||
})
|
||||
}
|
||||
|
||||
function r(e, t) {
|
||||
var o = m();
|
||||
v || n(o), u(e, o, t) || l(o)
|
||||
}
|
||||
|
||||
function c(t) {
|
||||
var o = m();
|
||||
return v || n(o), t && 0 === e(":focus", t).length ? void h(t) : void (v.children().length && v.remove())
|
||||
}
|
||||
|
||||
function l(t) {
|
||||
for (var n = v.children(), o = n.length - 1; o >= 0; o--) u(e(n[o]), t)
|
||||
}
|
||||
|
||||
function u(t, n, o) {
|
||||
var s = !(!o || !o.force) && o.force;
|
||||
return !(!t || !s && 0 !== e(":focus", t).length) && (t[n.hideMethod]({
|
||||
duration: n.hideDuration,
|
||||
easing: n.hideEasing,
|
||||
complete: function () {
|
||||
h(t)
|
||||
}
|
||||
}), !0)
|
||||
}
|
||||
|
||||
function d(t) {
|
||||
return v = e("<div/>").attr("id", t.containerId).addClass(t.positionClass), v.appendTo(e(t.target)), v
|
||||
}
|
||||
|
||||
function p() {
|
||||
return {
|
||||
tapToDismiss: !0,
|
||||
toastClass: "toast",
|
||||
containerId: "toast-container",
|
||||
debug: !1,
|
||||
showMethod: "fadeIn",
|
||||
showDuration: 300,
|
||||
showEasing: "swing",
|
||||
onShown: void 0,
|
||||
hideMethod: "fadeOut",
|
||||
hideDuration: 1e3,
|
||||
hideEasing: "swing",
|
||||
onHidden: void 0,
|
||||
closeMethod: !1,
|
||||
closeDuration: !1,
|
||||
closeEasing: !1,
|
||||
closeOnHover: !0,
|
||||
extendedTimeOut: 1e3,
|
||||
iconClasses: {
|
||||
error: "toast-error",
|
||||
info: "toast-info",
|
||||
success: "toast-success",
|
||||
warning: "toast-warning"
|
||||
},
|
||||
iconClass: "toast-info",
|
||||
positionClass: "toast-top-right",
|
||||
timeOut: 5e3,
|
||||
titleClass: "toast-title",
|
||||
messageClass: "toast-message",
|
||||
escapeHtml: !1,
|
||||
target: "body",
|
||||
closeHtml: '<button type="button">×</button>',
|
||||
closeClass: "toast-close-button",
|
||||
newestOnTop: !0,
|
||||
preventDuplicates: !1,
|
||||
progressBar: !1,
|
||||
progressClass: "toast-progress",
|
||||
rtl: !1
|
||||
}
|
||||
}
|
||||
|
||||
function f(e) {
|
||||
C && C(e)
|
||||
}
|
||||
|
||||
function g(t) {
|
||||
function o(e) {
|
||||
return null == e && (e = ""), e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">")
|
||||
}
|
||||
|
||||
function s() {
|
||||
c(), u(), d(), p(), g(), C(), l(), i()
|
||||
}
|
||||
|
||||
function i() {
|
||||
var e = "";
|
||||
switch (t.iconClass) {
|
||||
case"toast-success":
|
||||
case"toast-info":
|
||||
e = "polite";
|
||||
break;
|
||||
default:
|
||||
e = "assertive"
|
||||
}
|
||||
I.attr("aria-live", e)
|
||||
}
|
||||
|
||||
function a() {
|
||||
E.closeOnHover && I.hover(H, D), !E.onclick && E.tapToDismiss && I.click(b), E.closeButton && j && j.click(function (e) {
|
||||
e.stopPropagation ? e.stopPropagation() : void 0 !== e.cancelBubble && e.cancelBubble !== !0 && (e.cancelBubble = !0), E.onCloseClick && E.onCloseClick(e), b(!0)
|
||||
}), E.onclick && I.click(function (e) {
|
||||
E.onclick(e), b()
|
||||
})
|
||||
}
|
||||
|
||||
function r() {
|
||||
I.hide(), I[E.showMethod]({
|
||||
duration: E.showDuration,
|
||||
easing: E.showEasing,
|
||||
complete: E.onShown
|
||||
}), 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)))
|
||||
}
|
||||
|
||||
function c() {
|
||||
t.iconClass && I.addClass(E.toastClass).addClass(y)
|
||||
}
|
||||
|
||||
function l() {
|
||||
E.newestOnTop ? v.prepend(I) : v.append(I)
|
||||
}
|
||||
|
||||
function u() {
|
||||
if (t.title) {
|
||||
var e = t.title;
|
||||
E.escapeHtml && (e = o(t.title)), M.append(e).addClass(E.titleClass), I.append(M)
|
||||
}
|
||||
}
|
||||
|
||||
function d() {
|
||||
if (t.message) {
|
||||
var e = t.message;
|
||||
E.escapeHtml && (e = o(t.message)), B.append(e).addClass(E.messageClass), I.append(B)
|
||||
function setIcon() {
|
||||
if (map.iconClass) {
|
||||
$toastElement.addClass(options.toastClass).addClass(iconClass);
|
||||
}
|
||||
}
|
||||
|
||||
function p() {
|
||||
E.closeButton && (j.addClass(E.closeClass).attr("role", "button"), I.prepend(j))
|
||||
}
|
||||
|
||||
function g() {
|
||||
E.progressBar && (q.addClass(E.progressClass), I.prepend(q))
|
||||
}
|
||||
|
||||
function C() {
|
||||
E.rtl && I.addClass("rtl")
|
||||
}
|
||||
|
||||
function O(e, t) {
|
||||
if (e.preventDuplicates) {
|
||||
if (t.message === w) return !0;
|
||||
w = t.message
|
||||
function setSequence() {
|
||||
if (options.newestOnTop) {
|
||||
$container.prepend($toastElement);
|
||||
} else {
|
||||
$container.append($toastElement);
|
||||
}
|
||||
return !1
|
||||
}
|
||||
|
||||
function b(t) {
|
||||
var n = t && E.closeMethod !== !1 ? E.closeMethod : E.hideMethod,
|
||||
o = t && E.closeDuration !== !1 ? E.closeDuration : E.hideDuration,
|
||||
s = t && E.closeEasing !== !1 ? E.closeEasing : E.hideEasing;
|
||||
if (!e(":focus", I).length || t) return clearTimeout(F.intervalId), I[n]({
|
||||
duration: o,
|
||||
easing: s,
|
||||
complete: function () {
|
||||
h(I), clearTimeout(k), E.onHidden && "hidden" !== P.state && E.onHidden(), P.state = "hidden", P.endTime = new Date, f(P)
|
||||
function setTitle() {
|
||||
if (map.title) {
|
||||
var suffix = map.title;
|
||||
if (options.escapeHtml) {
|
||||
suffix = escapeHtml(map.title);
|
||||
}
|
||||
})
|
||||
$titleElement.append(suffix).addClass(options.titleClass);
|
||||
$toastElement.append($titleElement);
|
||||
}
|
||||
}
|
||||
|
||||
function D() {
|
||||
(E.timeOut > 0 || E.extendedTimeOut > 0) && (k = setTimeout(b, E.extendedTimeOut), F.maxHideTime = parseFloat(E.extendedTimeOut), F.hideEta = (new Date).getTime() + F.maxHideTime)
|
||||
function setMessage() {
|
||||
if (map.message) {
|
||||
var suffix = map.message;
|
||||
if (options.escapeHtml) {
|
||||
suffix = escapeHtml(map.message);
|
||||
}
|
||||
$messageElement.append(suffix).addClass(options.messageClass);
|
||||
$toastElement.append($messageElement);
|
||||
}
|
||||
}
|
||||
|
||||
function H() {
|
||||
clearTimeout(k), F.hideEta = 0, I.stop(!0, !0)[E.showMethod]({
|
||||
duration: E.showDuration,
|
||||
easing: E.showEasing
|
||||
})
|
||||
function setCloseButton() {
|
||||
if (options.closeButton) {
|
||||
$closeElement.addClass(options.closeClass).attr('role', 'button');
|
||||
$toastElement.prepend($closeElement);
|
||||
}
|
||||
}
|
||||
|
||||
function x() {
|
||||
var e = (F.hideEta - (new Date).getTime()) / F.maxHideTime * 100;
|
||||
q.width(e + "%")
|
||||
function setProgressBar() {
|
||||
if (options.progressBar) {
|
||||
$progressElement.addClass(options.progressClass);
|
||||
$toastElement.prepend($progressElement);
|
||||
}
|
||||
}
|
||||
|
||||
var E = m(), y = t.iconClass || E.iconClass;
|
||||
if ("undefined" != typeof t.optionsOverride && (E = e.extend(E, t.optionsOverride), y = t.optionsOverride.iconClass || y), !O(E, t)) {
|
||||
T++, v = n(E, !0);
|
||||
var k = null, I = e("<div/>"), M = e("<div/>"), B = e("<div/>"), q = e("<div/>"),
|
||||
j = e(E.closeHtml), F = {intervalId: null, hideEta: null, maxHideTime: null},
|
||||
P = {toastId: T, state: "visible", startTime: new Date, options: E, map: t};
|
||||
return s(), r(), a(), f(P), E.debug && console && console.log(P), I
|
||||
function setRTL() {
|
||||
if (options.rtl) {
|
||||
$toastElement.addClass('rtl');
|
||||
}
|
||||
}
|
||||
|
||||
function shouldExit(options, map) {
|
||||
if (options.preventDuplicates) {
|
||||
if (map.message === previousToast) {
|
||||
return true;
|
||||
} else {
|
||||
previousToast = map.message;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hideToast(override) {
|
||||
var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
|
||||
var duration = override && options.closeDuration !== false ?
|
||||
options.closeDuration : options.hideDuration;
|
||||
var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
|
||||
if ($(':focus', $toastElement).length && !override) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(progressBar.intervalId);
|
||||
return $toastElement[method]({
|
||||
duration: duration,
|
||||
easing: easing,
|
||||
complete: function () {
|
||||
removeToast($toastElement);
|
||||
clearTimeout(intervalId);
|
||||
if (options.onHidden && response.state !== 'hidden') {
|
||||
options.onHidden();
|
||||
}
|
||||
response.state = 'hidden';
|
||||
response.endTime = new Date();
|
||||
publish(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function delayedHideToast() {
|
||||
if (options.timeOut > 0 || options.extendedTimeOut > 0) {
|
||||
intervalId = setTimeout(hideToast, options.extendedTimeOut);
|
||||
progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
|
||||
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
||||
}
|
||||
}
|
||||
|
||||
function stickAround() {
|
||||
clearTimeout(intervalId);
|
||||
progressBar.hideEta = 0;
|
||||
$toastElement.stop(true, true)[options.showMethod](
|
||||
{duration: options.showDuration, easing: options.showEasing}
|
||||
);
|
||||
}
|
||||
|
||||
function updateProgress() {
|
||||
var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
|
||||
$progressElement.width(percentage + '%');
|
||||
}
|
||||
}
|
||||
|
||||
function m() {
|
||||
return e.extend({}, p(), b.options)
|
||||
function getOptions() {
|
||||
return $.extend({}, getDefaults(), toastr.options);
|
||||
}
|
||||
|
||||
function h(e) {
|
||||
v || (v = n()), e.is(":visible") || (e.remove(), e = null, 0 === v.children().length && (v.remove(), w = void 0))
|
||||
function removeToast($toastElement) {
|
||||
if (!$container) {
|
||||
$container = getContainer();
|
||||
}
|
||||
if ($toastElement.is(':visible')) {
|
||||
return;
|
||||
}
|
||||
$toastElement.remove();
|
||||
$toastElement = null;
|
||||
if ($container.children().length === 0) {
|
||||
$container.remove();
|
||||
previousToast = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var v, C, w, T = 0, O = {error: "error", info: "info", success: "success", warning: "warning"}, b = {
|
||||
clear: r,
|
||||
remove: c,
|
||||
error: t,
|
||||
getContainer: n,
|
||||
info: o,
|
||||
options: {},
|
||||
subscribe: s,
|
||||
success: i,
|
||||
version: "2.1.3",
|
||||
warning: a
|
||||
};
|
||||
return b
|
||||
}()
|
||||
})
|
||||
}("function" == typeof define && define.amd ? define : function (e, t) {
|
||||
// "undefined" != typeof module && module.exports ? module.exports = t(require("jquery")) : window.toastr = t(window.jQuery)
|
||||
layui.define(["jquery"], function (exports) {
|
||||
exports("okToastr", t(layui.jquery));
|
||||
}).addcss("okmodules/toastr.min.css");
|
||||
});
|
||||
//# sourceMappingURL=toastr.js.map
|
||||
})();
|
||||
});
|
||||
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
|
||||
if (typeof module !== 'undefined' && module.exports) { //Node
|
||||
module.exports = factory(require('jquery'));
|
||||
} else if (window.layui && layui.define) { // 加入layui模块规范
|
||||
layui.define(["jquery"], function (exports) {
|
||||
exports("okToastr", factory(layui.jquery));
|
||||
}).addcss("okmodules/toastr.min.css");
|
||||
} else {
|
||||
window.toastr = factory(window.jQuery);
|
||||
}
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@
|
|||
<script src="../../lib/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.use(["okMd5"], function () {
|
||||
let $ = layui.jquery;
|
||||
let okMd5 = layui.md5;
|
||||
let okMd5 = layui.okMd5;
|
||||
// console.log($.md5.create("abc"))
|
||||
console.log(new okMd5("a"))
|
||||
console.log(okMd5("abc"))
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue