Browse code

Zobrazovanie avatarov

Cinan Rakosnik authored on 24/03/2013 at 23:06:34
Showing 8 changed files
... ...
@@ -41,7 +41,12 @@ this.App =
41 41
 
42 42
     getMe: ->
43 43
       App.Com.trigger(event: 'app.roster.myself', success: (response) ->
44
-        App.Models.me = new Xmpp.Models.Me(jid: response.jid, name: response.vcard.name, status: response.status)
44
+        App.Models.me = new Xmpp.Models.Me(
45
+          jid: response.jid
46
+          name: response.vcard.name
47
+          status: response.status
48
+          avatar: response.vcard.avatar
49
+        )
45 50
       )
46 51
 
47 52
     _setupBackboneComponents: ->
... ...
@@ -6,6 +6,7 @@ class Xmpp.Models.Contact extends Xmpp.Models.Model
6 6
     name: ''
7 7
     status: 'offline'
8 8
     message: ''
9
+    avatar: ''
9 10
 
10 11
   initialize: ->
11 12
     _.bindAll(this)
... ...
@@ -33,4 +34,4 @@ class Xmpp.Collections.ContactsCollection extends Backbone.Collection
33 33
     @get(response.jid).set(message: response.status.message, status: response.status.status)
34 34
 
35 35
   udpateVcard: (response) ->
36
-    @get(response.jid).set(name: response.vcard.name)
37 36
\ No newline at end of file
37
+    @get(response.jid).set(name: response.vcard.name, avatar: response.vcard.avatar)
38 38
\ No newline at end of file
... ...
@@ -6,9 +6,10 @@ class Xmpp.Models.Me extends Xmpp.Models.Model
6 6
     name: ''
7 7
     status: 'online'
8 8
     message: ''
9
+    avatar: ''
9 10
 
10 11
   initialize: ->
11 12
     _.bindAll(this)
12 13
 
13
-    @view = new Xmpp.Views.Contacts.Me(model: this)
14
+    @view = new Xmpp.Views.Contacts.MeView(model: this)
14 15
     @view.render()
15 16
\ No newline at end of file
... ...
@@ -1,5 +1,5 @@
1 1
 .avatar
2
-  %img{src: 'assets/avatar.png', alt: I18n.t("chat.roster.avatar_alt") }
2
+  %img{src: "#{@avatar || 'assets/avatar.png'}", alt: I18n.t("chat.roster.avatar_alt") }
3 3
 %h1
4 4
   #{@name}
5 5
   %span.status.icon-record{class: "#{@status}"}
... ...
@@ -1,6 +1,6 @@
1 1
 .user
2 2
   .avatar.bigger{ title: "#{@jid}" }
3
-    %img{ src: 'assets/avatar.png', alt: I18n.t("chat.roster.avatar_alt") }
3
+    %img{ src: "#{@avatar || 'assets/avatar.png'}", alt: I18n.t("chat.roster.avatar_alt") }
4 4
   %h1{ title: "#{@jid}"} #{@name }
5 5
   %h2 #{@message || '<i>'+I18n.t('chat.roster.change_status_msg')+'</i>'}
6 6
   %h3
... ...
@@ -1,6 +1,6 @@
1 1
 Xmpp.Views.Contacts ||= {}
2 2
 
3
-class Xmpp.Views.Contacts.Me extends Backbone.View
3
+class Xmpp.Views.Contacts.MeView extends Backbone.View
4 4
   template: JST["backbone/templates/contacts/me"]
5 5
   el: $('#js-me')
6 6
 
... ...
@@ -15,6 +15,5 @@ class Xmpp.Views.Contacts.Me extends Backbone.View
15 15
 
16 16
   render: ->
17 17
     contact = @model.toJSON()
18
-    App.debug contact
19 18
     $(@el).html(@template(contact))
20 19
     this
21 20
\ No newline at end of file
... ...
@@ -62,13 +62,23 @@
62 62
 
63 63
   .avatar {
64 64
     float: left;
65
+
66
+    height: 32px;
67
+    width: 32px;
68
+
65 69
     margin-right: 8px;
66 70
 
67 71
     img {
68 72
       height: 32px;
73
+
74
+      margin: 0 auto;
75
+      display: block;
69 76
     }
70 77
 
71 78
     &.bigger {
79
+      height: 46px;
80
+      width: 46px;
81
+
72 82
       img {
73 83
         height: 46px;
74 84
       }
... ...
@@ -126,7 +126,11 @@ class WsRosterController < WebsocketRails::BaseController
126 126
             client.close()
127 127
         end
128 128
 
129
-        @storages.each do |storage|
129
+        @storages_arr.each do |storage|
130
+            connection_store.delete(storage)
131
+        end
132
+
133
+        @storages_hash.each do |storage|
130 134
             connection_store.delete(storage)
131 135
         end
132 136
     end
... ...
@@ -143,7 +147,7 @@ class WsRosterController < WebsocketRails::BaseController
143 143
         vcard = Jabber::Vcard::Helper.get(me, contact_jid)
144 144
 
145 145
         { name: pull_name_from_vcard(vcard) || contact_jid,
146
-          avatar: '' #TODO avatar
146
+          avatar: vcard["PHOTO/TYPE"] && ('data:' + vcard["PHOTO/TYPE"] + ';base64,' + vcard.photo_binval) || ''
147 147
         }
148 148
     end
149 149