Browse code

Lepsie vertikalne resizovanie rostera aj okna so spravami

Cinan Rakosnik authored on 19/05/2013 at 14:50:22
Showing 7 changed files
... ...
@@ -12,14 +12,23 @@ this.App =
12 12
 
13 13
   UI:
14 14
     setAutoHeight: ->
15
-      windowHeight = $(window).height()
15
+      App.UI.resizeRoster()
16
+      App.UI.resizeMessages()
17
+
18
+    resizeRoster: ->
16 19
       if (windowHeight < $('.roster').css('min-height').replace(/[^-\d\.]/g, ''))
17 20
         return
18 21
 
22
+      windowHeight = $(window).height()
19 23
       toolboxHeight = $("#height-setter-1 .toolbox").height()
20
-      $("#height-setter-1").css({height: windowHeight - toolboxHeight - 70})
21
-      $("#height-setter-1 .friends").css({height: windowHeight - toolboxHeight - 100})
22
-      $("#height-setter-2").css({height: windowHeight - $('#tabbar').outerHeight() - $('#msg-writer').outerHeight() - 57})
24
+      $(".friends").css({height: windowHeight - toolboxHeight - $('#js-me').height() - 40})
25
+      $("#height-setter-1").css({height: windowHeight - toolboxHeight - $('#js-active-friends').height() - 120})
26
+
27
+    resizeMessages: ->
28
+      windowHeight = $(window).height()
29
+      $("#height-setter-2").css({height: windowHeight - $('#tabbar').outerHeight() - $('#msg-writer').outerHeight() - 62})
30
+      messagesContainer = $('.messages')
31
+      messagesContainer.animate(scrollTop: messagesContainer.height(), 'fast')
23 32
 
24 33
     filterContacts: (searchTerm) ->
25 34
       App.Collections.contacts.filter(searchTerm)
... ...
@@ -246,7 +255,6 @@ this.App =
246 246
           )
247 247
 
248 248
           tab.chatWindow.appendMessage(contact, new Date(), result.message)
249
-          tab.chatWindow.log(message)
250 249
       )
251 250
 
252 251
   Models:
... ...
@@ -50,6 +50,7 @@ class Xmpp.Collections.ContactsCollection extends Backbone.Collection
50 50
       @moveToInactiveList('all')
51 51
 #      App.debug chat
52 52
       @moveToActiveList(chat.get('withWhom'))
53
+      Backbone.Events.trigger('resizeWorkspace')
53 54
     )
54 55
 
55 56
     Backbone.Events.on('closeChat', (chat) =>
... ...
@@ -59,6 +60,7 @@ class Xmpp.Collections.ContactsCollection extends Backbone.Collection
59 59
   appendContact: (contact) ->
60 60
     App.debug ['apppend', contact]
61 61
     @friendsList.appendContact(contact)
62
+    Backbone.Events.trigger('resizeWorkspace')
62 63
 
63 64
   mergeContacts: (contact) ->
64 65
     App.debug ['merging contacts', contact]
... ...
@@ -123,11 +125,13 @@ class Xmpp.Collections.ContactsCollection extends Backbone.Collection
123 123
         @remove(contact)
124 124
 
125 125
     # ignore 'unsubscribe' type of action
126
+    Backbone.Events.trigger('resizeWorkspace')
126 127
 
127 128
   # toto sem asi nepatri, ale asi do views. Nic to v skutocnosti nerobi s modelmi.
128 129
   filter: (searchTerm) ->
129 130
     @friendsList.filter(searchTerm)
130 131
     @activeList.filter(searchTerm)
132
+    Backbone.Events.trigger('resizeWorkspace')
131 133
 
132 134
   findByJid: (jid) ->
133 135
     @get(jid)
... ...
@@ -1,5 +1,4 @@
1 1
 .conversation.clear.border
2
-  -for view in @history
3
-    #{view}
2
+  .messages#height-setter-2
4 3
   -if @showWriter
5 4
     != JST['backbone/templates/chat/message_writer']()
6 5
\ No newline at end of file
... ...
@@ -16,10 +16,7 @@ class Xmpp.Views.Chat.WindowView extends Backbone.View
16 16
     @historyStack = []
17 17
 
18 18
   render: ->
19
-    historyStackHtml = _.map(@historyStack, (view) ->
20
-      view.render().el.outerHTML
21
-    )
22
-    $(@el).html(@template(showWriter: true, history: historyStackHtml))
19
+    $(@el).html(@template(showWriter: true))
23 20
     @show()
24 21
     return this
25 22
 
... ...
@@ -72,12 +69,5 @@ class Xmpp.Views.Chat.WindowView extends Backbone.View
72 72
 
73 73
   appendMessage: (user, date, msg) ->
74 74
     messageView = new Xmpp.Views.Chat.MessageView(user: user, date: date, message: msg)
75
-    $(@el).find('#msg-writer').before(messageView.render().el)
76
-    @log(messageView)
77
-
78
-  log: (view) ->
79
-    if (@historyStack.length + 1 >= @maxHistoryLength)
80
-      @historyStack = @historyStack.slice(@historyStack.length - @maxHistoryLength + 1)
81
-
82
-    @historyStack.push(view)
83
-#    App.debug @historyStack
75
+    $(@el).find('.messages').append(messageView.render().el)
76
+    App.UI.resizeMessages()
84 77
\ No newline at end of file
... ...
@@ -3,6 +3,8 @@ $().ready(->
3 3
     App.UI.setAutoHeight()
4 4
   ).trigger('resize')
5 5
 
6
+  Backbone.Events.on('resizeWorkspace', -> App.UI.setAutoHeight())
7
+
6 8
   $('#js-search-contacts').keyup( ->
7 9
     searchTerm = $(this).val()
8 10
     App.UI.filterContacts(searchTerm)
... ...
@@ -198,8 +198,8 @@
198 198
 
199 199
 .friends {
200 200
   height: inherit;
201
-  overflow-x: hidden;
202
-  overflow-y: auto;
201
+  //overflow-x: hidden;
202
+  //overflow-y: auto;
203 203
 
204 204
   .group-header {
205 205
     margin: 16px 3px 3px;
... ...
@@ -447,6 +447,7 @@
447 447
   padding: 9px;
448 448
   min-height: 367px;
449 449
   width: 730px;
450
+  position: relative;
450 451
 
451 452
   .event {
452 453
     color: $status-color;
... ...
@@ -16,14 +16,14 @@
16 16
   .leftside.left
17 17
     .roster.border.no-top-border.top-border
18 18
       .my-info#js-me
19
-      .wrap#height-setter-1
20
-        .friends
21
-          #js-active-friends
19
+      .friends
20
+        #js-active-friends
21
+        .wrap#height-setter-1
22 22
           #js-inactive-friends
23
-        .toolbox
24
-          %input#js-search-contacts{type: 'search', placeholder: "#{I18n.t('chat.roster.search')}", name: 'contact'}
25
-          %a{ href: '#'}
26
-            %span.icon-cog
23
+          .toolbox
24
+            %input#js-search-contacts{type: 'search', placeholder: "#{I18n.t('chat.roster.search')}", name: 'contact'}
25
+            %a{ href: '#'}
26
+              %span.icon-cog
27 27
   .chatting-window.left.rightside
28 28
     .tabbar#tabbar
29 29
       .wrap#js-tabbar