Browse code

Zobrazenie chatovacieho okna pri zacati konverzacie

Cinan Rakosnik authored on 27/03/2013 at 10:26:35
Showing 10 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+.event
1
+  Monday 13.2.2013
0 2
\ No newline at end of file
1 3
new file mode 100644
... ...
@@ -0,0 +1,9 @@
0
+.message-box
1
+  .user
2
+    .avatar
3
+      %img{src: 'assets/avatar.png', alt: I18n.t("chat.roster.avatar_alt")}
4
+    -#todo: user name missing in design
5
+  .date 3 hours ago
6
+  %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
7
+  -#%hr
8
+  %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
0 9
\ No newline at end of file
1 10
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+.message-writer#msg-writer
1
+  %input{ type: "text", placeholder: "Type your message here" }
2
+  %input{ type: "submit", value: "Send" }
0 3
\ No newline at end of file
1 4
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+.conversation.clear.border
1
+  #{@date}
0 2
\ No newline at end of file
1 3
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+Xmpp.Views.Chat ||= {}
1
+
2
+class Xmpp.Views.Chat.WindowView extends Backbone.View
3
+  template: JST["backbone/templates/chat/window"]
4
+  el: $('#conversation-js')
5
+
6
+  initialize: () ->
7
+    _.bindAll(this)
8
+    @tab = @attributes['tab']
9
+    @date = new Date() #pre testovacie ucely
10
+
11
+  render: ->
12
+    $(@el).html(@template(date: @date.getTime()))
13
+    @show()
14
+    return this
15
+
16
+  hide: ->
17
+    $(@el).addClass('hidden')
18
+    this
19
+
20
+  show: ->
21
+    $(@el).removeClass('hidden')
22
+    this
23
+
24
+  remove: ->
25
+    @undelegateEvents()
26
+    $(@el).empty()
27
+    # @stopListening() TODO: po upgrade na 1.0 uz bude pristupne
28
+    this
0 29
\ No newline at end of file
... ...
@@ -26,9 +26,27 @@ class Xmpp.Views.Tabbar.TabView extends Backbone.View
26 26
     ))
27 27
     return this
28 28
 
29
+  showChat: ->
30
+    if !@chatWindow
31
+      @chatWindow = new Xmpp.Views.Chat.WindowView(attributes: {tab: this})
32
+      App.debug 'zobrazujem NOVY chat window'
33
+    else
34
+      App.debug 'zobrazujem EXISTUJUCI chat window'
35
+
36
+    @chatWindow.render()
37
+
38
+  destroy: ->
39
+    App.debug 'destroy chatWindow and tab'
40
+    @chatWindow.remove()
41
+    @remove()
42
+
43
+  hideChat: ->
44
+    if @chatWindow
45
+      @chatWindow.hide();
46
+
29 47
   closeChat: ->
30 48
     Backbone.Events.trigger('closeChat', this, @model)
31
-    @remove()
49
+    @destroy()
32 50
 
33 51
   hasParticipants: (who, withWhom) ->
34 52
     @model && @model.get('who') == who && @model.get('withWhom') == withWhom
... ...
@@ -7,10 +7,14 @@ class Xmpp.Views.Tabbar.TabbarView extends Backbone.View
7 7
   initialize: () ->
8 8
     _.bindAll(this)
9 9
 
10
-    Backbone.Events.on('openChat', @addOrSelect)
11
-                   .on('closeChat', @removeTab)
10
+    Backbone.Events.on('openChat', (chat) =>
11
+      @hideCurrentChatWindow()
12
+      @addOrSelect(chat)
13
+    )
14
+    Backbone.Events.on('closeChat', @removeTab)
12 15
 
13 16
     @tabs = []
17
+    @activeTab = null
14 18
     @render()
15 19
 
16 20
   addOrSelect: (chat) ->
... ...
@@ -30,11 +34,24 @@ class Xmpp.Views.Tabbar.TabbarView extends Backbone.View
30 30
       tab.setInactive()
31 31
     )
32 32
 
33
-    tab.setActive().el
33
+    @activeTab = tab
34
+    @activeTab.setActive()
35
+
36
+    @activeTab.showChat()
37
+#    App.debug ['aktivny tab: ', @activeTab]
38
+
39
+  hideCurrentChatWindow: ->
40
+    if @activeTab
41
+      App.debug 'zakryvam chat window'
42
+      @activeTab.hideChat()
34 43
 
35 44
   removeTab: (tab) ->
