diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index 6e3e292c8e6a3c17e6ce56c92f1ce8e4a5560d5e..9912d0db5808c0a618bf8d2cce381a8e8b25be36 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -1667,7 +1667,7 @@ a.github-fork { .messages-box { position: relative; - margin: 60px 20px 0px; + margin: 60px 20px 0px 0px; overflow: hidden; .calc(width, ~'100% - 20px'); .calc(height, ~'100% - 120px'); @@ -1699,6 +1699,7 @@ a.github-fork { padding-left: 50px; position: relative; line-height: 20px; + margin-left: 20px; &.with-thumb { margin-top: 12px; min-height: 40px; @@ -1792,7 +1793,7 @@ a.github-fork { } } } - .time { + .time, .time-single { font-size: 12px; position: absolute; display: inline-block; @@ -1800,6 +1801,32 @@ a.github-fork { left: 6px; opacity: 0; } + .time-single { + opacity: 1; + left: -15px; + width: 64px; + .time-single-time { + display: none; + } + .time-single-edited { + text-align: center; + } + } + .message.own:hover { + .time-single { + .time-single-time { + display: block; + } + .time-single-edited { + display: none; + text-align: center; + } + } + .edit-message { + display: inline-block; + } + } + .thumb { position: absolute; left: 0; diff --git a/client/views/app/chatMessageDashboard.coffee b/client/views/app/chatMessageDashboard.coffee index 9919bbd24af3bb4a2384a2910e53247a49bcd27e..06bcd9f3569001ad13ba07420020354e0d026674 100644 --- a/client/views/app/chatMessageDashboard.coffee +++ b/client/views/app/chatMessageDashboard.coffee @@ -5,6 +5,9 @@ Template.chatMessageDashboard.helpers username: -> return this.u.username + messageDate: (date) -> + return moment(date).format('LL') + isSystemMessage: -> return this.t in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm'] diff --git a/client/views/app/chatMessageDashboard.html b/client/views/app/chatMessageDashboard.html index e1388040d52751b838a800539ec26019805c53eb..b57187856a68a7447b88a73296f620a36e10dcb2 100644 --- a/client/views/app/chatMessageDashboard.html +++ b/client/views/app/chatMessageDashboard.html @@ -1,9 +1,15 @@ <template name="chatMessageDashboard"> - <li class="message with-thumb {{own}} {{data.type}}" data-scroll-to-bottom="{{scroll}}"> + {{#if dateSeparator}} + <li class="date"> + <span>{{messageDate data.ts}}</span> + </li> + {{/if}} + <li class="message {{#unless single}}with-thumb{{/unless}} {{own}} {{data.type}}" data-scroll-to-bottom="{{scroll}}"> {{#with data}} {{#if isSystemMessage}} <p class="system">{{{message}}}</p> {{else}} + {{#unless ../single}} <a class="thumb user-card-message" href="#" data-username="{{username}}" tabindex="1"> {{> avatar username=username}} </a> @@ -15,12 +21,26 @@ {{/if}} <i class="icon-pencil edit-message"></i> </span> + {{/unless}} {{#if isEditing}} <div class="input-message-editing-container"> {{> messagePopupConfig getPupupConfig}} <textarea class="input-message-editing">{{message}}</textarea> </div> {{else}} + {{#if ../single}} + <span class="time-single"> + <div class="time-single-time"> + <i class="icon-pencil edit-message"></i> + {{time}} + </div> + {{#if ets}} + <div class="time-single-edited"> + ({{_ "edited"}}) + </div> + {{/if}} + </span> + {{/if}} <div> {{#emojione}}{{preProcessingMessage message}}{{/emojione}} </div> diff --git a/client/views/app/chatWindowDashboard.coffee b/client/views/app/chatWindowDashboard.coffee index 137cd9fbbe2eef3fe7b28dff323375c9878e807b..99a908b507876e4407f738a506969620626a7d86 100644 --- a/client/views/app/chatWindowDashboard.coffee +++ b/client/views/app/chatWindowDashboard.coffee @@ -71,55 +71,23 @@ Template.chatWindowDashboard.helpers users: usernames.join " #{t 'general.and'} " } - newDate: -> - console.log 'chatWindowDashboard.newDate' if window.rocketDebug + messageInfo: (from) -> + collection = ChatMessage - lastMessageDate = window.lastMessageWindow[this.rid] - d = moment(this.ts).format('YYYYMMDD') + if from is 'history' + collection = ChatMessageHistory - window.lastMessageWindow[this.rid] = - mid: this._id - date: d - - if not lastMessageDate? - return false - - if lastMessageDate.mid is this._id - last = ChatMessage.find({ts: {$lt: this.ts}, t: {$exists: false}}, { sort: { ts: -1 }, limit: 1 }).fetch()[0] - if not last? - return false - lastMessageDate = - mid: last._id - date: moment(last.ts).format('YYYYMMDD') - - return lastMessageDate.date isnt d - - newDateHistory: -> - console.log 'chatWindowDashboard.newDate' if window.rocketDebug - - lastMessageDate = window.lastMessageWindowHistory[this.rid] - d = moment(this.ts).format('YYYYMMDD') - - window.lastMessageWindowHistory[this.rid] = - mid: this._id - date: d - - if not lastMessageDate? - return false - - if lastMessageDate.mid is this._id - last = ChatMessageHistory.find({ts: {$lt: this.ts}, t: {$exists: false}}, { sort: { ts: -1 }, limit: 1 }).fetch()[0] - if not last? - return false - lastMessageDate = - mid: last._id - date: moment(last.ts).format('YYYYMMDD') - - return lastMessageDate.date isnt d + last = collection.find({ts: {$lt: this.ts}, t: {$exists: false}}, { sort: { ts: -1 }, limit: 1 }).fetch()[0] + if not last? + return { + single: false + newDay: false + } - messageDate: -> - console.log 'chatWindowDashboard.messageDate' if window.rocketDebug - return moment(this.ts).format('LL') + return { + single: last.u.username is this.u.username and this.ts - last.ts < 30000 + newDay: moment(last.ts).format('YYYYMMDD') isnt moment(this.ts).format('YYYYMMDD') + } roomName: -> console.log 'chatWindowDashboard.roomName' if window.rocketDebug diff --git a/client/views/app/chatWindowDashboard.html b/client/views/app/chatWindowDashboard.html index ee61c9883d1e7ffb32e6fa8202ae32a4f95565d3..030669237d06bafd11a15729ef2865a56463074a 100644 --- a/client/views/app/chatWindowDashboard.html +++ b/client/views/app/chatWindowDashboard.html @@ -32,24 +32,20 @@ {{/if}} {{#each messagesHistory}} {{#unless showTyping}} - {{#if newDateHistory}} - <li class="date"> - <span>{{messageDate}}</span> - </li> - {{/if}} - {{> chatMessageDashboard data=this}} - {{/unless}} - {{/each}} - {{#each messages}} - {{#unless showTyping}} - {{#if newDate}} - <li class="date"> - <span>{{messageDate}}</span> - </li> - {{/if}} - {{> chatMessageDashboard data=this scroll="true"}} + {{#with messageInfo 'history'}} + {{> chatMessageDashboard data=.. single=single dateSeparator=newDay}} + {{/with}} {{/unless}} {{/each}} + {{#with messages}} + {{#each .}} + {{#unless showTyping}} + {{#with messageInfo}} + {{> chatMessageDashboard data=.. scroll="true" single=single dateSeparator=newDay}} + {{/with}} + {{/unless}} + {{/each}} + {{/with}} </ul> </div> <div class="new-message not">