Files
admin_hura_8/template/javascript/global.html

76 lines
2.3 KiB
HTML
Raw Normal View History

2024-01-24 11:49:22 +07:00
<script>
$(document).ready(function () {
2024-01-26 15:17:05 +07:00
2024-01-24 11:49:22 +07:00
// Sự kiện click để hiển thị menu
$('#js-show-menu').click(function () {
2025-02-17 16:51:08 +07:00
$('#js-menu-big').toggleClass('show');
$('#overlay').addClass('active');
2024-01-24 11:49:22 +07:00
});
2025-02-24 10:09:33 +07:00
// hover show danh muc con
HoverShowMenu();
2024-05-15 09:03:46 +07:00
AdminFunctions.searchSuggestions('#js-input-search')
2024-01-24 11:49:22 +07:00
})
2025-02-17 16:51:08 +07:00
function clickBackground() {
$('#js-menu-big').removeClass('show');
$('#overlay').removeClass('active');
}
2025-02-24 10:09:33 +07:00
function HoverShowMenu() {
2025-02-24 10:16:18 +07:00
const $menuBig = $('#js-menu-big');
const $hoverMenu = $('#js-hover-menu');
$menuBig.find('.box-item .item').on('mousemove', function () {
if ($menuBig.hasClass('active')) {
const $parentItem = $(this).closest('.box-item');
const $hoverContent = $parentItem.find('.hover-menu');
2025-02-24 10:09:33 +07:00
if ($hoverContent.length) {
2025-02-24 10:16:18 +07:00
const offset = $parentItem.offset();
const menuWidth = $menuBig.width();
const hoverHeight = $hoverContent.outerHeight();
const windowHeight = $(window).height();
const maxY = $(window).scrollTop() + windowHeight;
let posX = offset.left + menuWidth;
let posY = offset.top;
if (posY + hoverHeight > maxY) {
posY = maxY - hoverHeight - 10;
2025-02-24 10:09:33 +07:00
}
$hoverMenu.addClass('active')
.html($hoverContent.html())
2025-02-24 10:16:18 +07:00
.css({ left: posX, top: posY });
2025-02-24 10:09:33 +07:00
}
}
});
2025-02-24 10:16:18 +07:00
$hoverMenu.on('mouseleave', function () {
$hoverMenu.removeClass('active');
2025-02-24 10:09:33 +07:00
});
}
2024-01-31 11:59:25 +07:00
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;
}
2025-02-10 16:51:19 +07:00
function toggleSubMenu(id) {
const submenu = $('#' + id);
2025-02-11 16:22:18 +07:00
submenu.toggleClass('active');
if ($('#js-menu-big .sub-menu').hasClass('active')) {
$('#js-menu-big').addClass('active');
} else {
$('#js-menu-big').removeClass('active');
}
2025-02-10 16:51:19 +07:00
}
2024-01-24 11:49:22 +07:00
</script>