From 333e8fb415af28422b7d4693f7a671a706eb7dcd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 15 Sep 2015 22:36:52 +0200 Subject: [PATCH] Disabled user popover for avatar in footer of navbar. Removed vip icon for avatar in footer of navbar. --- .../app/controllers/_default_navbar.js.coffee | 4 +- .../app/controllers/navigation.js.coffee | 2 +- .../app/controllers/widget/avatar.js.coffee | 6 +-- .../javascripts/app/models/user.js.coffee | 41 +++++++++++-------- .../javascripts/app/views/avatar.jst.eco | 2 +- .../app/views/profile/avatar-holder.jst.eco | 2 +- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_default_navbar.js.coffee b/app/assets/javascripts/app/controllers/_default_navbar.js.coffee index 9cb526801..049fe1ae2 100644 --- a/app/assets/javascripts/app/controllers/_default_navbar.js.coffee +++ b/app/assets/javascripts/app/controllers/_default_navbar.js.coffee @@ -4,9 +4,7 @@ App.Config.set('User', { parent: '', callback: -> item = {} - item['name'] = App.Session.get( 'login' ) - if App.Session.get() - item['avatar'] = App.Session.get().avatar() + item['name'] = App.Session.get('login') return item target: '#current_user', class: 'user' diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index e71c29d1e..6122fab89 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -91,7 +91,7 @@ class App.Navigation extends App.ControllerWidgetPermanent new App.WidgetAvatar( el: @$('.js-avatar') user_id: App.Session.get('id') - noPopups: true + type: 'personal' ) renderResult: (result = []) => diff --git a/app/assets/javascripts/app/controllers/widget/avatar.js.coffee b/app/assets/javascripts/app/controllers/widget/avatar.js.coffee index ac13989d9..331ba8bc7 100644 --- a/app/assets/javascripts/app/controllers/widget/avatar.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/avatar.js.coffee @@ -3,7 +3,7 @@ class App.WidgetAvatar extends App.Controller super # subscribe and reload data / fetch new data if triggered - @subscribeId = App.User.full( @user_id, @render, false, true ) + @subscribeId = App.User.full(@user_id, @render, false, true) release: => App.User.unsubscribe(@subscribeId) @@ -13,8 +13,8 @@ class App.WidgetAvatar extends App.Controller user: user size: @size position: @position + type: @type ) # start user popups - if !@noPopups - @userPopups(@position) + @userPopups(@position) diff --git a/app/assets/javascripts/app/models/user.js.coffee b/app/assets/javascripts/app/models/user.js.coffee index 1a883452a..d22484a4a 100644 --- a/app/assets/javascripts/app/models/user.js.coffee +++ b/app/assets/javascripts/app/models/user.js.coffee @@ -53,49 +53,58 @@ class App.User extends App.Model else return '??' - avatar: (size = 40, placement = '', cssClass = '', unique = false, avatar) -> + avatar: (size = 40, placement = '', cssClass = '', unique = false, avatar, type = undefined) -> cssClass += " size-#{size}" if placement placement = "data-placement=\"#{placement}\"" + # use generated avatar if !@image || @image is 'none' || unique - return @uniqueAvatar(size, placement, cssClass, avatar) + return @uniqueAvatar(size, placement, cssClass, avatar, type) + + # use image as avatar + image = @imageUrl() + vip = @vip + if type is 'personal' + vip = false else - image = @imageUrl() + cssClass += ' user-popover' - # TODO: don't show vip when its the avatar of the logged-in user - if @vip - return "" - else - return "" + if vip + return "" + "" - uniqueAvatar: (size, placement = '', cssClass = '', avatar) -> + uniqueAvatar: (size, placement = '', cssClass = '', avatar, type) -> width = 300 height = 226 size = parseInt(size, 10) + vip = @vip rng = new Math.seedrandom(@id) x = rng() * (width - size) y = rng() * (height - size) if !avatar - cssClass += " user-popover" - data = "data-id=\"#{@id}\"" + if type is 'personal' + vip = false + data = "data-id=\"#{@id}\"" + else + cssClass += " user-popover" + data = "data-id=\"#{@id}\"" else - data = "data-avatar-id=\"#{avatar.id}\"" + vip = false + data = "data-avatar-id=\"#{avatar.id}\"" - if @vip + if vip return "#{ @initials() }" - else - return "#{ @initials() }" + "#{ @initials() }" imageUrl: -> return if !@image # set image url @constructor.apiPath + '/users/image/' + @image - @_fillUp: (data) -> # set socal media links diff --git a/app/assets/javascripts/app/views/avatar.jst.eco b/app/assets/javascripts/app/views/avatar.jst.eco index a8c83f7c0..3beb48952 100644 --- a/app/assets/javascripts/app/views/avatar.jst.eco +++ b/app/assets/javascripts/app/views/avatar.jst.eco @@ -1 +1 @@ -<%- @user.avatar(@size, @position, @class) %> \ No newline at end of file +<%- @user.avatar(@size, @position, @class, false, false, @type) %> \ No newline at end of file diff --git a/app/assets/javascripts/app/views/profile/avatar-holder.jst.eco b/app/assets/javascripts/app/views/profile/avatar-holder.jst.eco index 2745ae227..f37574a8e 100644 --- a/app/assets/javascripts/app/views/profile/avatar-holder.jst.eco +++ b/app/assets/javascripts/app/views/profile/avatar-holder.jst.eco @@ -1,5 +1,5 @@
- +
<%- @Icon('diagonal-cross') %>