loading
This commit is contained in:
@@ -5,35 +5,71 @@
|
||||
|
||||
// Sự kiện click để hiển thị menu
|
||||
$('#js-show-menu').click(function () {
|
||||
capNhatTrangThaiMenu(false);
|
||||
AdminFunction.capNhatTrangThaiMenu(false);
|
||||
});
|
||||
|
||||
// Sự kiện click để ẩn menu
|
||||
$('#js-hide-menu').click(function () {
|
||||
capNhatTrangThaiMenu(true);
|
||||
AdminFunction.capNhatTrangThaiMenu(true);
|
||||
});
|
||||
|
||||
// Kiểm tra localStorage và thiết lập trạng thái ban đầu của menu
|
||||
const hideMenuBig = localStorage.getItem('menu_big') === 'hidden';
|
||||
capNhatTrangThaiMenu(hideMenuBig);
|
||||
AdminFunction.capNhatTrangThaiMenu(hideMenuBig);
|
||||
|
||||
AdminFunction.run_search('#js-input-search')
|
||||
|
||||
AdminFunction.searchSelect('#js-assign-admin');
|
||||
|
||||
AdminFunction.searchSelect('#js-order-status-select');
|
||||
|
||||
})
|
||||
|
||||
// Hàm để cập nhật trạng thái hiển thị menu và localStorage
|
||||
function capNhatTrangThaiMenu(hideMenuBig) {
|
||||
|
||||
if (hideMenuBig === false) {
|
||||
$('#js-admin-content-container').addClass('show-large-menu')
|
||||
} else {
|
||||
$('#js-admin-content-container').removeClass('show-large-menu')
|
||||
}
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
$('#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 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();
|
||||
|
||||
Reference in New Issue
Block a user