Commit 76b8987a6426f9729ca5b7d6c4bb1f1d1b9a5f21
1 parent
043f0b2901
Exists in
master
Update created and rendered callbacks to use new onCreated and onRendered syntax.
Closes #42.
Showing
5 changed files
with
20 additions
and
20 deletions
Show diff stats
client/controllers/authenticated/header.js
1 | /* | 1 | /* |
2 | * Controller: Header | 2 | * Controller: Header |
3 | * Template: /client/includes/_header.html | 3 | * Template: /client/includes/_header.html |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Created | 7 | * Created |
8 | */ | 8 | */ |
9 | 9 | ||
10 | Template.header.created = function(){ | 10 | Template.header.onCreated(function(){ |
11 | // Code to run when template is created goes here. | 11 | // Code to run when template is created goes here. |
12 | } | 12 | }); |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * Rendered | 15 | * Rendered |
16 | */ | 16 | */ |
17 | 17 | ||
18 | Template.header.rendered = function() { | 18 | Template.header.onRendered(function() { |
19 | // Code to run when template is rendered goes here. | 19 | // Code to run when template is rendered goes here. |
20 | } | 20 | }); |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Helpers | 23 | * Helpers |
24 | */ | 24 | */ |
25 | 25 | ||
26 | Template.header.helpers({ | 26 | Template.header.helpers({ |
27 | example: function(){ | 27 | example: function(){ |
28 | // Code to run for helper function. | 28 | // Code to run for helper function. |
29 | } | 29 | } |
30 | }); | 30 | }); |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Events | 33 | * Events |
34 | */ | 34 | */ |
35 | 35 | ||
36 | Template.header.events({ | 36 | Template.header.events({ |
37 | 'click .logout': function(){ | 37 | 'click .logout': function(){ |
38 | Meteor.logout(function(error){ | 38 | Meteor.logout(function(error){ |
39 | if(error){ | 39 | if(error){ |
40 | Bert.alert(error.reason, 'danger'); | 40 | Bert.alert(error.reason, 'danger'); |
41 | } else { | 41 | } else { |
42 | Bert.alert('Succesfully logged out!', 'success'); | 42 | Bert.alert('Succesfully logged out!', 'success'); |
43 | } | 43 | } |
44 | }); | 44 | }); |
45 | } | 45 | } |
46 | }); | 46 | }); |
47 | 47 |
client/controllers/public/login.js
1 | /* | 1 | /* |
2 | * Controller: Login | 2 | * Controller: Login |
3 | * Template: /client/views/public/login.html | 3 | * Template: /client/views/public/login.html |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Created | 7 | * Created |
8 | */ | 8 | */ |
9 | 9 | ||
10 | Template.login.created = function(){ | 10 | Template.login.onCreated(function(){ |
11 | // Code to run when template is created goes here. | 11 | // Code to run when template is created goes here. |
12 | } | 12 | }); |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * Rendered | 15 | * Rendered |
16 | */ | 16 | */ |
17 | 17 | ||
18 | Template.login.rendered = function(){ | 18 | Template.login.onRendered(function(){ |
19 | $('#application-login').validate({ | 19 | $('#application-login').validate({ |
20 | rules: { | 20 | rules: { |
21 | emailAddress: { | 21 | emailAddress: { |
22 | required: true, | 22 | required: true, |
23 | email: true | 23 | email: true |
24 | }, | 24 | }, |
25 | password: { | 25 | password: { |
26 | required: true | 26 | required: true |
27 | } | 27 | } |
28 | }, | 28 | }, |
29 | messages: { | 29 | messages: { |
30 | emailAddress: { | 30 | emailAddress: { |
31 | required: "Please enter your email address to login.", | 31 | required: "Please enter your email address to login.", |
32 | email: "Please enter a valid email address." | 32 | email: "Please enter a valid email address." |
33 | }, | 33 | }, |
34 | password: { | 34 | password: { |
35 | required: "Please enter your password to login." | 35 | required: "Please enter your password to login." |
36 | } | 36 | } |
37 | }, | 37 | }, |
38 | submitHandler: function(){ | 38 | submitHandler: function(){ |
39 | // Grab the user's details. | 39 | // Grab the user's details. |
40 | user = { | 40 | user = { |
41 | email: $('[name="emailAddress"]').val(), | 41 | email: $('[name="emailAddress"]').val(), |
42 | password: $('[name="password"]').val() | 42 | password: $('[name="password"]').val() |
43 | } | 43 | } |
44 | 44 | ||
45 | // Log the user in. | 45 | // Log the user in. |
46 | Meteor.loginWithPassword(user.email, user.password, function(error){ | 46 | Meteor.loginWithPassword(user.email, user.password, function(error){ |
47 | if(error){ | 47 | if(error){ |
48 | Bert.alert(error.reason, 'danger'); | 48 | Bert.alert(error.reason, 'danger'); |
49 | } else { | 49 | } else { |
50 | Bert.alert('Logged in!', 'success'); | 50 | Bert.alert('Logged in!', 'success'); |
51 | } | 51 | } |
52 | }); | 52 | }); |
53 | } | 53 | } |
54 | }); | 54 | }); |
55 | } | 55 | }); |
56 | 56 | ||
57 | /* | 57 | /* |
58 | * Helpers | 58 | * Helpers |
59 | */ | 59 | */ |
60 | 60 | ||
61 | Template.login.helpers({ | 61 | Template.login.helpers({ |
62 | example: function(){ | 62 | example: function(){ |
63 | // Code to run for helper function. | 63 | // Code to run for helper function. |
64 | } | 64 | } |
65 | }); | 65 | }); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * Events | 68 | * Events |
69 | */ | 69 | */ |
70 | 70 | ||
71 | Template.login.events({ | 71 | Template.login.events({ |
72 | 'submit form': function(e){ | 72 | 'submit form': function(e){ |
73 | // Prevent form from submitting. | 73 | // Prevent form from submitting. |
74 | e.preventDefault(); | 74 | e.preventDefault(); |
75 | } | 75 | } |
76 | }); | 76 | }); |
77 | 77 |
client/controllers/public/recover-password.js
1 | /* | 1 | /* |
2 | * Controller: Recover Password | 2 | * Controller: Recover Password |
3 | * Template: /client/views/public/recover-password.html | 3 | * Template: /client/views/public/recover-password.html |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Created | 7 | * Created |
8 | */ | 8 | */ |
9 | 9 | ||
10 | Template.recoverPassword.created = function(){ | 10 | Template.recoverPassword.onCreated(function(){ |
11 | // Code to run when template is created goes here. | 11 | // Code to run when template is created goes here. |
12 | } | 12 | }); |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * Rendered | 15 | * Rendered |
16 | */ | 16 | */ |
17 | 17 | ||
18 | 18 | ||
19 | Template.recoverPassword.rendered = function(){ | 19 | Template.recoverPassword.onRendered(function(){ |
20 | $('#application-recover-password').validate({ | 20 | $('#application-recover-password').validate({ |
21 | rules: { | 21 | rules: { |
22 | emailAddress: { | 22 | emailAddress: { |
23 | required: true, | 23 | required: true, |
24 | email: true | 24 | email: true |
25 | } | 25 | } |
26 | }, | 26 | }, |
27 | messages: { | 27 | messages: { |
28 | emailAddress: { | 28 | emailAddress: { |
29 | required: "Please enter your email address to recover your password.", | 29 | required: "Please enter your email address to recover your password.", |
30 | email: "Please enter a valid email address." | 30 | email: "Please enter a valid email address." |
31 | } | 31 | } |
32 | }, | 32 | }, |
33 | submitHandler: function(){ | 33 | submitHandler: function(){ |
34 | // Grab the user's email address. | 34 | // Grab the user's email address. |
35 | var email = $('[name="emailAddress"]').val(); | 35 | var email = $('[name="emailAddress"]').val(); |
36 | 36 | ||
37 | // Call the send reset password email method. | 37 | // Call the send reset password email method. |
38 | Accounts.forgotPassword({email: email}, function(error){ | 38 | Accounts.forgotPassword({email: email}, function(error){ |
39 | if(error){ | 39 | if(error){ |
40 | Bert.alert(error.reason, 'danger'); | 40 | Bert.alert(error.reason, 'danger'); |
41 | } else { | 41 | } else { |
42 | Bert.alert('Check your inbox for a reset link!', 'success'); | 42 | Bert.alert('Check your inbox for a reset link!', 'success'); |
43 | } | 43 | } |
44 | }); | 44 | }); |
45 | } | 45 | } |
46 | }); | 46 | }); |
47 | } | 47 | }); |
48 | 48 | ||
49 | /* | 49 | /* |
50 | * Helpers | 50 | * Helpers |
51 | */ | 51 | */ |
52 | 52 | ||
53 | Template.recoverPassword.helpers({ | 53 | Template.recoverPassword.helpers({ |
54 | example: function(){ | 54 | example: function(){ |
55 | // Code to run for helper function. | 55 | // Code to run for helper function. |
56 | } | 56 | } |
57 | }); | 57 | }); |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * Events | 60 | * Events |
61 | */ | 61 | */ |
62 | 62 | ||
63 | Template.recoverPassword.events({ | 63 | Template.recoverPassword.events({ |
64 | 'submit form': function(e){ | 64 | 'submit form': function(e){ |
65 | // Prevent form from submitting. | 65 | // Prevent form from submitting. |
66 | e.preventDefault(); | 66 | e.preventDefault(); |
67 | } | 67 | } |
68 | }); | 68 | }); |
69 | 69 |
client/controllers/public/reset-password.js
1 | /* | 1 | /* |
2 | * Controller: Reset Password | 2 | * Controller: Reset Password |
3 | * Template: /client/views/public/reset-password.html | 3 | * Template: /client/views/public/reset-password.html |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Created | 7 | * Created |
8 | */ | 8 | */ |
9 | 9 | ||
10 | Template.resetPassword.created = function(){ | 10 | Template.resetPassword.onCreated(function(){ |
11 | // Code to run when template is created goes here. | 11 | // Code to run when template is created goes here. |
12 | } | 12 | }); |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * Rendered | 15 | * Rendered |
16 | */ | 16 | */ |
17 | 17 | ||
18 | Template.resetPassword.rendered = function(){ | 18 | Template.resetPassword.onRendered(function(){ |
19 | $('#application-reset-password').validate({ | 19 | $('#application-reset-password').validate({ |
20 | rules: { | 20 | rules: { |
21 | newPassword: { | 21 | newPassword: { |
22 | required: true, | 22 | required: true, |
23 | minlength: 6 | 23 | minlength: 6 |
24 | }, | 24 | }, |
25 | repeatNewPassword: { | 25 | repeatNewPassword: { |
26 | required: true, | 26 | required: true, |
27 | minlength: 6, | 27 | minlength: 6, |
28 | equalTo: "[name='newPassword']" | 28 | equalTo: "[name='newPassword']" |
29 | } | 29 | } |
30 | }, | 30 | }, |
31 | messages: { | 31 | messages: { |
32 | newPassword: { | 32 | newPassword: { |
33 | required: "Please enter a new password.", | 33 | required: "Please enter a new password.", |
34 | minlength: "Please use at least six characters." | 34 | minlength: "Please use at least six characters." |
35 | }, | 35 | }, |
36 | repeatNewPassword: { | 36 | repeatNewPassword: { |
37 | required: "Please repeat your new password.", | 37 | required: "Please repeat your new password.", |
38 | equalTo: "Your password do not match. Please try again." | 38 | equalTo: "Your password do not match. Please try again." |
39 | } | 39 | } |
40 | }, | 40 | }, |
41 | submitHandler: function(){ | 41 | submitHandler: function(){ |
42 | // Grab the user's reset token and new password. | 42 | // Grab the user's reset token and new password. |
43 | var token = Session.get('resetPasswordToken'), | 43 | var token = Session.get('resetPasswordToken'), |
44 | password = $('[name="newPassword"]').val(); | 44 | password = $('[name="newPassword"]').val(); |
45 | 45 | ||
46 | // Reset the user's password. | 46 | // Reset the user's password. |
47 | Accounts.resetPassword(token, password, function(error){ | 47 | Accounts.resetPassword(token, password, function(error){ |
48 | if(error){ | 48 | if(error){ |
49 | Bert.alert(error.reason, 'danger'); | 49 | Bert.alert(error.reason, 'danger'); |
50 | } else { | 50 | } else { |
51 | Bert.alert('Password successfully reset!', 'success'); | 51 | Bert.alert('Password successfully reset!', 'success'); |
52 | Session.set('resetPasswordToken', null); | 52 | Session.set('resetPasswordToken', null); |
53 | } | 53 | } |
54 | }); | 54 | }); |
55 | } | 55 | } |
56 | }); | 56 | }); |
57 | } | 57 | }); |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * Helpers | 60 | * Helpers |
61 | */ | 61 | */ |
62 | 62 | ||
63 | Template.resetPassword.helpers({ | 63 | Template.resetPassword.helpers({ |
64 | example: function(){ | 64 | example: function(){ |
65 | // Code to run for helper function. | 65 | // Code to run for helper function. |
66 | } | 66 | } |
67 | }); | 67 | }); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Events | 70 | * Events |
71 | */ | 71 | */ |
72 | 72 | ||
73 | Template.resetPassword.events({ | 73 | Template.resetPassword.events({ |
74 | 'submit form': function(e){ | 74 | 'submit form': function(e){ |
75 | // Prevent form from submitting. | 75 | // Prevent form from submitting. |
76 | e.preventDefault(); | 76 | e.preventDefault(); |
77 | } | 77 | } |
78 | }); | 78 | }); |
79 | 79 |
client/controllers/public/signup.js
1 | /* | 1 | /* |
2 | * Controller: Signup | 2 | * Controller: Signup |
3 | * Template: /client/views/public/signup.html | 3 | * Template: /client/views/public/signup.html |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* | 6 | /* |
7 | * Created | 7 | * Created |
8 | */ | 8 | */ |
9 | 9 | ||
10 | Template.signup.created = function(){ | 10 | Template.signup.onCreated(function(){ |
11 | // Code to run when template is created goes here. | 11 | // Code to run when template is created goes here. |
12 | } | 12 | }); |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * Rendered | 15 | * Rendered |
16 | */ | 16 | */ |
17 | 17 | ||
18 | Template.signup.rendered = function(){ | 18 | Template.signup.onRendered(function(){ |
19 | $('#application-signup').validate({ | 19 | $('#application-signup').validate({ |
20 | rules: { | 20 | rules: { |
21 | emailAddress: { | 21 | emailAddress: { |
22 | required: true, | 22 | required: true, |
23 | email: true | 23 | email: true |
24 | }, | 24 | }, |
25 | password: { | 25 | password: { |
26 | required: true, | 26 | required: true, |
27 | minlength: 6 | 27 | minlength: 6 |
28 | } | 28 | } |
29 | }, | 29 | }, |
30 | messages: { | 30 | messages: { |
31 | emailAddress: { | 31 | emailAddress: { |
32 | required: "Please enter your email address to sign up.", | 32 | required: "Please enter your email address to sign up.", |
33 | email: "Please enter a valid email address." | 33 | email: "Please enter a valid email address." |
34 | }, | 34 | }, |
35 | password: { | 35 | password: { |
36 | required: "Please enter a password to sign up.", | 36 | required: "Please enter a password to sign up.", |
37 | minlength: "Please use at least six characters." | 37 | minlength: "Please use at least six characters." |
38 | } | 38 | } |
39 | }, | 39 | }, |
40 | submitHandler: function(){ | 40 | submitHandler: function(){ |
41 | // Grab the user's details. | 41 | // Grab the user's details. |
42 | user = { | 42 | user = { |
43 | email: $('[name="emailAddress"]').val(), | 43 | email: $('[name="emailAddress"]').val(), |
44 | password: $('[name="password"]').val() | 44 | password: $('[name="password"]').val() |
45 | } | 45 | } |
46 | 46 | ||
47 | // Create the user's account. | 47 | // Create the user's account. |
48 | Accounts.createUser({email: user.email, password: user.password}, function(error){ | 48 | Accounts.createUser({email: user.email, password: user.password}, function(error){ |
49 | if(error){ | 49 | if(error){ |
50 | Bert.alert(error.reason, 'danger'); | 50 | Bert.alert(error.reason, 'danger'); |
51 | } else { | 51 | } else { |
52 | Bert.alert('Welcome!', 'success'); | 52 | Bert.alert('Welcome!', 'success'); |
53 | } | 53 | } |
54 | }); | 54 | }); |
55 | } | 55 | } |
56 | }); | 56 | }); |
57 | } | 57 | }); |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * Helpers | 60 | * Helpers |
61 | */ | 61 | */ |
62 | 62 | ||
63 | Template.signup.helpers({ | 63 | Template.signup.helpers({ |
64 | example: function(){ | 64 | example: function(){ |
65 | // Code to run for helper function. | 65 | // Code to run for helper function. |
66 | } | 66 | } |
67 | }); | 67 | }); |
68 | 68 | ||
69 | /* | 69 | /* |
70 | * Events | 70 | * Events |
71 | */ | 71 | */ |
72 | 72 | ||
73 | Template.signup.events({ | 73 | Template.signup.events({ |
74 | 'submit form': function(e){ | 74 | 'submit form': function(e){ |
75 | // Prevent form from submitting. | 75 | // Prevent form from submitting. |
76 | e.preventDefault(); | 76 | e.preventDefault(); |
77 | } | 77 | } |
78 | }); | 78 | }); |
79 | 79 |