diff --git a/assets/script/main.js b/assets/script/main.js index 51a8afb..16c762e 100644 --- a/assets/script/main.js +++ b/assets/script/main.js @@ -1,64 +1 @@ -"use strict"; - -var AdminFunction = (function () { - - - function capNhatTrangThaiMenu(hideMenuBig) { - - if (hideMenuBig === false) { - $('#js-admin-content-container').addClass('show-large-menu') - } else { - $('#js-admin-content-container').removeClass('show-large-menu') - } - - $('#js-menu-big').toggleClass('hidden', hideMenuBig); - $('#js-menu-small').toggleClass('hidden', !hideMenuBig); - $('#js-form-search').toggleClass('menu-hide', hideMenuBig); - localStorage.setItem(hideMenuBig ? 'menu_big' : 'menu_small', 'hidden'); - localStorage.removeItem(hideMenuBig ? 'menu_small' : 'menu_big'); - } - - function add_product_to_category(id) { - $('#status_' + id).html('Đang xử lý..'); - setTimeout(function () { - $('#status_' + id).html(''); - }, 1000) - } - - function run_search(holder) { - - $(holder).keyup(debounce(function () { - var inputString = $(this).val(); - $('#js-show-search').show() - }, 300)); - - $('body').click(function () { - $("#js-show-search").hide(); - }); - - - } - - - function update_product_hot(id) { - $('#js-status-hottype-' + id).html('Đang xử lý..'); - setTimeout(function () { - $('#js-status-hottype-' + id).html(''); - }, 1000) - } - - - function searchSelect(holder) { - $(holder).select2(); - } - - return { - capNhatTrangThaiMenu: capNhatTrangThaiMenu, - add_product_to_category: add_product_to_category, - run_search: run_search, - searchSelect: searchSelect, - update_product_hot: update_product_hot - } -})(); - - +(function () { const t = document.createElement("link").relList; if (t && t.supports && t.supports("modulepreload")) return; for (const e of document.querySelectorAll('link[rel="modulepreload"]')) i(e); new MutationObserver(e => { for (const r of e) if (r.type === "childList") for (const o of r.addedNodes) o.tagName === "LINK" && o.rel === "modulepreload" && i(o) }).observe(document, { childList: !0, subtree: !0 }); function s(e) { const r = {}; return e.integrity && (r.integrity = e.integrity), e.referrerPolicy && (r.referrerPolicy = e.referrerPolicy), e.crossOrigin === "use-credentials" ? r.credentials = "include" : e.crossOrigin === "anonymous" ? r.credentials = "omit" : r.credentials = "same-origin", r } function i(e) { if (e.ep) return; e.ep = !0; const r = s(e); fetch(e.href, r) } })(); diff --git a/template/javascript/global.html b/template/javascript/global.html index cd0d22e..048e6b7 100644 --- a/template/javascript/global.html +++ b/template/javascript/global.html @@ -25,52 +25,6 @@ }) - - 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 getTextAreaSelection(textarea) { - var start = textarea.selectionStart, end = textarea.selectionEnd; - return { - start: start, - end: end, - length: end - start, - text: textarea.value.slice(start, end) - }; - } - - function detectPaste(textarea, callback) { - textarea.onpaste = function () { - var sel = getTextAreaSelection(textarea); - var initialLength = textarea.value.length; - window.setTimeout(function () { - var val = textarea.value; - var pastedTextLength = val.length - (initialLength - sel.length); - var end = sel.start + pastedTextLength; - callback({ - start: sel.start, - end: end, - length: pastedTextLength, - text: val.slice(sel.start, end) - }); - }, 1); - }; - } - // end search - - function formatCurrency(a) { var b = parseFloat(a).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString(); var len = b.length;