Files
VinFontApp/SysApp/wwwroot/js/libs/js-waves.min.js
2025-05-06 02:04:49 +07:00

1 line
6.6 KiB
JavaScript

!function (t, e) { "use strict"; "function" == typeof define && define.amd ? define([], function () { return t.Waves = e.call(t), t.Waves }) : "object" == typeof exports ? module.exports = e.call(t) : t.Waves = e.call(t) }("object" == typeof global ? global : this, function () { "use strict"; var t = t || {}, e = document.querySelectorAll.bind(document), n = Object.prototype.toString, a = "ontouchstart" in window; function o(t) { var e = typeof t; return "function" === e || "object" === e && !!t } function r(t) { var a, r = n.call(t); return "[object String]" === r ? e(t) : o(t) && /^\[object (Array|HTMLCollection|NodeList|Object)\]$/.test(r) && t.hasOwnProperty("length") ? t : o(a = t) && a.nodeType > 0 ? [t] : [] } function i(t) { var e = ""; for (var n in t) t.hasOwnProperty(n) && (e += n + ":" + t[n] + ";"); return e } var s = { duration: 750, delay: 200, show: function (t, e, n) { if (2 === t.button) return !1; e = e || this; var a = document.createElement("div"); a.className = "waves-ripple waves-rippling", e.appendChild(a); var o, r, u, c, l, d = (c = { top: 0, left: 0 }, l = (o = e) && o.ownerDocument, r = l.documentElement, void 0 !== o.getBoundingClientRect && (c = o.getBoundingClientRect()), u = function (t) { return null !== (e = t) && e === e.window ? t : 9 === t.nodeType && t.defaultView; var e }(l), { top: c.top + u.pageYOffset - r.clientTop, left: c.left + u.pageXOffset - r.clientLeft }), m = 0, v = 0; "touches" in t && t.touches.length ? (m = t.touches[0].pageY - d.top, v = t.touches[0].pageX - d.left) : (m = t.pageY - d.top, v = t.pageX - d.left), v = v >= 0 ? v : 0, m = m >= 0 ? m : 0; var f = "scale(" + e.clientWidth / 100 * 3 + ")", p = "translate(0,0)"; n && (p = "translate(" + n.x + "px, " + n.y + "px)"), a.setAttribute("data-hold", Date.now()), a.setAttribute("data-x", v), a.setAttribute("data-y", m), a.setAttribute("data-scale", f), a.setAttribute("data-translate", p); var h = { top: m + "px", left: v + "px" }; a.classList.add("waves-notransition"), a.setAttribute("style", i(h)), a.classList.remove("waves-notransition"), h["-webkit-transform"] = f + " " + p, h["-moz-transform"] = f + " " + p, h["-ms-transform"] = f + " " + p, h["-o-transform"] = f + " " + p, h.transform = f + " " + p, h.opacity = "1"; var b = "mousemove" === t.type ? 2500 : s.duration; h["-webkit-transition-duration"] = b + "ms", h["-moz-transition-duration"] = b + "ms", h["-o-transition-duration"] = b + "ms", h["transition-duration"] = b + "ms", a.setAttribute("style", i(h)) }, hide: function (t, e) { for (var n = (e = e || this).getElementsByClassName("waves-rippling"), o = 0, r = n.length; o < r; o++)c(t, e, n[o]); a && (e.removeEventListener("touchend", s.hide), e.removeEventListener("touchcancel", s.hide)), e.removeEventListener("mouseup", s.hide), e.removeEventListener("mouseleave", s.hide) } }, u = { input: function (t) { var e = t.parentNode; if ("i" !== e.tagName.toLowerCase() || !e.classList.contains("waves-effect")) { var n = document.createElement("i"); n.className = t.className + " waves-input-wrapper", t.className = "waves-button-input", e.replaceChild(n, t), n.appendChild(t); var a = window.getComputedStyle(t, null), o = a.color, r = a.backgroundColor; n.setAttribute("style", "color:" + o + ";background:" + r), t.setAttribute("style", "background-color:rgba(0,0,0,0);") } }, img: function (t) { var e = t.parentNode; if ("i" !== e.tagName.toLowerCase() || !e.classList.contains("waves-effect")) { var n = document.createElement("i"); e.replaceChild(n, t), n.appendChild(t) } } }; function c(t, e, n) { if (n) { n.classList.remove("waves-rippling"); var a = n.getAttribute("data-x"), o = n.getAttribute("data-y"), r = n.getAttribute("data-scale"), u = n.getAttribute("data-translate"), c = 350 - (Date.now() - Number(n.getAttribute("data-hold"))); c < 0 && (c = 0), "mousemove" === t.type && (c = 150); var l = "mousemove" === t.type ? 2500 : s.duration; setTimeout(function () { var t = { top: o + "px", left: a + "px", opacity: "0", "-webkit-transition-duration": l + "ms", "-moz-transition-duration": l + "ms", "-o-transition-duration": l + "ms", "transition-duration": l + "ms", "-webkit-transform": r + " " + u, "-moz-transform": r + " " + u, "-ms-transform": r + " " + u, "-o-transform": r + " " + u, transform: r + " " + u }; n.setAttribute("style", i(t)), setTimeout(function () { try { e.removeChild(n) } catch (t) { return !1 } }, l) }, c) } } var l = { touches: 0, allowEvent: function (t) { var e = !0; return /^(mousedown|mousemove)$/.test(t.type) && l.touches && (e = !1), e }, registerEvent: function (t) { var e = t.type; "touchstart" === e ? l.touches += 1 : /^(touchend|touchcancel)$/.test(e) && setTimeout(function () { l.touches && (l.touches -= 1) }, 500) } }; function d(t) { var e = function (t) { if (!1 === l.allowEvent(t)) return null; for (var e = null, n = t.target || t.srcElement; n.parentElement;) { if (!(n instanceof SVGElement) && n.classList.contains("waves-effect")) { e = n; break } n = n.parentElement } return e }(t); if (null !== e) { if (e.disabled || e.getAttribute("disabled") || e.classList.contains("disabled")) return; if (l.registerEvent(t), "touchstart" === t.type && s.delay) { var n = !1, o = setTimeout(function () { o = null, s.show(t, e) }, s.delay), r = function (a) { o && (clearTimeout(o), o = null, s.show(t, e)), n || (n = !0, s.hide(a, e)), u() }, i = function (t) { o && (clearTimeout(o), o = null), r(t), u() }; e.addEventListener("touchmove", i, !1), e.addEventListener("touchend", r, !1), e.addEventListener("touchcancel", r, !1); var u = function () { e.removeEventListener("touchmove", i), e.removeEventListener("touchend", r), e.removeEventListener("touchcancel", r) } } else s.show(t, e), a && (e.addEventListener("touchend", s.hide, !1), e.addEventListener("touchcancel", s.hide, !1)), e.addEventListener("mouseup", s.hide, !1), e.addEventListener("mouseleave", s.hide, !1) } } return t.init = function (t) { var e = document.body; "duration" in (t = t || {}) && (s.duration = t.duration), "delay" in t && (s.delay = t.delay), a && (e.addEventListener("touchstart", d, !1), e.addEventListener("touchcancel", l.registerEvent, !1), e.addEventListener("touchend", l.registerEvent, !1)), e.addEventListener("mousedown", d, !1) }, t.attach = function (t, e) { var a, o; t = r(t), "[object Array]" === n.call(e) && (e = e.join(" ")), e = e ? " " + e : ""; for (var i = 0, s = t.length; i < s; i++)o = (a = t[i]).tagName.toLowerCase(), -1 !== ["input", "img"].indexOf(o) && (u[o](a), a = a.parentElement), -1 === a.className.indexOf("waves-effect") && (a.className += " waves-effect" + e) }, t.calm = function (t) { for (var e = { type: "mouseup", button: 1 }, n = 0, a = (t = r(t)).length; n < a; n++)s.hide(e, t[n]) }, t });