-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from RocketChat/avatar-from-username
Avatar from username
- Loading branch information
Showing
20 changed files
with
148 additions
and
754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,13 @@ | ||
Template.avatarPrompt.onCreated -> | ||
self = this | ||
self.suggestions = new ReactiveVar | ||
self.upload = new ReactiveVar | ||
|
||
self.getSuggestions = -> | ||
self.suggestions.set undefined | ||
Meteor.call 'getAvatarSuggestion', (error, avatars) -> | ||
self.suggestions.set | ||
ready: true | ||
avatars: avatars | ||
|
||
self.getSuggestions() | ||
|
||
|
||
Template.avatarPrompt.helpers | ||
suggestions: -> | ||
return Template.instance().suggestions.get() | ||
|
||
upload: -> | ||
return Template.instance().upload.get() | ||
|
||
|
||
Template.avatarPrompt.events | ||
'click .select-service': (e) -> | ||
Meteor.call 'setAvatarFromService', this.blob, this.service, -> | ||
console.log arguments | ||
|
||
'click .login-with-service': (event, template) -> | ||
loginWithService = "loginWith#{_.capitalize(this)}" | ||
|
||
serviceConfig = {} | ||
|
||
Meteor[loginWithService] serviceConfig, (error) -> | ||
if error?.error is 'github-no-public-email' | ||
alert t("loginServices.github_no_public_email") | ||
return | ||
|
||
console.log error | ||
if error? | ||
toastr.error error.message | ||
return | ||
|
||
template.getSuggestions() | ||
|
||
'change .myFileInput': (event, template) -> | ||
FS.Utility.eachFile event, (blob) -> | ||
reader = new FileReader() | ||
reader.readAsDataURL(blob) | ||
reader.onloadend = -> | ||
template.upload.set | ||
service: 'upload' | ||
blob: reader.result | ||
Template.avatar.helpers | ||
dimensions: -> | ||
return { | ||
width: 40 | ||
height: 40 | ||
} | ||
|
||
imageUrl: -> | ||
username = this.username | ||
if not username? and this.userId? | ||
username = Meteor.users.findOne(this.userId)?.username | ||
url = "#{Meteor.absoluteUrl()}/avatar/#{username}" | ||
return url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,6 @@ | ||
<template name="avatarSuggestion"> | ||
{{#if .}} | ||
<div class="avatar-suggestion-item"> | ||
<div style="background-image: url({{blob}});"> | ||
</div> | ||
<button type="button" class="button primary select-service">{{_ "avatar.Use_service_avatar" service}}</button> | ||
</div> | ||
{{/if}} | ||
</template> | ||
|
||
<template name="avatarSuggestionLogin"> | ||
{{#if .}} | ||
<div class="avatar-suggestion-item"> | ||
<div class="question-mark"></div> | ||
<button type="button" class="button primary login-with-service">{{_ "avatar.Login_with" .}}</button> | ||
</div> | ||
{{/if}} | ||
</template> | ||
|
||
<template name="avatarPrompt"> | ||
<form id="login-card" method='/'> | ||
<div class="fields"> | ||
<h2>{{_ "avatar.Select_an_avatar"}}</h2> | ||
</div> | ||
<div class="fields"> | ||
<div class='input-text active'> | ||
<div class='field'> | ||
<div class="avatar-suggestions"> | ||
{{#if suggestions.ready}} | ||
{{> avatarSuggestion suggestions.avatars.gravatar}} | ||
{{> avatarSuggestion suggestions.avatars.facebook}} | ||
{{> avatarSuggestion suggestions.avatars.google}} | ||
{{> avatarSuggestion suggestions.avatars.github}} | ||
|
||
{{#unless suggestions.avatars.facebook}} | ||
{{> avatarSuggestionLogin 'facebook'}} | ||
{{/unless}} | ||
{{#unless suggestions.avatars.google}} | ||
{{> avatarSuggestionLogin 'google'}} | ||
{{/unless}} | ||
{{#unless suggestions.avatars.github}} | ||
{{> avatarSuggestionLogin 'github'}} | ||
{{/unless}} | ||
|
||
<div class="avatar-suggestion-item"> | ||
<div style="background-image: url({{upload.blob}});" class="{{#unless upload}}question-mark{{/unless}}"> | ||
</div> | ||
{{#with upload}} | ||
<button type="button" class="button primary select-service">{{_ "avatar.Use_uploaded_avatar"}}</button> | ||
{{/with}} | ||
{{#unless upload}} | ||
<button type="button" class="button primary">{{_ "avatar.Select_file"}} | ||
<input type="file" class="myFileInput"> | ||
</button> | ||
{{/unless}} | ||
</div> | ||
{{else}} | ||
{{_ "usernameRegistration.Loading_suggestion"}} | ||
{{/if}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{#if username.ready}} | ||
<div class="submit"> | ||
<button data-loading-text="{{_ "general.Please_wait"}}..." class='button primary login'><span>{{_ "usernameRegistration.Use_this_username"}}</span></button> | ||
</div> | ||
{{/if}} | ||
</form> | ||
</template> | ||
<template name="avatar"> | ||
<div class="avatar"> | ||
<img class="avatar-image" src="/images/pixel.png" style="background-image:url({{imageUrl}});" alt="avatar" /> | ||
<span class="avatar-initials" style="{{initialsCss}}">{{initialsText}}</span> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Template.avatarPrompt.onCreated -> | ||
self = this | ||
self.suggestions = new ReactiveVar | ||
self.upload = new ReactiveVar | ||
|
||
self.getSuggestions = -> | ||
self.suggestions.set undefined | ||
Meteor.call 'getAvatarSuggestion', (error, avatars) -> | ||
self.suggestions.set | ||
ready: true | ||
avatars: avatars | ||
|
||
self.getSuggestions() | ||
|
||
|
||
Template.avatarPrompt.helpers | ||
suggestions: -> | ||
return Template.instance().suggestions.get() | ||
|
||
upload: -> | ||
return Template.instance().upload.get() | ||
|
||
|
||
Template.avatarPrompt.events | ||
'click .select-service': (e) -> | ||
Meteor.call 'setAvatarFromService', this.blob, this.service, -> | ||
console.log arguments | ||
|
||
'click .login-with-service': (event, template) -> | ||
loginWithService = "loginWith#{_.capitalize(this)}" | ||
|
||
serviceConfig = {} | ||
|
||
Meteor[loginWithService] serviceConfig, (error) -> | ||
if error?.error is 'github-no-public-email' | ||
alert t("loginServices.github_no_public_email") | ||
return | ||
|
||
console.log error | ||
if error? | ||
toastr.error error.message | ||
return | ||
|
||
template.getSuggestions() | ||
|
||
'change .myFileInput': (event, template) -> | ||
FS.Utility.eachFile event, (blob) -> | ||
reader = new FileReader() | ||
reader.readAsDataURL(blob) | ||
reader.onloadend = -> | ||
template.upload.set | ||
service: 'upload' | ||
blob: reader.result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template name="avatarSuggestion"> | ||
{{#if .}} | ||
<div class="avatar-suggestion-item"> | ||
<div style="background-image: url({{blob}});"> | ||
</div> | ||
<button type="button" class="button primary select-service">{{_ "avatar.Use_service_avatar" service}}</button> | ||
</div> | ||
{{/if}} | ||
</template> | ||
|
||
<template name="avatarSuggestionLogin"> | ||
{{#if .}} | ||
<div class="avatar-suggestion-item"> | ||
<div class="question-mark"></div> | ||
<button type="button" class="button primary login-with-service">{{_ "avatar.Login_with" .}}</button> | ||
</div> | ||
{{/if}} | ||
</template> | ||
|
||
<template name="avatarPrompt"> | ||
<form id="login-card" method='/'> | ||
<div class="fields"> | ||
<h2>{{_ "avatar.Select_an_avatar"}}</h2> | ||
</div> | ||
<div class="fields"> | ||
<div class='input-text active'> | ||
<div class='field'> | ||
<div class="avatar-suggestions"> | ||
{{#if suggestions.ready}} | ||
{{> avatarSuggestion suggestions.avatars.gravatar}} | ||
{{> avatarSuggestion suggestions.avatars.facebook}} | ||
{{> avatarSuggestion suggestions.avatars.google}} | ||
{{> avatarSuggestion suggestions.avatars.github}} | ||
|
||
{{#unless suggestions.avatars.facebook}} | ||
{{> avatarSuggestionLogin 'facebook'}} | ||
{{/unless}} | ||
{{#unless suggestions.avatars.google}} | ||
{{> avatarSuggestionLogin 'google'}} | ||
{{/unless}} | ||
{{#unless suggestions.avatars.github}} | ||
{{> avatarSuggestionLogin 'github'}} | ||
{{/unless}} | ||
|
||
<div class="avatar-suggestion-item"> | ||
<div style="background-image: url({{upload.blob}});" class="{{#unless upload}}question-mark{{/unless}}"> | ||
</div> | ||
{{#with upload}} | ||
<button type="button" class="button primary select-service">{{_ "avatar.Use_uploaded_avatar"}}</button> | ||
{{/with}} | ||
{{#unless upload}} | ||
<button type="button" class="button primary">{{_ "avatar.Select_file"}} | ||
<input type="file" class="myFileInput"> | ||
</button> | ||
{{/unless}} | ||
</div> | ||
{{else}} | ||
{{_ "usernameRegistration.Loading_suggestion"}} | ||
{{/if}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{#if username.ready}} | ||
<div class="submit"> | ||
<button data-loading-text="{{_ "general.Please_wait"}}..." class='button primary login'><span>{{_ "usernameRegistration.Use_this_username"}}</span></button> | ||
</div> | ||
{{/if}} | ||
</form> | ||
</template> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.