ts
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
"use strict";
|
||||
const AdminFunction = (() => {
|
||||
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');
|
||||
const AdminFunctions = (() => {
|
||||
function toggleMenuVisibility(hideLargeMenu) {
|
||||
const contentContainer = $('#js-admin-content-container');
|
||||
const largeMenu = $('#js-menu-big');
|
||||
const smallMenu = $('#js-menu-small');
|
||||
const searchForm = $('#js-form-search');
|
||||
contentContainer.toggleClass('show-large-menu', !hideLargeMenu);
|
||||
largeMenu.toggleClass('hidden', hideLargeMenu);
|
||||
smallMenu.toggleClass('hidden', !hideLargeMenu);
|
||||
searchForm.toggleClass('menu-hide', hideLargeMenu);
|
||||
localStorage.setItem(hideLargeMenu ? 'menu_big' : 'menu_small', 'hidden');
|
||||
localStorage.removeItem(hideLargeMenu ? 'menu_small' : 'menu_big');
|
||||
}
|
||||
function debounce(func, wait, immediate) {
|
||||
let timeout = null;
|
||||
@@ -31,35 +30,36 @@ const AdminFunction = (() => {
|
||||
func.apply(context, args);
|
||||
};
|
||||
}
|
||||
function add_product_to_category(id) {
|
||||
$('#status_' + id).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>');
|
||||
function addProductToCategory(productId) {
|
||||
const statusElement = $('#status_' + productId);
|
||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||
setTimeout(() => {
|
||||
$('#status_' + id).html('');
|
||||
statusElement.html('');
|
||||
}, 1000);
|
||||
}
|
||||
function run_search(holder) {
|
||||
$(holder).keyup(debounce(function () {
|
||||
//const inputString = $(this).val();
|
||||
function searchSuggestions(inputSelector) {
|
||||
$(inputSelector).keyup(debounce(function () {
|
||||
$('#js-show-search').show();
|
||||
}, 300, false)); // Cast debounce to any to avoid type inference issues
|
||||
}, 300, false));
|
||||
$('body').click(function () {
|
||||
$("#js-show-search").hide();
|
||||
$('#js-show-search').hide();
|
||||
});
|
||||
}
|
||||
function update_product_hot(id) {
|
||||
$('#js-status-hottype-' + id).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>');
|
||||
function markProductAsHot(productId) {
|
||||
const statusElement = $('#js-status-hottype-' + productId);
|
||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||
setTimeout(() => {
|
||||
$('#js-status-hottype-' + id).html('');
|
||||
statusElement.html('');
|
||||
}, 1000);
|
||||
}
|
||||
function searchSelect(holder) {
|
||||
$(holder).select2();
|
||||
function initializeSearchDropdown(selector) {
|
||||
$(selector).select2();
|
||||
}
|
||||
return {
|
||||
capNhatTrangThaiMenu,
|
||||
add_product_to_category,
|
||||
run_search,
|
||||
searchSelect,
|
||||
update_product_hot
|
||||
toggleMenuVisibility,
|
||||
addProductToCategory,
|
||||
searchSuggestions,
|
||||
initializeSearchDropdown,
|
||||
markProductAsHot
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
interface AdminFunction {
|
||||
capNhatTrangThaiMenu(hideMenuBig: boolean): void;
|
||||
add_product_to_category(id: string): void;
|
||||
run_search(holder: string): void;
|
||||
searchSelect(holder: string): void;
|
||||
update_product_hot(id: string): void;
|
||||
interface AdminFunctions {
|
||||
toggleMenuVisibility(hideLargeMenu: boolean): void;
|
||||
addProductToCategory(productId: string): void;
|
||||
searchSuggestions(inputSelector: string): void;
|
||||
initializeSearchDropdown(selector: string): void;
|
||||
markProductAsHot(productId: string): void;
|
||||
}
|
||||
|
||||
const AdminFunction: AdminFunction = (() => {
|
||||
function capNhatTrangThaiMenu(hideMenuBig: boolean): void {
|
||||
if (hideMenuBig === false) {
|
||||
$('#js-admin-content-container').addClass('show-large-menu');
|
||||
} else {
|
||||
$('#js-admin-content-container').removeClass('show-large-menu');
|
||||
}
|
||||
const AdminFunctions: AdminFunctions = (() => {
|
||||
|
||||
$('#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 toggleMenuVisibility(hideLargeMenu: boolean): void {
|
||||
const contentContainer = $('#js-admin-content-container');
|
||||
const largeMenu = $('#js-menu-big');
|
||||
const smallMenu = $('#js-menu-small');
|
||||
const searchForm = $('#js-form-search');
|
||||
|
||||
contentContainer.toggleClass('show-large-menu', !hideLargeMenu);
|
||||
largeMenu.toggleClass('hidden', hideLargeMenu);
|
||||
smallMenu.toggleClass('hidden', !hideLargeMenu);
|
||||
searchForm.toggleClass('menu-hide', hideLargeMenu);
|
||||
|
||||
localStorage.setItem(hideLargeMenu ? 'menu_big' : 'menu_small', 'hidden');
|
||||
localStorage.removeItem(hideLargeMenu ? 'menu_small' : 'menu_big');
|
||||
}
|
||||
|
||||
function debounce(func: (...args: any[]) => void, wait: number, immediate: boolean) {
|
||||
@@ -40,41 +42,41 @@ const AdminFunction: AdminFunction = (() => {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function add_product_to_category(id: string): void {
|
||||
$('#status_' + id).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>');
|
||||
function addProductToCategory(productId: string): void {
|
||||
const statusElement = $('#status_' + productId);
|
||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||
setTimeout(() => {
|
||||
$('#status_' + id).html('');
|
||||
statusElement.html('');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function run_search(holder: string): void {
|
||||
$(holder).keyup(debounce(function (this: HTMLInputElement) { // Ensure 'this' context is of type HTMLInputElement
|
||||
//const inputString = $(this).val();
|
||||
function searchSuggestions(inputSelector: string): void {
|
||||
$(inputSelector).keyup(debounce(function (this: HTMLInputElement) {
|
||||
$('#js-show-search').show();
|
||||
}, 300, false) as any); // Cast debounce to any to avoid type inference issues
|
||||
}, 300, false) as any);
|
||||
|
||||
$('body').click(function () {
|
||||
$("#js-show-search").hide();
|
||||
$('#js-show-search').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function update_product_hot(id: string): void {
|
||||
$('#js-status-hottype-' + id).html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Đang xử lý..</span>');
|
||||
function markProductAsHot(productId: string): void {
|
||||
const statusElement = $('#js-status-hottype-' + productId);
|
||||
statusElement.html('<span class="loading loading-bars loading-sm"></span><span class="ml-[3px]">Processing...</span>');
|
||||
setTimeout(() => {
|
||||
$('#js-status-hottype-' + id).html('');
|
||||
statusElement.html('');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function searchSelect(holder: string): void {
|
||||
$(holder).select2();
|
||||
function initializeSearchDropdown(selector: string): void {
|
||||
$(selector).select2();
|
||||
}
|
||||
|
||||
return {
|
||||
capNhatTrangThaiMenu,
|
||||
add_product_to_category,
|
||||
run_search,
|
||||
searchSelect,
|
||||
update_product_hot
|
||||
toggleMenuVisibility,
|
||||
addProductToCategory,
|
||||
searchSuggestions,
|
||||
initializeSearchDropdown,
|
||||
markProductAsHot
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user