From 89e4d5ed07c18d9642853c322dd59be5be0d3e25 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 4 Sep 2015 17:18:49 +0500 Subject: [PATCH] show usernames in #groupchat messages --- css/style.css | 11 ++++++++++- following.html | 5 ++++- home.html | 5 ++++- js/mobile_abstract.js | 2 +- js/twister_directmsg.js | 2 +- js/twister_formatpost.js | 33 ++++++++++++++++++++------------- theme_calm/css/style.css | 11 ++++++++++- theme_nin/css/style.css | 20 +++++++++++++++++++- 8 files changed, 69 insertions(+), 20 deletions(-) diff --git a/css/style.css b/css/style.css index 3f4c6e1..01a8e17 100644 --- a/css/style.css +++ b/css/style.css @@ -1552,13 +1552,21 @@ ol.toptrends-list { left: auto; } +.direct-messages-thread .post.sent .post-info { + text-align: right; +} + +.direct-messages-thread .post.sent .post-info-name { + margin-right: 2px; +} + .direct-messages-thread .post.sent .post-info-time { float: left; } .direct-messages-thread .post.sent .post-info-time .post-info-sent { float: right; - margin: 0 2px; + margin-left: 2px; } .direct-messages-thread .post.sent .post-text { @@ -2205,6 +2213,7 @@ ul.dropdown-menu .active, ul.dropdown-menu .active a { .post-rt-reference .post-photo { width: 24px; height: 24px; + margin: 4px; } .post-rt-reference .post-photo img { diff --git a/following.html b/following.html index 0ca6122..5941fbd 100644 --- a/following.html +++ b/following.html @@ -382,7 +382,10 @@
  • user-photo
    - +

  • diff --git a/home.html b/home.html index b94eb16..179dac6 100644 --- a/home.html +++ b/home.html @@ -474,7 +474,10 @@
  • user-photo
    - +

  • diff --git a/js/mobile_abstract.js b/js/mobile_abstract.js index 2d0673d..8fe3e14 100644 --- a/js/mobile_abstract.js +++ b/js/mobile_abstract.js @@ -150,7 +150,7 @@ var MAL = function() else return "#profile?user=" + username; //} - } + }; // recover username from url (only for hash) this.urlToUser = function(url) { diff --git a/js/twister_directmsg.js b/js/twister_directmsg.js index abe346e..4c8291d 100644 --- a/js/twister_directmsg.js +++ b/js/twister_directmsg.js @@ -81,7 +81,7 @@ function processDmConversation(postboard, dm_screenname, dmData) { var dmList = dmData[dm_screenname]; if (dmList.length) { for (var i = 0; i < dmList.length; i++) { - var dmItem = dmDataToConversationItem(dmList[i], defaultScreenName, dm_screenname) + var dmItem = postToElemDM(dmList[i], defaultScreenName, dm_screenname) .attr('data-id', dmList[i].id) .appendTo(postboard) ; diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index d113266..4489050 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -280,24 +280,31 @@ function dmDataToSnippetItem(dmData, remoteUser) { } // format dmdata (returned by getdirectmsgs) to display in conversation thread -function dmDataToConversationItem(dmData, localUser, remoteUser) { - var from = (dmData.from && dmData.from.length && dmData.from.charCodeAt(0)) - ? dmData.from - : (dmData.fromMe ? localUser : remoteUser); - var classDm = dmData.fromMe ? "sent" : "received"; - var dmItem = $("#dm-chat-template").clone(true); - dmItem.removeAttr('id'); - dmItem.addClass(classDm); - getAvatar(from, dmItem.find(".post-photo").find("img") ); - dmItem.find('.post-info-time') +function postToElemDM(dmData, localUser, remoteUser) { + var senderAlias = (dmData.from && dmData.from.length && dmData.from.charCodeAt(0)) + ? dmData.from : (dmData.fromMe ? localUser : remoteUser); + var elem = $('#dm-chat-template').clone(true) + .removeAttr('id') + .addClass(dmData.fromMe ? 'sent' : 'received') + ; + + var elemName = elem.find('.post-info-name') + .attr('href', $.MAL.userUrl(senderAlias)); + if (senderAlias[0] === '*' ) + getGroupChatName(senderAlias, elemName); + else + getFullname(senderAlias, elemName); + + getAvatar(senderAlias, elem.find('.post-photo').find('img')); + elem.find('.post-info-time') .attr('title', timeSincePost(dmData.time)) .find('span:last') .text(timeGmtToText(dmData.time)) ; - setPostInfoSent(from,dmData.k,dmItem.find('.post-info-sent')); - dmItem.find('.post-text').html(htmlFormatMsg(dmData.text).html); + setPostInfoSent(senderAlias, dmData.k, elem.find('.post-info-sent')); + elem.find('.post-text').html(htmlFormatMsg(dmData.text).html); - return dmItem; + return elem; } // convert message text to html, featuring @users and links formating. diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index 683c907..af6745c 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -1920,13 +1920,21 @@ textarea.splited-post { left: auto; } +.direct-messages-thread .post.sent .post-info { + text-align: right; +} + +.direct-messages-thread .post.sent .post-info-name { + margin-right: 2px; +} + .direct-messages-thread .post.sent .post-info-time { float: left; } .direct-messages-thread .post.sent .post-info-time .post-info-sent { float: right; - margin: 0 2px; + margin-left: 2px; } .direct-messages-thread .post.sent .post-text { @@ -2631,6 +2639,7 @@ p.post-text img { .post-rt-reference .post-photo { width: 24px; height: 24px; + margin: 4px; } .post-rt-reference .post-photo img { diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 2a8aae1..c27f003 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -2868,17 +2868,19 @@ ol.toptrends-list a:hover { margin-left: 58px; font-size: 0.9em; } + /* line 758, ../sass/style.sass */ .directMessages .post-info-name { float: none; } + /* line 760, ../sass/style.sass */ .directMessages .post-info-tag { line-height: 1em; padding: 0; display: inline; font-size: 80%; - margin: 0 0 0 1em; + margin-left: 0.1em; } /* line 767, ../sass/style.sass */ @@ -2911,6 +2913,13 @@ ol.toptrends-list a:hover { margin: 0px 10px 20px 10px; cursor: default; } + +.direct-messages-thread .post .post-info-name { + display: block; + margin-left: 128px; + padding: 0; +} + /* line 793, ../sass/style.sass */ .direct-messages-thread .post .post-info-time { float: none; @@ -2962,6 +2971,15 @@ ol.toptrends-list a:hover { left: 0; top: 10px; } + +.direct-messages-thread .post.sent .post-info { + text-align: right; +} + +.direct-messages-thread .post.sent .post-info-name { + margin-right: 128px; +} + /* line 842, ../sass/style.sass */ .direct-messages-thread .post.sent .post-text:after { border-top: solid 7px transparent;