| ... | ... |
@@ -27,6 +27,16 @@ class Xmpp.Models.Chat extends Xmpp.Models.Model |
| 27 | 27 |
App.debug ['multichat has id', id] |
| 28 | 28 |
@set('chatId', id)
|
| 29 | 29 |
|
| 30 |
+ isMeOwner: -> |
|
| 31 |
+ @get('who') == App.Models.me
|
|
| 32 |
+ |
|
| 33 |
+ isAttending: (contact) -> |
|
| 34 |
+ attendants = @get('withWhom')
|
|
| 35 |
+ if _.isArray(attendants) |
|
| 36 |
+ return _.find(attendants, (somebody) -> somebody == contact) |
|
| 37 |
+ else |
|
| 38 |
+ return contact == attendants |
|
| 39 |
+ |
|
| 30 | 40 |
syncContacts: (contacts, owner) -> |
| 31 | 41 |
contactsWithoutMe = _.filter(contacts, (jid) -> |
| 32 | 42 |
jid != App.Models.me.get('jid')
|
| ... | ... |
@@ -60,6 +70,7 @@ class Xmpp.Models.Chat extends Xmpp.Models.Model |
| 60 | 60 |
|
| 61 | 61 |
class Xmpp.Collections.ChatsCollection extends Backbone.Collection |
| 62 | 62 |
model: Xmpp.Models.Chat |
| 63 |
+ activeChat: null |
|
| 63 | 64 |
|
| 64 | 65 |
initialize: -> |
| 65 | 66 |
_.bindAll(this) |
| ... | ... |
@@ -68,6 +79,10 @@ class Xmpp.Collections.ChatsCollection extends Backbone.Collection |
| 68 | 68 |
@removeChat(chat) |
| 69 | 69 |
) |
| 70 | 70 |
|
| 71 |
+ Backbone.Events.on('openChat', (chat) =>
|
|
| 72 |
+ @activeChat = chat |
|
| 73 |
+ ) |
|
| 74 |
+ |
|
| 71 | 75 |
find: (who, withWhom) -> |
| 72 | 76 |
_.find(@models, (chat) -> |
| 73 | 77 |
chat.get('who') == who && chat.get('withWhom') == withWhom
|
| ... | ... |
@@ -5,11 +5,18 @@ |
| 5 | 5 |
%span.status.icon-record{class: "#{@status}"}
|
| 6 | 6 |
%h2 #{@message}
|
| 7 | 7 |
%span.action |
| 8 |
- -if @usingMyApp |
|
| 9 |
- %span.icon-bubbles.chat |
|
| 10 |
- %span chat |
|
| 11 |
- -#%span.icon-bubbles.invite |
|
| 8 |
+ -#-if @usingMyApp |
|
| 9 |
+ %span.icon-bubbles.multichat |
|
| 10 |
+ -# ak nemam otvoreny multichat |
|
| 11 |
+ %span multi |
|
| 12 |
+ %span.icon-bubbles.invite |
|
| 13 |
+ -# ak nie je v multichate a mam otvoreny multichat a som admin toho multichatu |
|
| 12 | 14 |
%span invite |
| 15 |
+ %span.icon-x-full.kick |
|
| 16 |
+ -# ak som admin otvoreneho multichatu |
|
| 17 |
+ %span kick |
|
| 18 |
+ -#%span.icon-x-full.remove |
|
| 19 |
+ %span remove |
|
| 13 | 20 |
|
| 14 | 21 |
-# .avatar |
| 15 | 22 |
-# %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
|
| ... | ... |
@@ -17,9 +24,6 @@ |
| 17 | 17 |
-# Bob Awesome |
| 18 | 18 |
-# %span.status.dnd.icon-record |
| 19 | 19 |
-# %h2 sales manager |
| 20 |
--# %span.action |
|
| 21 |
--# %span.icon-x-full |
|
| 22 |
--# %span kick |
|
| 23 | 20 |
-#%li.clear.user |
| 24 | 21 |
-# .avatar |
| 25 | 22 |
-# %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
|
| ... | ... |
@@ -7,7 +7,7 @@ class Xmpp.Views.Contacts.ContactView extends Backbone.View |
| 7 | 7 |
|
| 8 | 8 |
events: |
| 9 | 9 |
'click .invite': 'inviteToMultichat' |
| 10 |
- 'click .chat': 'newMultiChat' |
|
| 10 |
+ 'click .multichat': 'newMultiChat' |
|
| 11 | 11 |
click: 'startChat' |
| 12 | 12 |
mouseover: 'showIcons' |
| 13 | 13 |
mouseleave: 'hideIcons' |
| ... | ... |
@@ -76,6 +76,19 @@ class Xmpp.Views.Contacts.ContactView extends Backbone.View |
| 76 | 76 |
chat = App.Collections.chats.findById(chatId) |
| 77 | 77 |
|
| 78 | 78 |
showIcons: -> |
| 79 |
+ activeChat = App.Collections.chats.activeChat |
|
| 80 |
+ |
|
| 81 |
+ $(@el).find('.action .multichat, .action .invite, .action .kick').hide()
|
|
| 82 |
+ |
|
| 83 |
+ if (@model.get('usingMyApp') == true)
|
|
| 84 |
+ if not activeChat or not activeChat.get('isMultiChat')
|
|
| 85 |
+ $(@el).find('.action .multichat').show()
|
|
| 86 |
+ else if activeChat.get('isMultiChat') and activeChat.isMeOwner() and not activeChat.isAttending(@model)
|
|
| 87 |
+ $(@el).find('.action .invite').show()
|
|
| 88 |
+ else if activeChat.get('isMultiChat') and activeChat.isMeOwner()
|
|
| 89 |
+ $(@el).find('.action .kick').show()
|
|
| 90 |
+ |
|
| 91 |
+ |
|
| 79 | 92 |
$(@el).find('.action').show()
|
| 80 | 93 |
|
| 81 | 94 |
hideIcons: -> |