Files
du_an_khach_hang/Teahouse/js/library.js

234 lines
201 KiB
JavaScript
Raw Normal View History

2023-07-06 11:11:29 +07:00
/**
* Swiper 8.4.4
* Most modern mobile touch slider and framework with hardware accelerated transitions
* https://swiperjs.com
*
* Copyright 2014-2022 Vladimir Kharlampidi
*
* Released under the MIT License
*
* Released on: October 12, 2022
*/
!function (e, t) { "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).Swiper = t() }(this, (function () { "use strict"; function e(e) { return null !== e && "object" == typeof e && "constructor" in e && e.constructor === Object } function t(s, a) { void 0 === s && (s = {}), void 0 === a && (a = {}), Object.keys(a).forEach((i => { void 0 === s[i] ? s[i] = a[i] : e(a[i]) && e(s[i]) && Object.keys(a[i]).length > 0 && t(s[i], a[i]) })) } const s = { body: {}, addEventListener() { }, removeEventListener() { }, activeElement: { blur() { }, nodeName: "" }, querySelector: () => null, querySelectorAll: () => [], getElementById: () => null, createEvent: () => ({ initEvent() { } }), createElement: () => ({ children: [], childNodes: [], style: {}, setAttribute() { }, getElementsByTagName: () => [] }), createElementNS: () => ({}), importNode: () => null, location: { hash: "", host: "", hostname: "", href: "", origin: "", pathname: "", protocol: "", search: "" } }; function a() { const e = "undefined" != typeof document ? document : {}; return t(e, s), e } const i = { document: s, navigator: { userAgent: "" }, location: { hash: "", host: "", hostname: "", href: "", origin: "", pathname: "", protocol: "", search: "" }, history: { replaceState() { }, pushState() { }, go() { }, back() { } }, CustomEvent: function () { return this }, addEventListener() { }, removeEventListener() { }, getComputedStyle: () => ({ getPropertyValue: () => "" }), Image() { }, Date() { }, screen: {}, setTimeout() { }, clearTimeout() { }, matchMedia: () => ({}), requestAnimationFrame: e => "undefined" == typeof setTimeout ? (e(), null) : setTimeout(e, 0), cancelAnimationFrame(e) { "undefined" != typeof setTimeout && clearTimeout(e) } }; function r() { const e = "undefined" != typeof window ? window : {}; return t(e, i), e } class n extends Array { constructor(e) { "number" == typeof e ? super(e) : (super(...e || []), function (e) { const t = e.__proto__; Object.defineProperty(e, "__proto__", { get: () => t, set(e) { t.__proto__ = e } }) }(this)) } } function l(e) { void 0 === e && (e = []); const t = []; return e.forEach((e => { Array.isArray(e) ? t.push(...l(e)) : t.push(e) })), t } function o(e, t) { return Array.prototype.filter.call(e, t) } function d(e, t) { const s = r(), i = a(); let l = []; if (!t && e instanceof n) return e; if (!e) return new n(l); if ("string" == typeof e) { const s = e.trim(); if (s.indexOf("<") >= 0 && s.indexOf(">") >= 0) { let e = "div"; 0 === s.indexOf("<li") && (e = "ul"), 0 === s.indexOf("<tr") && (e = "tbody"), 0 !== s.indexOf("<td") && 0 !== s.indexOf("<th") || (e = "tr"), 0 === s.indexOf("<tbody") && (e = "table"), 0 === s.indexOf("<option") && (e = "select"); const t = i.createElement(e); t.innerHTML = s; for (let e = 0; e < t.childNodes.length; e += 1)l.push(t.childNodes[e]) } else l = function (e, t) { if ("string" != typeof e) return [e]; const s = [], a = t.querySelectorAll(e); for (let e = 0; e < a.length; e += 1)s.push(a[e]); return s }(e.trim(), t || i) } else if (e.nodeType || e === s || e === i) l.push(e); else if (Array.isArray(e)) { if (e instanceof n) return e; l = e } return new n(function (e) { const t = []; for (let s = 0; s < e.length; s += 1)-1 === t.indexOf(e[s]) && t.push(e[s]); return t }(l)) } d.fn = n.prototype; const c = { addClass: function () { for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)t[s] = arguments[s]; const a = l(t.map((e => e.split(" ")))); return this.forEach((e => { e.classList.add(...a) })), this }, removeClass: function () { for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)t[s] = arguments[s]; const a = l(t.map((e => e.split(" ")))); return this.forEach((e => { e.classList.remove(...a) })), this }, hasClass: function () { for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)t[s] = arguments[s]; const a = l(t.map((e => e.split(" ")))); return o(this, (e => a.filter((t => e.classList.c
//# sourceMappingURL=swiper-bundle.min.js.map
/**
* LAZY LOADING
*/
function _extends() { return (_extends = Object.assign || function (t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e]; for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]) } return t }).apply(this, arguments) } function _typeof(t) { return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t })(t) } !function (t, e) { "object" === ("undefined" == typeof exports ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.LazyLoad = e() }(this, function () { "use strict"; var t = "undefined" != typeof window, e = t && !("onscroll" in window) || "undefined" != typeof navigator && /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent), n = t && "IntersectionObserver" in window, o = t && "classList" in document.createElement("p"), r = { elements_selector: "img", container: e || t ? document : null, threshold: 300, thresholds: null, data_src: "src", data_srcset: "srcset", data_sizes: "sizes", data_bg: "bg", class_loading: "loading", class_loaded: "loaded", class_error: "error", load_delay: 0, auto_unobserve: !0, callback_enter: null, callback_exit: null, callback_reveal: null, callback_loaded: null, callback_error: null, callback_finish: null }, a = function (t, e) { return t.getAttribute("data-" + e) }, s = function (t, e, n) { var o = "data-" + e; null !== n ? t.setAttribute(o, n) : t.removeAttribute(o) }, i = function (t) { return "true" === a(t, "was-processed") }, c = function (t, e) { return s(t, "ll-timeout", e) }, l = function (t) { return a(t, "ll-timeout") }, u = function (t, e) { var n, o = new t(e); try { n = new CustomEvent("LazyLoad::Initialized", { detail: { instance: o } }) } catch (t) { (n = document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized", !1, !1, { instance: o }) } window.dispatchEvent(n) }; var d = function (t, e) { t && t(e) }, f = function (t, e) { t._loadingCount += e, 0 === t._elements.length && 0 === t._loadingCount && d(t._settings.callback_finish) }, _ = function (t) { for (var e, n = [], o = 0; e = t.children[o]; o += 1)"SOURCE" === e.tagName && n.push(e); return n }, v = function (t, e, n) { n && t.setAttribute(e, n) }, b = function (t, e) { v(t, "sizes", a(t, e.data_sizes)), v(t, "srcset", a(t, e.data_srcset)), v(t, "src", a(t, e.data_src)) }, g = { IMG: function (t, e) { var n = t.parentNode; n && "PICTURE" === n.tagName && _(n).forEach(function (t) { b(t, e) }); b(t, e) }, IFRAME: function (t, e) { v(t, "src", a(t, e.data_src)) }, VIDEO: function (t, e) { _(t).forEach(function (t) { v(t, "src", a(t, e.data_src)) }), v(t, "src", a(t, e.data_src)), t.load() } }, m = function (t, e) { var n, o, r = e._settings, s = t.tagName, i = g[s]; if (i) return i(t, r), f(e, 1), void (e._elements = (n = e._elements, o = t, n.filter(function (t) { return t !== o }))); !function (t, e) { var n = a(t, e.data_src), o = a(t, e.data_bg); n && (t.style.backgroundImage = 'url("'.concat(n, '")')), o && (t.style.backgroundImage = o) }(t, r) }, h = function (t, e) { o ? t.classList.add(e) : t.className += (t.className ? " " : "") + e }, p = function (t, e, n) { t.addEventListener(e, n) }, y = function (t, e, n) { t.removeEventListener(e, n) }, E = function (t, e, n) { y(t, "load", e), y(t, "loadeddata", e), y(t, "error", n) }, w = function (t, e, n) { var r = n._settings, a = e ? r.class_loaded : r.class_error, s = e ? r.callback_loaded : r.callback_error, i = t.target; !function (t, e) { o ? t.classList.remove(e) : t.className = t.className.replace(new RegExp("(^|\\s+)" + e + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "") }(i, r.class_loading), h(i, a), d(s, i), f(n, -1) }, k = function (t, e) { var n = function n(r) { w(r, !0, e), E(t, n, o) }, o = function o(r) { w(r, !1, e), E(t, n, o) }; !function (t, e, n) { p(t, "load", e), p(t, "loadeddata", e), p(t,
//# sourceMappingURL=lazyload.min.js.map
/*!
* jQuery mmenu v7.2.2
* @requires jQuery 1.7.0 or later
*
* mmenu.frebsite.nl
*
* Copyright (c) Fred Heusschen
* www.frebsite.nl
*
* License: CC-BY-NC-4.0
* http://creativecommons.org/licenses/by-nc/4.0/
*/
!function (h) { var n, p, o, a, t, f = "mmenu", e = "7.2.2"; h[f] && h[f].version > e || (h[f] = function (t, e, n) { return this.$menu = t, this._api = ["bind", "getInstance", "initPanels", "openPanel", "closePanel", "closeAllPanels", "setSelected"], this.opts = e, this.conf = n, this.vars = {}, this.cbck = {}, this.mtch = {}, "function" == typeof this.___deprecated && this.___deprecated(), this._initWrappers(), this._initAddons(), this._initExtensions(), this._initHooks(), this._initMenu(), this._initPanels(), this._initOpened(), this._initAnchors(), this._initMatchMedia(), "function" == typeof this.___debug && this.___debug(), this }, h[f].version = e, h[f].uniqueId = 0, h[f].wrappers = {}, h[f].addons = {}, h[f].defaults = { hooks: {}, extensions: [], wrappers: [], navbar: { add: !0, title: "Menu", titleLink: "parent" }, onClick: { setSelected: !0 }, slidingSubmenus: !0 }, h[f].configuration = { classNames: { divider: "Divider", inset: "Inset", nolistview: "NoListview", nopanel: "NoPanel", panel: "Panel", selected: "Selected", spacer: "Spacer", vertical: "Vertical" }, clone: !1, language: null, openingInterval: 25, panelNodetype: "ul, ol, div", transitionDuration: 400 }, h[f].prototype = { getInstance: function () { return this }, initPanels: function (t) { this._initPanels(t) }, openPanel: function (t, e) { if (this.trigger("openPanel:before", t), t && t.length && (t.is("." + p.panel) || (t = t.closest("." + p.panel)), t.is("." + p.panel))) { var n = this; if ("boolean" != typeof e && (e = !0), t.parent("." + p.listitem + "_vertical").length) t.parents("." + p.listitem + "_vertical").addClass(p.listitem + "_opened").children("." + p.panel).removeClass(p.hidden), this.openPanel(t.parents("." + p.panel).not(function () { return h(this).parent("." + p.listitem + "_vertical").length }).first()), this.trigger("openPanel:start", t), this.trigger("openPanel:finish", t); else { if (t.hasClass(p.panel + "_opened")) return; var i = this.$pnls.children("." + p.panel), s = this.$pnls.children("." + p.panel + "_opened"); if (!h[f].support.csstransitions) return s.addClass(p.hidden).removeClass(p.panel + "_opened"), t.removeClass(p.hidden).addClass(p.panel + "_opened"), this.trigger("openPanel:start", t), void this.trigger("openPanel:finish", t); i.not(t).removeClass(p.panel + "_opened-parent"); for (var a = t.data(o.parent); a;)(a = a.closest("." + p.panel)).parent("." + p.listitem + "_vertical").length || a.addClass(p.panel + "_opened-parent"), a = a.data(o.parent); i.removeClass(p.panel + "_highest").not(s).not(t).addClass(p.hidden), t.removeClass(p.hidden); var r = function () { s.removeClass(p.panel + "_opened"), t.addClass(p.panel + "_opened"), t.hasClass(p.panel + "_opened-parent") ? (s.addClass(p.panel + "_highest"), t.removeClass(p.panel + "_opened-parent")) : (s.addClass(p.panel + "_opened-parent"), t.addClass(p.panel + "_highest")), n.trigger("openPanel:start", t) }, l = function () { s.removeClass(p.panel + "_highest").addClass(p.hidden), t.removeClass(p.panel + "_highest"), n.trigger("openPanel:finish", t) }; e && !t.hasClass(p.panel + "_noanimation") ? setTimeout(function () { n.__transitionend(t, function () { l() }, n.conf.transitionDuration), r() }, n.conf.openingInterval) : (r(), l()) } this.trigger("openPanel:after", t) } }, closePanel: function (t) { this.trigger("closePanel:before", t); var e = t.parent(); e.hasClass(p.listitem + "_vertical") && (e.removeClass(p.listitem + "_opened"), t.addClass(p.hidden), this.trigger("closePanel", t)), this.trigger("closePanel:after", t) }, closeAllPanels: function (t) { this.trigger("closeAllPanels:before"), this.$pnls.find("." + p.listview).children().removeClass(p.listitem + "_selected").filter("." + p.listitem + "_vertical").removeClass(p.listitem + "_opened"); var e = this.$pnls.children("." + p.panel), n = t && t.length ? t : e.first(); this.$pnls.children("." + p.panel).not(n).removeClass(p.panel + "_opened").removeClass(p.panel + "_opened-parent").removeClass(p.panel + "_highest").addClass(p.hidden), this.openPanel(n, !1), this.trigger("closeAllPanels:after") }, to
!function (r) { var s, i, o, a, t = "mmenu", p = "offCanvas"; r[t].addons[p] = { setup: function () { if (this.opts[p]) { var e = this.opts[p], i = this.conf[p]; a = r[t].glbl, this._api = r.merge(this._api, ["open", "close", "setPage"]), "object" != typeof e && (e = {}), e = this.opts[p] = r.extend(!0, {}, r[t].defaults[p], e), "string" != typeof i.page.selector && (i.page.selector = "> " + i.page.nodetype), this.vars.opened = !1; var o = [s.menu + "_offcanvas"]; this.bind("initMenu:after", function () { var e = this; this._initBlocker(), this.setPage(a.$page), this["_initWindow_" + p](), this.$menu.addClass(o.join(" ")).parent("." + s.wrapper).removeClass(s.wrapper), this.$menu[i.menu.insertMethod](i.menu.insertSelector); var t = window.location.hash; if (t) { var n = this._getOriginalMenuId(); n && n == t.slice(1) && setTimeout(function () { e.open() }, 1e3) } }), this.bind("setPage:after", function (e) { a.$blck && a.$blck.children("a").attr("href", "#" + e.attr("id")) }), this.bind("open:start:sr-aria", function () { this.__sr_aria(this.$menu, "hidden", !1) }), this.bind("close:finish:sr-aria", function () { this.__sr_aria(this.$menu, "hidden", !0) }), this.bind("initMenu:after:sr-aria", function () { this.__sr_aria(this.$menu, "hidden", !0) }), this.bind("initBlocker:after:sr-text", function () { a.$blck.children("a").html(this.__sr_text(this.i18n(this.conf.screenReader.text.closeMenu))) }) } }, add: function () { s = r[t]._c, i = r[t]._d, o = r[t]._e, s.add("slideout page no-csstransforms3d"), i.add("style") }, clickAnchor: function (e, t) { var n = this; if (this.opts[p]) { var i = this._getOriginalMenuId(); if (i && e.is('[href="#' + i + '"]')) { if (t) return this.open(), !0; var o = e.closest("." + s.menu); if (o.length) { var r = o.data("mmenu"); if (r && r.close) return r.close(), n.__transitionend(o, function () { n.open() }, n.conf.transitionDuration), !0 } return this.open(), !0 } if (a.$page) return (i = a.$page.first().attr("id")) && e.is('[href="#' + i + '"]') ? (this.close(), !0) : void 0 } } }, r[t].defaults[p] = { blockUI: !0, moveBackground: !0 }, r[t].configuration[p] = { menu: { insertMethod: "prependTo", insertSelector: "body" }, page: { nodetype: "div", selector: null, noSelector: [], wrapIfNeeded: !0 } }, r[t].prototype.open = function () { if (this.trigger("open:before"), !this.vars.opened) { var e = this; this._openSetup(), setTimeout(function () { e._openFinish() }, this.conf.openingInterval), this.trigger("open:after") } }, r[t].prototype._openSetup = function () { var e = this, t = this.opts[p]; this.closeAllOthers(), a.$page.each(function () { r(this).data(i.style, r(this).attr("style") || "") }), a.$wndw.trigger(o.resize + "-" + p, [!0]); var n = [s.wrapper + "_opened"]; t.blockUI && n.push(s.wrapper + "_blocking"), "modal" == t.blockUI && n.push(s.wrapper + "_modal"), t.moveBackground && n.push(s.wrapper + "_background"), a.$html.addClass(n.join(" ")), setTimeout(function () { e.vars.opened = !0 }, this.conf.openingInterval), this.$menu.addClass(s.menu + "_opened") }, r[t].prototype._openFinish = function () { var e = this; this.__transitionend(a.$page.first(), function () { e.trigger("open:finish") }, this.conf.transitionDuration), this.trigger("open:start"), a.$html.addClass(s.wrapper + "_opening") }, r[t].prototype.close = function () { if (this.trigger("close:before"), this.vars.opened) { var t = this; this.__transitionend(a.$page.first(), function () { t.$menu.removeClass(s.menu + "_opened"); var e = [s.wrapper + "_opened", s.wrapper + "_blocking", s.wrapper + "_modal", s.wrapper + "_background"]; a.$html.removeClass(e.join(" ")), a.$page.each(function () { var e = r(this).data(i.style); r(this).attr("style", e) }), t.vars.opened = !1, t.trigger("close:finish") }, this.conf.transitionDuration), this.trigger("close:start"), a.$html.removeClass(s.wrapper + "_opening"), this.trigger("close:after") } }, r[t].prototype.closeAllOthers = function () { a.$body.find("." + s.menu + "_offcanvas").not(this.$menu).each(function () { var e = r(this).data(t); e && e.close && e.close() }) }, r[t
!function (n) { var s, o, i = "mmenu", e = "screenReader"; n[i].addons[e] = { setup: function () { var r = this, t = this.opts[e], a = this.conf[e]; n[i].glbl, "boolean" == typeof t && (t = { aria: t, text: t }), "object" != typeof t && (t = {}), (t = this.opts[e] = n.extend(!0, {}, n[i].defaults[e], t)).aria && (this.bind("initAddons:after", function () { this.bind("initMenu:after", function () { this.trigger("initMenu:after:sr-aria") }), this.bind("initNavbar:after", function () { this.trigger("initNavbar:after:sr-aria", arguments[0]) }), this.bind("openPanel:start", function () { this.trigger("openPanel:start:sr-aria", arguments[0]) }), this.bind("close:start", function () { this.trigger("close:start:sr-aria") }), this.bind("close:finish", function () { this.trigger("close:finish:sr-aria") }), this.bind("open:start", function () { this.trigger("open:start:sr-aria") }), this.bind("initOpened:after", function () { this.trigger("initOpened:after:sr-aria") }) }), this.bind("updateListview", function () { this.$pnls.find("." + s.listview).children().each(function () { r.__sr_aria(n(this), "hidden", n(this).is("." + s.hidden)) }) }), this.bind("openPanel:start", function (t) { var i = this.$menu.find("." + s.panel).not(t).not(t.parents("." + s.panel)), n = t.add(t.find("." + s.listitem + "_vertical ." + s.listitem + "_opened").children("." + s.panel)); this.__sr_aria(i, "hidden", !0), this.__sr_aria(n, "hidden", !1) }), this.bind("closePanel", function (t) { this.__sr_aria(t, "hidden", !0) }), this.bind("initPanels:after", function (t) { var i = t.find("." + s.btn).each(function () { r.__sr_aria(n(this), "owns", n(this).attr("href").replace("#", "")) }); this.__sr_aria(i, "haspopup", !0) }), this.bind("initNavbar:after", function (t) { var i = t.children("." + s.navbar); this.__sr_aria(i, "hidden", !t.hasClass(s.panel + "_has-navbar")) }), t.text && "parent" == this.opts.navbar.titleLink && this.bind("initNavbar:after", function (t) { var i = t.children("." + s.navbar), n = !!i.children("." + s.btn + "_prev").length; this.__sr_aria(i.children("." + s.title), "hidden", n) })), t.text && (this.bind("initAddons:after", function () { this.bind("setPage:after", function () { this.trigger("setPage:after:sr-text", arguments[0]) }), this.bind("initBlocker:after", function () { this.trigger("initBlocker:after:sr-text") }) }), this.bind("initNavbar:after", function (t) { var i = t.children("." + s.navbar), n = this.i18n(a.text.closeSubmenu); i.children("." + s.btn + "_prev").html(this.__sr_text(n)) }), this.bind("initListview:after", function (t) { var i = t.data(o.parent); if (i && i.length) { var n = i.children("." + s.btn + "_next"), e = this.i18n(a.text[n.parent().is("." + s.listitem + "_vertical") ? "toggleSubmenu" : "openSubmenu"]); n.append(r.__sr_text(e)) } })) }, add: function () { s = n[i]._c, o = n[i]._d, n[i]._e, s.add("sronly") }, clickAnchor: function (t, i) { } }, n[i].defaults[e] = { aria: !0, text: !0 }, n[i].configuration[e] = { text: { closeMenu: "Close menu", closeSubmenu: "Close submenu", openSubmenu: "Open submenu", toggleSubmenu: "Toggle submenu" } }, n[i].prototype.__sr_aria = function (t, i, n) { t.prop("aria-" + i, n)[n ? "attr" : "removeAttr"]("aria-" + i, n) }, n[i].prototype.__sr_role = function (t, i) { t.prop("role", i)[i ? "attr" : "removeAttr"]("role", i) }, n[i].prototype.__sr_text = function (t) { return '<span class="' + s.sronly + '">' + t + "</span>" } }(jQuery);
!function (n) { var e, r, s, t = "mmenu", i = "scrollBugFix"; n[t].addons[i] = { setup: function () { var o = this.opts[i]; this.conf[i]; s = n[t].glbl, n[t].support.touch && this.opts.offCanvas && this.opts.offCanvas.blockUI && ("boolean" == typeof o && (o = { fix: o }), "object" != typeof o && (o = {}), (o = this.opts[i] = n.extend(!0, {}, n[t].defaults[i], o)).fix && (this.bind("open:start", function () { this.$pnls.children("." + e.panel + "_opened").scrollTop(0) }), this.bind("initMenu:after", function () { this["_initWindow_" + i]() }))) }, add: function () { e = n[t]._c, n[t]._d, r = n[t]._e }, clickAnchor: function (o, t) { } }, n[t].defaults[i] = { fix: !0 }, n[t].prototype["_initWindow_" + i] = function () { var o = this; n(document).off(r.touchmove + "-" + i).on(r.touchmove + "-" + i, function (o) { s.$html.hasClass(e.wrapper + "_opened") && o.preventDefault() }); var t = !1; s.$body.off(r.touchstart + "-" + i).on(r.touchstart + "-" + i, "." + e.panels + "> ." + e.panel, function (o) { s.$html.hasClass(e.wrapper + "_opened") && (t || (t = !0, 0 === o.currentTarget.scrollTop ? o.currentTarget.scrollTop = 1 : o.currentTarget.scrollHeight === o.currentTarget.scrollTop + o.currentTarget.offsetHeight && (o.currentTarget.scrollTop -= 1), t = !1)) }).off(r.touchmove + "-" + i).on(r.touchmove + "-" + i, "." + e.panels + "> ." + e.panel, function (o) { s.$html.hasClass(e.wrapper + "_opened") && n(this)[0].scrollHeight > n(this).innerHeight() && o.stopPropagation() }), s.$wndw.off(r.orientationchange + "-" + i).on(r.orientationchange + "-" + i, function () { o.$pnls.children("." + e.panel + "_opened").scrollTop(0).css({ "-webkit-overflow-scrolling": "auto" }).css({ "-webkit-overflow-scrolling": "touch" }) }) } }(jQuery);
// FORMAT PRICE
function formatCurrency(a) {
var b = parseFloat(a)
.toFixed(2)
.replace(/(\d)(?=(\d{3})+\.)/g, "$1.")
.toString();
var len = b.length;
b = b.substring(0, len - 3);
return b;
}
// CONVERT STRING TO NUMBER
function strToNumber(str) {
str += "";
while (str.indexOf(".") > 0) {
str = str.replace(".", "");
}
var result = parseFloat(str);
return isNaN(result) ? 0 : result;
}
// FORMAT DATE
function formatDate(a) {
var a = new Date(parseInt(a) * 1000);
var year = a.getFullYear();
var month = a.getMonth() + 1;
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
// var time = date + '/' + month + '/' + year + ' ' + hour + ':' + min + ':' + sec ;
var time = date + "/" + month + "/" + year;
return time;
}
// CHECK EMAIL ADDRESS
function validateEmail(sEmail) {
var regex_email = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
return regex_email.test(sEmail)
}
// CHECK MOBILE PHONE 10 DIGITAL
function validateTel(tel) {
vnf_regex_tel = /((09|03|07|08|05|02)+([0-9]{8})\b)/g;
return (vnf_regex_tel.test(tel))
}
// DEBOUNCE FUNC
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this, args = arguments;
var later = function () {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
function isOnScreen(elem) {
// if the element doesn't exist, abort
if( elem.length == 0 ) {
return;
}
var $window = jQuery(window)
var viewport_top = $window.scrollTop()
var viewport_height = $window.height()
var viewport_bottom = viewport_top + viewport_height
var $elem = jQuery(elem)
var top = $elem.offset().top
var height = $elem.height()
var bottom = top + height
return (top >= viewport_top && top < viewport_bottom) ||
(bottom > viewport_top && bottom <= viewport_bottom) ||
(height > viewport_height && top <= viewport_top && bottom >= viewport_bottom)
}
function isOnScreenHandler(target, func) {
if (isOnScreen(target) && !$(target).hasClass('loaded')) {
func();
$(target).addClass('loaded');
} else {
lazy_load_group.push(
{
id: target.slice(1, target.length),
target: target,
loadFn: function () {
func();
},
}
)
}
}
// CALL MODAL SUCCESS
function modalSuccess() {
const successForm = document.querySelector(".success-form");
successForm.classList.toggle("hide");
setTimeout(function () {
successForm.classList.toggle("hide");
}, 1200);
}
// Hàm kiểm tra form với tất cả các input có attribute là "check-type"
function check_form_global(targetForm, targetAlert, borderColorDefault) {
const listTotalInputs = $(`${targetForm} [check-type]`);
let error = "";
let inputsCheckData = [];
let listErrorInputs = [];
let inputValueData = {};
// Tạo data là array chứa các thông tin của input
listTotalInputs.each(function () {
let id = $(this).attr('id');
let type = $(this).attr('check-type');
inputsCheckData = [...inputsCheckData, { id: id, type: type }];
})
// Reset border-color input về mặc định
listTotalInputs.css('border-color', borderColorDefault);
// Danh sách kiểm tra input và tạo error
inputsCheckData.forEach(function (input) {
let inputEl = document.getElementById(input.id);
let inputValue = inputEl.value;
let inputType = input.type;
inputValueData = { ...inputValueData, [inputType]: inputValue };
switch (inputType) {
case 'email':
if (validateEmail(inputValue) == false) errorInputHandler(inputEl, 'Email không hợp lệ');
break;
case 'name':
if (inputValue.length < 2 && 1 < 2) errorInputHandler(inputEl, 'Tên quá ngắn (tối thiểu 2 ký tự)');
break;
case 'tel':
if (!validateTel(inputValue)) errorInputHandler(inputEl, 'Số điện thoại không hợp lệ');
break;
case 'address':
if (inputValue.length < 6 && 1 < 2) errorInputHandler(inputEl, 'Bạn chưa nhập địa chỉ (tối thiểu 6 ký tự)');
break;
case 'province':
if (inputValue === '') errorInputHandler(inputEl, 'Bạn chưa chọn Tỉnh/Thành phố');
break;
case 'district':
if (inputValue === '') errorInputHandler(inputEl, 'Bạn chưa chọn Quận/Huyện');
break;
case 'ward':
if (inputValue === '') errorInputHandler(inputEl, 'Bạn chưa chọn Phường/Xã');
break;
case 'content':
if (inputValue.length < 8 && 1 < 2) errorInputHandler(inputEl, 'Bạn chưa nhập nội dung (tối thiểu 8 ký tự)');
break;
case 'password':
if (inputValue.length < 6 && 1 < 2) errorInputHandler(inputEl, 'Bạn chưa nhập mật khẩu/ Mật khẩu quá yếu (tối thiểu 6 ký tự)');
break;
case 'password-repeat':
let passwordValue = document.querySelector('[check-type="password"]').value;
if (inputValue !== passwordValue) errorInputHandler(inputEl, 'Mật khẩu nhập lại chưa trùng khớp');
break;
default:
break;
}
})
// Hàm xử lý error khi input lỗi
function errorInputHandler(inputEl, errorTitle) {
listErrorInputs = [...listErrorInputs, inputEl];
error += `<li>${errorTitle}</li>`;
}
// Xử lý lỗi nếu có
if (error !== '') {
alertInput(listErrorInputs, '#e80000');
$(targetAlert).html(`<ul>${error}</ul>`);
return { result: false };
} else {
$(targetAlert).html('');
return { result: true, values: inputValueData };
}
}
// Hàm thay đổi border-color input lỗi
function alertInput(listInput, color) {
listInput.forEach(function (input) {
input.style.borderColor = color;
})
}