Product & Menu hide if empty

This commit is contained in:
yarzar_code
2020-03-03 11:05:47 +06:30
parent a8603b26e5
commit e1dea34320
2 changed files with 18 additions and 7 deletions

View File

@@ -89,9 +89,11 @@
</li>
<div id="menu-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list category_cache_list" role="tablist" id="ul-navbar">
<%if @product%>
<li class="nav-item product" data-ref="<%= foodcourt_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li>
<%end%>
</ul>
</div>
</div>
@@ -414,10 +416,11 @@ $(document).ready(function () {
if (window.location.href.indexOf('#') != -1) {
getAllMenu();
}
var menus = JSON.parse(localStorage.getItem("menus"));
if (menus != null) {
menu_cache_append(menus);
else{
var menus = JSON.parse(localStorage.getItem("menus"));
if (menus != null) {
menu_cache_append(menus);
}
}
$(".tables").on('click', function () {
@@ -478,9 +481,16 @@ function getAllMenu(){
function menu_cache_append(menus){
$("#menu_cache").removeClass("hidden");
$(".menu_cache_name").text(menus[0]["name"])
if(menus.length != 1){
$(".menu_cache_name").text(menus[0]["name"])
}
for(var i in menus) {
menu_list_template(menus[i]);
if (menus[i].categories.length)
menu_list_template(menus[i]);
}
if ( $('.menu_click').length < 2 ) {
$('.list-menu').hide();
$('.category_list').css("margin-top", "10px");
}
var category = menus[0]["categories"];
@@ -512,7 +522,7 @@ function menu_click_cache_append(name,menus,menu_id) {
menu_list.empty();
var menu_cat = $('.category_list');
menu_cat.empty();
$('.category_list li:not(.product)').remove();
$(".main_menu").text(name);