45
+#    if @activeTab && @activeTab == tab
46
+#      App.debug 'nicim tab aj chat window'
47
+#      @activeTab.destroy()
48
+
36 49
     @tabs = _.without(@tabs, tab)
37 50
 
38 51
   render: ->
39
-    $(@el).html('')
52
+    $(@el).html(@template())
40 53
     return this
... ...
@@ -95,4 +95,8 @@ input {
95 95
 
96 96
 .clear {
97 97
   clear: both;
98
+}
99
+
100
+.hidden {
101
+  display: none;
98 102
 }
99 103
\ No newline at end of file
... ...
@@ -307,6 +307,7 @@
307 307
 
308 308
   .messages {
309 309
     min-height: 296px;
310
+    overflow: auto;
310 311
   }
311 312
 
312 313
   .message-box {
... ...
@@ -16,30 +16,6 @@
16 16
       .my-info#js-me
17 17
       .friends
18 18
         #js-active-friends
19
-        -#%h1.group-header.active Chat group
20
-        -#%ul.active-group
21
-        -#  %li.clear.user
22
-        -#    .avatar
23
-        -#      %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
24
-        -#    %h1
25
-        -#      Adam Wolsky
26
-        -#      %span.status.online.icon-record
27
-        -#    %h2 co-founder
28
-        -#    %span.action
29
-        -#      %span.icon-x-full
30
-        -#        %span kick
31
-        -#  %li.clear.user
32
-        -#    .avatar
33
-        -#      %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
34
-        -#    %h1
35
-        -#      John Savage
36
-        -#      %span.status.away.icon-record
37
-        -#    %h2 web & ui designer
38
-        -#    %span.action
39
-        -#      %span.icon-x-full
40
-        -#        %span kick
41
-        -#      %span.icon-bubbles
42
-        -#        %span invite
43 19
         #js-inactive-friends
44 20
       .toolbox
45 21
         %input{type: "search", placeholder: "Search contact"}
... ...
@@ -48,42 +24,31 @@
48 48
   .chatting-window.left.rightside
49 49
     .tabbar#tabbar
50 50
       #js-tabbar
51
-    .conversation.clear.border
52
-      .messages#height-setter-2{style: "overflow: auto;"}
53
-        %a{ href: "#", class: "event" }
54
-          Load older messages
55
-          %span.icon-arrow-up
56
-        .message-box
57
-          .user
58
-            .avatar
59
-              %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
60
-            -#todo: user name missing in design
61
-          .date 3 hours ago
62
-          %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
63
-        .message-box
64
-          .user
65
-            .avatar
66
-              %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
67
-            -#todo: user name missing in design
68
-          .date 3 hours ago
69
-          %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
70
-          -#%hr
71
-          %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
72
-
73
-        .event
74
-          Monday 13.2.2013
75
-
76
-        .message-box.active
77
-          .user
78
-            .avatar
79
-              %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
80
-            -#todo: user name missing in design
81
-          .date 3 hours ago
82
-          %p Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Lorem ipsum dolor sit amet enim.
83
-
84
-        .event
85
-          Adam left the room | 13:45
86
-
87
-      .message-writer#msg-writer
88
-        %input{ type: "text", placeholder: "Type your message here" }
89
-        %input{ type: "submit", value: "Send" }
51
+    #conversation-js
52
+      -#.conversation.clear.border
53
+        -#.messages#height-setter-2{style: "overflow: auto;"}
54
+        -#  %a{ href: "#", class: "event" }
55
+        -#    Load older messages
56
+        -#    %span.icon-arrow-up
57
+        -#  .message-box
58
+        -#    .user
59
+        -#      .avatar
60
+        -#        %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
61
+        -#      -#todo: user name missing in design
62
+        -#    .date 3 hours ago
63
+        -#    %p Lorem ipsum dolor sit amet enim. Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Curabitur et ligula...
64
+        -#
65
+        -#  .message-box.active
66
+        -#    .user
67
+        -#      .avatar
68
+        -#        %img{src: 'assets/avatar.png', alt: t("chat.avatar_alt")}
69
+        -#      -#todo: user name missing in design
70
+        -#    .date 3 hours ago
71
+        -#    %p Etiam ullamcorper. Supendisse a pellentesque dui, non felis. Maecenas malesuada elit lectus felis, malesuada ultricies. Lorem ipsum dolor sit amet enim.
72
+        -#
73
+        -#  .event
74
+        -#    Adam left the room | 13:45
75
+        -#
76
+        -#.message-writer#msg-writer
77
+        -#  %input{ type: "text", placeholder: "Type your message here" }
78
+        -#  %input{ type: "submit", value: "Send" }