11<template >
22 <div class =" wrapper" >
3-
43 <RecipeImages v-if =" $store.state.recipe" />
54
65 <div v-if =" $store.state.recipe" class =" content" >
@@ -76,61 +75,75 @@ export default {
7675 },
7776 methods: {
7877 setup : function () {
78+ // Make the control row show that a recipe is loading
7979 if (! this .$store .state .recipe ) {
80- // Make the control row show that a recipe is loading
8180 this .$store .dispatch (' setLoadingRecipe' , { recipe: - 1 })
81+
82+ // Make the control row show that the recipe is reloading
8283 } else if (this .$store .state .recipe .id === parseInt (this .$route .params .id )) {
83- // Make the control row show that the recipe is reloading
8484 this .$store .dispatch (' setReloadingRecipe' , {
8585 recipe: this .$route .params .id
8686 })
87+
88+ // Make the control row show that a new recipe is loading
8789 } else {
88- // Make the control row show that a new recipe is loading
8990 this .$store .dispatch (' setLoadingRecipe' , { recipe: this .$route .params .id })
9091 }
92+
9193 let $this = this
94+
9295 $ .ajax ({
93- url: this .$window .baseUrl + ' /api/recipes/' + this .$route .params .id ,
96+ url: this .$window .baseUrl + ' /api/recipes/' + this .$route .params .id ,
9497 method: ' GET' ,
9598 data: null ,
99+
96100 }).done (function (recipe ) {
97101 // Store recipe data in vuex
98102 $this .$store .dispatch (' setRecipe' , { recipe: recipe })
103+
99104 if ($this .$store .state .recipe .recipeIngredient ) {
100105 $this .ingredients = Object .values ($this .$store .state .recipe .recipeIngredient )
101106 }
107+
102108 if ($this .$store .state .recipe .recipeInstructions ) {
103109 $this .instructions = Object .values ($this .$store .state .recipe .recipeInstructions )
104110 }
111+
105112 if ($this .$store .state .recipe .cookTime ) {
106113 let cookT = $this .$store .state .recipe .cookTime .match (/ PT(\d +? )H(\d +? )M/ )
107114 $this .timerCook = { hours: parseInt (cookT[1 ]), minutes: parseInt (cookT[2 ]) }
108115 }
116+
109117 if ($this .$store .state .recipe .prepTime ) {
110118 let prepT = $this .$store .state .recipe .prepTime .match (/ PT(\d +? )H(\d +? )M/ )
111119 $this .timerPrep = { hours: parseInt (prepT[1 ]), minutes: parseInt (prepT[2 ]) }
112120 }
121+
113122 if ($this .$store .state .recipe .totalTime ) {
114123 let totalT = $this .$store .state .recipe .totalTime .match (/ PT(\d +? )H(\d +? )M/ )
115124 $this .timerTotal = { hours: parseInt (totalT[1 ]), minutes: parseInt (totalT[2 ]) }
116125 }
126+
117127 if ($this .$store .state .recipe .tool ) {
118128 $this .tools = $this .$store .state .recipe .tool
119129 }
130+
120131 // Always set the active page last!
121132 $this .$store .dispatch (' setPage' , { page: ' recipe' })
122-
123- console .log (' DEBUG' , $this);
133+
124134 }).fail (function (e ) {
125135 if ($this .$store .state .loadingRecipe ) {
126136 // Reset loading recipe
127137 $this .$store .dispatch (' setLoadingRecipe' , { recipe: 0 })
128138 }
139+
129140 if ($this .$store .state .reloadingRecipe ) {
130141 // Reset reloading recipe
131142 $this .$store .dispatch (' setReloadingRecipe' , { recipe: 0 })
132143 }
144+
133145 $this .$store .dispatch (' setPage' , { page: ' recipe' })
146+
134147 alert ($this .t (' Loading recipe failed' ))
135148 })
136149 }
@@ -186,7 +199,7 @@ aside {
186199 width : 30% ;
187200 float : left ;
188201 }
189- @media (max-width :1199px ) { .content aside {
202+ @media screen and (max-width :1199px ) { .content aside {
190203 width : 100% ;
191204 float : none ;
192205 } }
@@ -198,7 +211,7 @@ aside {
198211 text-align : justify ;
199212 }
200213
201- @media (max-width :1199px ) { main {
214+ @media screen and (max-width :1199px ) { main {
202215 flex-basis : 100% ;
203216 width : 100% ;
204217 } }
@@ -221,7 +234,7 @@ aside {
221234 clear : both ;
222235 }
223236
224- @media (max-width :1199px ) { .recipe-content aside {
237+ @media screen and (max-width :1199px ) { .recipe-content aside {
225238 display : block ;
226239 width : 100% ;
227240 float : none ;
0 commit comments