Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,900 --> 00:00:05,030
Well our application is definitely working but I want you to notice the really awkward behavior.
2
00:00:05,040 --> 00:00:10,170
If I refresh the page right now and then click on the Generate button nothing happens.
3
00:00:10,170 --> 00:00:11,880
That's because I haven't entered in a length.
4
00:00:11,880 --> 00:00:14,570
I also haven't selected any valid characters.
5
00:00:14,690 --> 00:00:20,160
So just to kind of help guide our users I think that we should try to disable this button from being
6
00:00:20,160 --> 00:00:20,830
clicked.
7
00:00:20,830 --> 00:00:28,320
And so we have both a length and at least one of these character sets has been selected now in general
8
00:00:28,380 --> 00:00:30,630
to actually disable a button.
9
00:00:30,630 --> 00:00:34,630
Oh we have to do is add a disabled attribute to the button element.
10
00:00:34,650 --> 00:00:35,440
Let me show you what I mean.
11
00:00:36,330 --> 00:00:40,980
I'm gonna go back over to my component template and inside there I'll find the button elements right
12
00:00:40,980 --> 00:00:48,240
here down towards the bottom if I just add in an attribute of disabled like so and then save this button
13
00:00:48,300 --> 00:00:53,040
will be disabled on the screen and so would be kind of clear to our users that hey they need to do something
14
00:00:53,040 --> 00:00:54,610
before they can click that.
15
00:00:54,840 --> 00:01:00,030
But this is pretty much what we want but obviously we want to update that disabled attribute after a
16
00:01:00,030 --> 00:01:04,380
user has entered in a link and checked on these things as well.
17
00:01:04,550 --> 00:01:10,140
So in order to do so we're going to set up another property binding just like we've been doing on those
18
00:01:10,140 --> 00:01:11,850
input elements.
19
00:01:11,850 --> 00:01:15,860
Remember on the input element down here we've got a bound property.
20
00:01:16,020 --> 00:01:20,750
This right here means take a look at the password property of our components.
21
00:01:20,840 --> 00:01:27,210
Anytime that changes reassign that value to the value property of the input do we want to do the same
22
00:01:27,210 --> 00:01:27,570
thing.
23
00:01:27,600 --> 00:01:33,670
But this time we want to affect the disabled property of the button let's do this.
24
00:01:33,750 --> 00:01:42,040
We will wrap it disabled property with those same kind of square brackets like so I'll then put in my
25
00:01:42,040 --> 00:01:46,780
set of double quotes and remember whatever we put inside those double quotes is now going to be evaluated
26
00:01:46,870 --> 00:01:48,650
as though it were javascript.
27
00:01:48,750 --> 00:01:54,340
So just to get started let's first begin by only enabling the button after the user has entered in a
28
00:01:54,400 --> 00:01:59,910
length they'll say not length like so.
29
00:01:59,970 --> 00:02:01,320
So how does this work.
30
00:02:01,460 --> 00:02:02,980
What would our application first boots up.
31
00:02:02,990 --> 00:02:06,590
Length is equal to zero not zero is equal to true.
32
00:02:06,620 --> 00:02:09,850
So we can imagine that like true would be stuck in right there.
33
00:02:09,890 --> 00:02:15,020
That means yes do disable the button but having not length is going to work to make sure that we only
34
00:02:15,020 --> 00:02:18,230
enable the button after the user has entered an actual length.
35
00:02:18,230 --> 00:02:21,170
Property let's test this out really quickly.
36
00:02:21,170 --> 00:02:28,500
I'll save this I'll flip back over now the button is disabled by default but if I enter in a link I
37
00:02:28,500 --> 00:02:31,700
can see the Generate button lights right up okay.
38
00:02:31,740 --> 00:02:34,650
So I'd say that definitely works.
39
00:02:34,700 --> 00:02:39,890
Now let's add in some additional checks there to also look and make sure that we've got at least one
40
00:02:39,890 --> 00:02:42,120
of these things checked OK.
41
00:02:42,130 --> 00:02:46,600
Now this check heading into Boolean logic for this is going to be just a little bit more complicated.
42
00:02:46,660 --> 00:02:51,250
So if you understand what's going on right here this is really all you need to understand the boolean
43
00:02:51,250 --> 00:02:54,130
stuff they're about to add in is going to get a little bit nasty.
44
00:02:54,160 --> 00:02:58,780
I just want to tell you right up front this line is give be a little bit long so I'm going to first
45
00:02:58,780 --> 00:03:06,270
do a little bit of indentation here just to give myself some base to type.
46
00:03:06,340 --> 00:03:13,460
Now I'm going to remove the knot length and I will replace it with not so exclamation and a set of parentheses.
47
00:03:13,660 --> 00:03:24,390
And inside there I'll say length and another set of parentheses include letters or include symbols or
48
00:03:24,870 --> 00:03:30,640
include numbers and I'll close off both the parentheses.
49
00:03:30,640 --> 00:03:35,730
I'll zoom out for just a second so you can see that whole statement again this says Take a look and
50
00:03:35,730 --> 00:03:41,700
make sure that at least one of include letters symbols or numbers is true and make sure that there is
51
00:03:41,700 --> 00:03:46,320
a length entered and then take the opposite of all that to decide whether or not the button should be
52
00:03:46,320 --> 00:03:46,830
disabled
53
00:03:49,600 --> 00:03:49,830
OK.
54
00:03:49,860 --> 00:03:54,340
So it's a test that I'll save this line of flip back over.
55
00:03:54,450 --> 00:03:56,070
Now if I enter into length by itself.
56
00:03:56,280 --> 00:03:57,240
No no good.
57
00:03:57,240 --> 00:04:00,650
I have to also check one of these boxes once I do.
58
00:04:00,660 --> 00:04:06,750
Now the Generate button lights up as soon as I uncheck one the black boxes the button the general button
59
00:04:06,750 --> 00:04:08,570
goes away once again.
60
00:04:08,590 --> 00:04:12,720
Now I can hit generate and I still see my random password all right.
61
00:04:12,720 --> 00:04:14,640
So I'd say that's a pretty good improvement.
62
00:04:14,700 --> 00:04:17,220
So I think this application looks pretty good right now.
63
00:04:17,250 --> 00:04:20,140
The last big thing I think we should fix is the styling.
64
00:04:20,160 --> 00:04:22,530
Right now the application is not ugly.
65
00:04:22,530 --> 00:04:26,940
I think we should add in a little bit of styling just to make sure this thing looks a little bit better.
66
00:04:27,110 --> 00:04:30,330
No quick pause and we'll start to add in some C Ss in just a moment.
6922
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.