Skip to content

Commit 59d848a

Browse files
author
OmarrSakr
committed
edit in loading Screen and some property in side-nav
1 parent f9a1cf0 commit 59d848a

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

.vscode/settings.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"العنصر",
99
"القيم",
1010
"الكتابة",
11+
"المحتوى",
1112
"المرور",
1213
"الوجبات",
1314
"بعمل",
@@ -19,6 +20,7 @@
1920
"زمنية",
2021
"لتعطيل",
2122
"محددة",
22-
"مهلة"
23+
"مهلة",
24+
"موجود"
2325
]
2426
}

assets/JS/main.js

+53-13
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ $(() => {
106106

107107
// ? ===============> getCategoryMeals for displayMeals() <===============
108108
async function getCategoryMeals(category) {
109+
$(".loading").fadeIn(300);
109110
// $("#loading").fadeIn(300);
110111
try {
111112
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/filter.php?c=${category}`);
@@ -115,6 +116,7 @@ async function getCategoryMeals(category) {
115116
const data = await response.json();
116117
// console.log(data);
117118
displayMeals(data.meals.slice(0, 20)); // !👆🏻
119+
$(".loading").fadeOut(300);
118120
}
119121
catch (error) {
120122
console.error("There was an error:", error);
@@ -125,6 +127,7 @@ getCategoryMeals("Seafood"); // here you must call the function getCategor
125127

126128
// * =======================> getMealDetails for displayMealDetails() <===========================
127129
async function getMealDetails(mealID) {
130+
$(".loading").fadeIn(300);
128131
try {
129132
console.log("Meal ID:", mealID);
130133
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/lookup.php?i=${mealID}`);
@@ -134,6 +137,7 @@ async function getMealDetails(mealID) {
134137
const data = await response.json();
135138
// console.log(data);
136139
displayMealDetails(data.meals[0]); // !👇
140+
$(".loading").fadeOut(300);
137141
}
138142
catch (error) {
139143
console.error("There was an error:", error.message);
@@ -342,6 +346,7 @@ $("body").on("click", (e) => {
342346
// ? ===============> getCategories <===============
343347

344348
async function getCategories() {
349+
$(".loading").fadeIn(300);
345350
try {
346351
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/categories.php`);
347352
if (!response.ok) {
@@ -350,6 +355,7 @@ async function getCategories() {
350355
const data = await response.json();
351356
// console.log(data);
352357
displayCategories(data.categories); // !
358+
$(".loading").fadeOut(300);
353359
localStorage.setItem('savedCategories', JSON.stringify(data.categories));
354360
}
355361
catch (error) {
@@ -443,6 +449,7 @@ $("body").on("click", (e) => {
443449
// ? ================> getArea <==================
444450

445451
async function getArea() {
452+
$(".loading").fadeIn(300);
446453
try {
447454
const response = await fetch("https://www.themealdb.com/api/json/v1/1/list.php?a=list");
448455
if (!response.ok) {
@@ -452,6 +459,8 @@ async function getArea() {
452459
// console.log(data);
453460
if (data.meals && Array.isArray(data.meals)) {
454461
displayArea(data.meals);
462+
$(".loading").fadeOut(300);
463+
455464
localStorage.setItem('savedArea', JSON.stringify(data.meals));
456465

457466
} else {
@@ -557,6 +566,7 @@ $("body").on("click", (e) => {
557566
// ? ===============> getIngredients <===============
558567

559568
async function getIngredients() {
569+
$(".loading").fadeIn(300);
560570
try {
561571
const response = await fetch(`https://www.themealdb.com/api/json/v1/1/list.php?i=list`);
562572
if (!response.ok) {
@@ -565,6 +575,7 @@ async function getIngredients() {
565575
const data = await response.json();
566576
// console.log(data);
567577
displayIngredients(data.meals); // !
578+
$(".loading").fadeOut(300);
568579
localStorage.setItem('savedIngredients', JSON.stringify(data.meals));
569580

570581
}
@@ -641,7 +652,7 @@ $("#closeContact").on("click", () => {
641652
$("#contact").fadeOut(300);
642653
localStorage.setItem('contactUsVisible', 'false');
643654
});
644-
$("#contactUs").on("click", () => {
655+
$("#contactUsLink").on("click", () => {
645656
closeSideNav();
646657
$("#contact").fadeIn(300);
647658
localStorage.setItem('contactUsVisible', 'true');
@@ -702,7 +713,7 @@ $("#submitBtn").on("click", (e) => {
702713
localStorage.setItem("age", $("#age").val());
703714
$("#password").val();// لا تحتفظ بكلمة المرور في localStorage
704715
$("#rePassword").val();
705-
716+
706717
// كدا انا بفرغ الحقل بعمل Clear Input
707718
$("#uName").val("");
708719
$("#email").val("");
@@ -823,15 +834,44 @@ $(() => {
823834
// * ================> just for ( preload ) when you preload this website .. it will appear load-circle <====================
824835

825836

837+
jQuery(() => {
838+
//* $("#data") => Located in (Home Section)
839+
//* انتظر حتى يتم تحميل البيانات
840+
let dataTime = $("#data");
841+
if (dataTime.length > 0) {
842+
//* البيانات جاهزة، لذلك يمكن إخفاء شاشة التحميل
843+
$(".loading").fadeOut(500, () => {
844+
$("body").removeClass("no-scroll");
845+
});
846+
}
847+
});
848+
849+
850+
851+
852+
853+
$(document).ready(function () {
854+
$('.side-nav ul li').on('click', function () {
855+
856+
$('#search').hide();
857+
$('#categories').hide();
858+
$('#area').hide();
859+
$('#ingredients').hide();
860+
$('#contact').hide();
861+
862+
let targetContentId = $(this).attr('id')
863+
.replace('UsLink', '') // إزالة "UsLink"
864+
.replace('Link', ''); // إزالة "Link"
865+
866+
if ($('#' + targetContentId).length > 0) {
867+
$('#' + targetContentId).show();
868+
} else {
869+
console.log("المحتوى غير موجود للـ ID: " + targetContentId);
870+
}
871+
$("#data").show;
872+
});
873+
});
874+
875+
876+
826877

827-
$(() => {
828-
// تقليل الوقت الظاهر للـ preloader(مهلة زمنية محددة setTimeout)
829-
setTimeout(() => {
830-
// إضافة الفئة لإنهاء عرض الـ preloader
831-
$('.loading').addClass('loading-end');
832-
// إخفاء الـ preloader بعد فترة قصيرة
833-
setTimeout(() => {
834-
$('.loading').addClass('disabled');
835-
}, 800);
836-
}, 1000);
837-
});

index.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
</head>
3232

33-
<body data-bs-theme="dark" class="position-relative">
33+
<body data-bs-theme="dark" class="position-relative no-scroll">
3434
<!-- !-------------------< just for appear load-circle >----------------- -->
3535

3636
<div class="loading">
@@ -44,22 +44,22 @@
4444
<h1>Yummy</h1>
4545
</div>
4646
<ul class="mb-0 overflow-hidden position-relative bottom-25">
47-
<li id="searchLink" class=" py-2 mb-2">
47+
<li id="searchLink" class=" py-2 mb-2 content-section">
4848
<i class="fa-solid fa-magnifying-glass me-3"></i><span class="fs-5">Search</span>
4949
</li>
50-
<li id="categoriesLink" class=" py-2 mb-2">
50+
<li id="categoriesLink" class=" py-2 mb-2 content-section">
5151
<i class="fa-solid fa-layer-group me-3"></i><span class="fs-5">Categories</span>
5252
</li>
53-
<li id="areaLink" class=" py-2 mb-2">
53+
<li id="areaLink" class=" py-2 mb-2 content-section">
5454
<i class="fa-solid fa-earth-americas me-3"></i><span class="fs-5">Area</span>
5555
</li>
56-
<li id="ingredientsLink" class=" py-2 mb-2">
56+
<li id="ingredientsLink" class=" py-2 mb-2 content-section">
5757
<i class="fa-solid fa-burger me-3"></i><span class="fs-5">Ingredients</span>
5858
</li>
59-
<li id="contactUs" class=" py-2 mb-2">
59+
<li id="contactUsLink" class=" py-2 mb-2 content-section">
6060
<i class="fa-solid fa-share-nodes me-3"></i><span class="fs-5">Contact us</span>
6161
</li>
62-
<li id="theme" class=" py-2 mb-2">
62+
<li id="theme" class=" py-2 mb-2 content-section">
6363
<i class="fa-solid fa-circle-half-stroke me-3"></i><span class="fs-5">theme: Dark</span>
6464
</li>
6565
</ul>

0 commit comments

Comments
 (0)