@@ -106,6 +106,7 @@ $(() => {
106
106
107
107
// ? ===============> getCategoryMeals for displayMeals() <===============
108
108
async function getCategoryMeals ( category ) {
109
+ $ ( ".loading" ) . fadeIn ( 300 ) ;
109
110
// $("#loading").fadeIn(300);
110
111
try {
111
112
const response = await fetch ( `https://www.themealdb.com/api/json/v1/1/filter.php?c=${ category } ` ) ;
@@ -115,6 +116,7 @@ async function getCategoryMeals(category) {
115
116
const data = await response . json ( ) ;
116
117
// console.log(data);
117
118
displayMeals ( data . meals . slice ( 0 , 20 ) ) ; // !👆🏻
119
+ $ ( ".loading" ) . fadeOut ( 300 ) ;
118
120
}
119
121
catch ( error ) {
120
122
console . error ( "There was an error:" , error ) ;
@@ -125,6 +127,7 @@ getCategoryMeals("Seafood"); // here you must call the function getCategor
125
127
126
128
// * =======================> getMealDetails for displayMealDetails() <===========================
127
129
async function getMealDetails ( mealID ) {
130
+ $ ( ".loading" ) . fadeIn ( 300 ) ;
128
131
try {
129
132
console . log ( "Meal ID:" , mealID ) ;
130
133
const response = await fetch ( `https://www.themealdb.com/api/json/v1/1/lookup.php?i=${ mealID } ` ) ;
@@ -134,6 +137,7 @@ async function getMealDetails(mealID) {
134
137
const data = await response . json ( ) ;
135
138
// console.log(data);
136
139
displayMealDetails ( data . meals [ 0 ] ) ; // !👇
140
+ $ ( ".loading" ) . fadeOut ( 300 ) ;
137
141
}
138
142
catch ( error ) {
139
143
console . error ( "There was an error:" , error . message ) ;
@@ -342,6 +346,7 @@ $("body").on("click", (e) => {
342
346
// ? ===============> getCategories <===============
343
347
344
348
async function getCategories ( ) {
349
+ $ ( ".loading" ) . fadeIn ( 300 ) ;
345
350
try {
346
351
const response = await fetch ( `https://www.themealdb.com/api/json/v1/1/categories.php` ) ;
347
352
if ( ! response . ok ) {
@@ -350,6 +355,7 @@ async function getCategories() {
350
355
const data = await response . json ( ) ;
351
356
// console.log(data);
352
357
displayCategories ( data . categories ) ; // !
358
+ $ ( ".loading" ) . fadeOut ( 300 ) ;
353
359
localStorage . setItem ( 'savedCategories' , JSON . stringify ( data . categories ) ) ;
354
360
}
355
361
catch ( error ) {
@@ -443,6 +449,7 @@ $("body").on("click", (e) => {
443
449
// ? ================> getArea <==================
444
450
445
451
async function getArea ( ) {
452
+ $ ( ".loading" ) . fadeIn ( 300 ) ;
446
453
try {
447
454
const response = await fetch ( "https://www.themealdb.com/api/json/v1/1/list.php?a=list" ) ;
448
455
if ( ! response . ok ) {
@@ -452,6 +459,8 @@ async function getArea() {
452
459
// console.log(data);
453
460
if ( data . meals && Array . isArray ( data . meals ) ) {
454
461
displayArea ( data . meals ) ;
462
+ $ ( ".loading" ) . fadeOut ( 300 ) ;
463
+
455
464
localStorage . setItem ( 'savedArea' , JSON . stringify ( data . meals ) ) ;
456
465
457
466
} else {
@@ -557,6 +566,7 @@ $("body").on("click", (e) => {
557
566
// ? ===============> getIngredients <===============
558
567
559
568
async function getIngredients ( ) {
569
+ $ ( ".loading" ) . fadeIn ( 300 ) ;
560
570
try {
561
571
const response = await fetch ( `https://www.themealdb.com/api/json/v1/1/list.php?i=list` ) ;
562
572
if ( ! response . ok ) {
@@ -565,6 +575,7 @@ async function getIngredients() {
565
575
const data = await response . json ( ) ;
566
576
// console.log(data);
567
577
displayIngredients ( data . meals ) ; // !
578
+ $ ( ".loading" ) . fadeOut ( 300 ) ;
568
579
localStorage . setItem ( 'savedIngredients' , JSON . stringify ( data . meals ) ) ;
569
580
570
581
}
@@ -641,7 +652,7 @@ $("#closeContact").on("click", () => {
641
652
$ ( "#contact" ) . fadeOut ( 300 ) ;
642
653
localStorage . setItem ( 'contactUsVisible' , 'false' ) ;
643
654
} ) ;
644
- $ ( "#contactUs " ) . on ( "click" , ( ) => {
655
+ $ ( "#contactUsLink " ) . on ( "click" , ( ) => {
645
656
closeSideNav ( ) ;
646
657
$ ( "#contact" ) . fadeIn ( 300 ) ;
647
658
localStorage . setItem ( 'contactUsVisible' , 'true' ) ;
@@ -702,7 +713,7 @@ $("#submitBtn").on("click", (e) => {
702
713
localStorage . setItem ( "age" , $ ( "#age" ) . val ( ) ) ;
703
714
$ ( "#password" ) . val ( ) ; // لا تحتفظ بكلمة المرور في localStorage
704
715
$ ( "#rePassword" ) . val ( ) ;
705
-
716
+
706
717
// كدا انا بفرغ الحقل بعمل Clear Input
707
718
$ ( "#uName" ) . val ( "" ) ;
708
719
$ ( "#email" ) . val ( "" ) ;
@@ -823,15 +834,44 @@ $(() => {
823
834
// * ================> just for ( preload ) when you preload this website .. it will appear load-circle <====================
824
835
825
836
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
+
826
877
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
- } ) ;
0 commit comments