All language subtitles for 8. Using Menus - Refresh Fix

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Now there's one last feature that we need to take a look at before our menu is completely finished.

You notice that we are on the mobile apps page and the mobile apps tab here is marked as selected and

we are on the mobile apps route and the mobile apps content is being rendered and the services tab is

marked as active.

So if we go ahead and now refresh the page you'll see we are actually sent back to the home page for

the active tab while the route in the U.R.L. and the content on the page is still being rendered as

the mobile apps page if we hover over the services tab you'll also see that the mobile app development

menu item is also not selected because the active value is set to zero for the Home tab.

So that means we need to come up here and where we added the EU's effect a function to fix the styling

of the active tab when the page refreshes.

We need to go ahead and add our individual services pages.

So the custom software mobile apps and Web site routes to this fix is getting quite verbose though as

you can see here.

And so I actually want to refactor this a little bit into a javascript switch statement.

I'll move this over and here we're going to just switch over the window dot location dot path name and

open loops open that up.

Now we can set a case for each route that may appear starting with the slash route and then we will

open that with a colon and inside here is where we can check if the value is not set to 0.

So this is the check that we were doing here to make sure that we're not already set to the correct

page which will help prevent unnecessary re rendering.

And so if the correct page is not already set let's go ahead and set the value to the correct page we

can go ahead and actually copy all of this and we'll go ahead and paste that underneath.

And just one underneath here and then we can fix can ignore those for a second.

We can fix the spacing there with a shift tab to move it backwards and it's complaining here that we

don't have a default case.

And so let's real quick add underneath this a default and we'll just make this break the only way you

would fall to this case is if you're trying to access a page that doesn't exist any way in which case

we don't really need to worry about setting an active tab.

But let's go and change this case here now to slash services and of course that means the value of one

needs to be checked as well as setting the value to one if it isn't already.

And we'll go ahead and repeat this process for all of the rest of the routes and then include the new

routes that we have not already.

So let's actually just do that.

Here underneath the services with custom software and we're going to make sure that we're still checking

for one because we want the active tab set to services but then inside of the services menu we want

the correct custom software menu item to be marked as selected.

So here we also want to go ahead and set our selected index also to one.

This is because on our menu the custom software development is in the second position which if you're

counting from 0 is 0 and 1 the first position.

Now this also is showing us that we need to set the 0 with a position for services if that's selected.

So what's come up here and also set the set selected index to 0 this time for the first option in the

menu which is these services menu item will continue and come down and set a case for these slash mobile

apps page and set that equal to again check if the value is on these services page so set to 1 and then

if it is not we will set our value to 1 and then we'll set these selected index to 2 which will then

mark the mobile apps page as selected in the menu again will come down below and we'll create another

case for the slash Web sites page and we'll open this up check if we are on the services tab open this

and if we are not let's set us to these services tab and then let's set these selected index for our

menu to 3.

Now this should appropriately handle setting the active menu items anytime we refresh along with setting

the correct active tab for whichever page we're on so let's continue for the rest of the regular pages

with a case for Slash slash revolution and this we'll be checking for it if the value wipes value is

not already set to 2 Well then we want to go ahead and set the value to to that's all we'll do there

and then we'll come down below and we will case for these slash about and it looks actually I think

that this is in the wrong place.

Yeah.

Make sure that you are getting underneath all of the correct brackets and then set another case for

Slash about to this time.

Check if we are on if we are not already not already on the third page.

Well then of course we're going to set the value to the third page.

Do the same thing again.

Case for Slash contact.

Open it up.

And if the value is not equal to our fourth tab size only put an array there.

Make it an object.

Then we're going to set the value to the fourth tab.

And one last time you finally made it through the case for the slash estimate page which we will then

set our value to five.

Well make sure we're getting the if statement if our value is not already set to five.

Well then then we're going to set the value to five five okay.

Now you're all probably yelling at me to get rid of these.

Yes lint errors.

It's telling me we need our break statements in here.

And so if we do not put in a break statement then our code could possibly run multiple of these cases

which we definitely do not want to do so outside of our if statements will add a break which will kick

us out of the switch.

If we do not need to do anything and let's make sure we get our case up here with a break and then here

with the brink mobile apps needs a break websites can take a break

break Mr. brick then break ups break down here.

We'll break right here and still not liking the sand.

I think I missed something.

I think I need a break inside of here as well.

No no.

Oh I think the here I need the break statement inside of this parentheses and then get rid of that.

There we go.

OK.

So make sure here that you're putting these brake statements within yeah within that brackets up here.

So just make sure you're getting these in the right places.

Hopefully I did not confuse you too much.

And there it looks like.

I think we're good Oh I see why I did something weird.

I don't know why I added these extra brackets here after the colon.

You don't need those.

So make sure to get rid of those and that's why it was being so weird with us.

Got those here on these last couple ones.

It looks like so yeah get rid of those rid of those.

I knew that I'd missed something up and there now looks like we're good.

So you just need the case the path a colon and then underneath that the if statement open that up and

then outside of the if statement a break let's go ahead and save this now and the page will refresh.

And so we see the services tab is correctly being set again.

And if we hover over it the mobile app development page is already selected.

So if we come over to home we go over and we hover.

So nothing is selected.

Go to Web site development Web site development is set in the U.R.L. and on the page.

And if we hover over services we see that it is selected.

So let's go ahead now and refresh the page and you see we still have these services tab being marked

active.

We're still on the right path.

We're still rendering the right content.

And if we hover over the menu we're still marking the Web site page as being selected.

So I think that that is all of the functionality and probably then some that we needed for our menu

to really create a dynamic and versatile component.

I'm really happy with the way that this looks and the functionality behind it.

And I think it just adds a nice little touch of interactivity to an otherwise more static experience.

So hopefully you really like that too.

Hopefully that wasn't too confusing to set up.

And if you need to just go through and really read over your code again and look at how the values are

being passed and remember that it's really just managing indexes of whether or not we are on the first

second third or fourth menu item or the first second third fourth or fifth tab and it's all just about

making sure that these values are set correctly at the correct times so we really have done a great

job getting this up I think it looks great and now we need to start addressing a problem there.

I'm sure you're eager to take a look at which is responsive design.

And right now I haven't done it yet but if you resize our browser and you start coming down well pretty

quickly you see our design kind of starts falling apart and it really does not look anything at all

like a production application is supposed to so to take a look at how we can start fixing this and making

sure that the page starts resizing correctly and giving us a correct header for smaller screen sizes.

Let's take a look at responsive design in the next video.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.