@@ -106,6 +106,7 @@ $(() => {
106106
107107// ? ===============> getCategoryMeals for displayMeals() <===============
108108async 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() <===========================
127129async 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
344348async 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
445451async 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
559568async 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- } ) ;
0 commit comments