Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REFACTOR: new 'show-avatar-select' app event to trigger the avatar se…
…lector modal
- Loading branch information
Showing
12 changed files
with
99 additions
and
118 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
31 changes: 31 additions & 0 deletions
31
app/assets/javascripts/discourse/initializers/avatar-select.js.es6
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,31 @@ | ||
import showModal from "discourse/lib/show-modal"; | ||
import { ajax } from "discourse/lib/ajax"; | ||
|
||
export default { | ||
name: "avatar-select", | ||
|
||
initialize(container) { | ||
const siteSettings = container.lookup("site-settings:main"); | ||
const appEvents = container.lookup("app-events:main"); | ||
|
||
appEvents.on("show-avatar-select", user => { | ||
const avatarTemplate = user.get("avatar_template"); | ||
let selected = "uploaded"; | ||
|
||
if (avatarTemplate === user.get("system_avatar_template")) { | ||
selected = "system"; | ||
} else if (avatarTemplate === user.get("gravatar_avatar_template")) { | ||
selected = "gravatar"; | ||
} | ||
|
||
const modal = showModal("avatar-selector"); | ||
modal.setProperties({ user, selected }); | ||
|
||
if (siteSettings.selectable_avatars_enabled) { | ||
ajax("/site/selectable-avatars.json").then(avatars => | ||
modal.set("selectableAvatars", avatars) | ||
); | ||
} | ||
}); | ||
} | ||
}; |
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
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/discourse/templates/components/user-profile-avatar.hbs
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,11 @@ | ||
<div class='user-profile-avatar'> | ||
{{bound-avatar user "huge"}} | ||
{{#if user.primary_group_name}} | ||
{{avatar-flair | ||
flairURL=user.primary_group_flair_url | ||
flairBgColor=user.primary_group_flair_bg_color | ||
flairColor=user.primary_group_flair_color | ||
groupName=user.primary_group_name}} | ||
{{/if}} | ||
{{plugin-outlet name="user-profile-avatar-flair" args=(hash model=user) tagName='div'}} | ||
</div> |
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 |
---|---|---|
|
@@ -151,7 +151,6 @@ | |
} | ||
|
||
.user-profile-avatar { | ||
cursor: pointer; | ||
position: relative; | ||
float: left; | ||
height: 100%; | ||
|
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