Skip to content

Commit

Permalink
remove the 'avatar' helper and make 'avatarUrl' a global helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayman committed Jul 13, 2014
1 parent c4b86e7 commit b5c8426
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
17 changes: 6 additions & 11 deletions client/lib/globalhelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ Handlebars.registerHelper('username', function(user){
}
});

//avatar as responsive image
Handlebars.registerHelper('avatar', function(id){
if(Meteor.users.findOne(id) == null) { return; }
var avatar = Meteor.users.findOne(id).profile.avatar;
var url="/img/avatar.jpg"
if (avatar) {
var url=avatar;
Template.userProfile.avatarUrl = function() {
if(this.profile.avatar) {
return this.profile.avatar;
} else {
return "/img/avatar.jpg";
}
return '<img class="img-circle img-responsive avatar" src="'+url+'">';
});


};

Handlebars.registerHelper('currentRoute', function() {
var currentRoute = Router.current();
Expand Down
2 changes: 1 addition & 1 deletion client/views/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="row">
<div class="col-md-4">
<div class="col-md-6">
{{{avatar _id}}}
<img class="img-circle img-responsive avatar" src="{{avatarUrl profile.avatar}}">
</div>
{{#if isOwner}}
<div class="col-md-12">
Expand Down
8 changes: 0 additions & 8 deletions client/views/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ Template.userProfile.userFriends = function() {
return Meteor.users.find({_id: {$in: friends}});
};

Template.userProfile.avatarUrl = function() {
if(this.profile.avatar) {
return this.profile.avatar;
} else {
return "/img/avatar.jpg";
}
};

Template.userProfile.events = {
'click [data-action="set-username"]': function() {
var newname = $("input#new-username").val();
Expand Down

0 comments on commit b5c8426

Please sign in to comment.