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