Use less2 in contacts

pull/1/head
yflory 7 years ago
parent dd63cd13d7
commit 7b8490ad20

@ -34,7 +34,8 @@
@button-border: 2px; @button-border: 2px;
@bg-color: @colortheme_friends-bg; @bg-color: @colortheme_friends-bg;
@color: @colortheme_friends-color; @color: @colortheme_friends-color;
#app {
#cp-app-contacts-container {
flex: 1; flex: 1;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -46,26 +47,22 @@
} }
} }
#toolbar { #cp-toolbar {
display: flex; // We need this to remove a 3px border at the bottom of the toolbar display: flex; // We need this to remove a 3px border at the bottom of the toolbar
} }
.cryptpad-toolbar { #cp-app-contacts-friendlist {
padding: 0px;
display: inline-block;
}
#friendList {
width: 350px; width: 350px;
height: 100%; height: 100%;
background-color: lighten(@bg-color, 10%); background-color: lighten(@bg-color, 10%);
overflow-y: auto; overflow-y: auto;
.friend { .cp-app-contacts-friend {
background: rgba(0,0,0,0.1); background: rgba(0,0,0,0.1);
padding: 5px; padding: 5px;
margin: 10px; margin: 10px;
cursor: pointer; cursor: pointer;
.right-col { position: relative;
.cp-app-contacts-right-col {
margin-left: 5px; margin-left: 5px;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
@ -73,13 +70,20 @@
&:hover { &:hover {
background-color: rgba(0,0,0,0.3); background-color: rgba(0,0,0,0.3);
} }
&.notify { &.cp-app-contacts-notify {
animation: example 2s ease-in-out infinite; animation: example 2s ease-in-out infinite;
} }
} }
.cp-app-contacts-remove {
cursor: pointer;
width: 20px;
&:hover {
color: darken(@color, 20%);
}
}
} }
#friendList .friend, #messaging .cp-avatar { #cp-app-contacts-friendlist .cp-app-contacts-friend, #cp-app-contacts-messaging .cp-avatar {
.avatar_main(30px); .avatar_main(30px);
&.cp-avatar { &.cp-avatar {
display: flex; display: flex;
@ -91,10 +95,10 @@
color: #000; color: #000;
} }
} }
media-tag, .default { media-tag, .cp-avatar-default {
margin-right: 5px; margin-right: 5px;
} }
.status { .cp-app-contacts-status {
width: 5px; width: 5px;
display: inline-block; display: inline-block;
position: absolute; position: absolute;
@ -103,28 +107,15 @@
bottom: 0; bottom: 0;
opacity: 0.7; opacity: 0.7;
background-color: #777; background-color: #777;
&.online { &.cp-app-contacts-online {
background-color: green; background-color: green;
} }
&.offline { &.cp-app-contacts-offline {
background-color: red; background-color: red;
} }
} }
} }
#friendList {
.friend {
position: relative;
}
.remove {
cursor: pointer;
width: 20px;
&:hover {
color: darken(@color, 20%);
}
}
}
.placeholder (@color: #bbb) { .placeholder (@color: #bbb) {
&::-webkit-input-placeholder { /* WebKit, Blink, Edge */ &::-webkit-input-placeholder { /* WebKit, Blink, Edge */
color: @color; color: @color;
@ -145,16 +136,16 @@
} }
} }
#messaging { #cp-app-contacts-messaging {
flex: 1; flex: 1;
height: 100%; height: 100%;
background-color: lighten(@bg-color, 20%); background-color: lighten(@bg-color, 20%);
min-width: 0; min-width: 0;
.info { .cp-app-contacts-info {
padding: 20px; padding: 20px;
} }
.header { .cp-app-contacts-header {
background-color: lighten(@bg-color, 15%); background-color: lighten(@bg-color, 15%);
padding: 0; padding: 0;
display: flex; display: flex;
@ -171,49 +162,49 @@
} }
} }
.avatar, .cp-avatar,
.right-col { .cp-app-contacts-right-col {
flex:1 1 auto; flex:1 1 auto;
} }
.remove-history { .cp-app-contacts-remove-history {
.hover; .hover;
} }
.cp-avatar { .cp-avatar {
margin: 10px; margin: 10px;
} }
.more-history { .cp-app-contacts-more-history {
//display: none; //display: none;
.hover; .hover;
&.faded { &.cp-app-contacts-faded {
color: darken(@bg-color, 5%); color: darken(@bg-color, 5%);
} }
} }
} }
.chat { .cp-app-contacts-chat {
height: 100%; height: 100%;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
.messages { .cp-app-contacts-messages {
padding: 0 20px; padding: 0 20px;
margin: 10px 0; margin: 10px 0;
flex: 1; flex: 1;
overflow-x: auto; overflow-x: auto;
.message { .cp-app-contacts-message {
& > div { & > div {
padding: 0 10px; padding: 0 10px;
} }
.content { .cp-app-contacts-content {
overflow: hidden; overflow: hidden;
word-wrap: break-word; word-wrap: break-word;
&> * { &> * {
margin: 0; margin: 0;
} }
} }
.date { .cp-app-contacts-date {
display: none; display: none;
font-style: italic; font-style: italic;
} }
.sender { .cp-app-contacts-sender {
margin-top: 10px; margin-top: 10px;
font-weight: bold; font-weight: bold;
background-color: rgba(0,0,0,0.1); background-color: rgba(0,0,0,0.1);
@ -221,7 +212,7 @@
} }
} }
} }
.input { .cp-app-contacts-input {
background-color: lighten(@bg-color, 15%); background-color: lighten(@bg-color, 15%);
height: auto; height: auto;
min-height: 50px; min-height: 50px;

@ -47,12 +47,12 @@ define([
} }
}); });
var toolbarElement = h('div#toolbar.cp-toolbar-container'); var toolbarElement = h('div#cp-toolbar.cp-toolbar-container');
document.body.appendChild(toolbarElement); document.body.appendChild(toolbarElement);
var messaging = h('div#messaging', [ var messaging = h('div#cp-app-contacts-messaging', [
h('div.info', [ h('div.cp-app-contacts-info', [
h('h2', Messages.contacts_info1), h('h2', Messages.contacts_info1),
h('ul', [ h('ul', [
h('li', Messages.contacts_info2), h('li', Messages.contacts_info2),
@ -61,9 +61,9 @@ define([
]) ])
]); ]);
var friendList = h('div#friendList'); var friendList = h('div#cp-app-contacts-friendlist');
var appElement = h('div#app', [ var appElement = h('div#cp-app-contacts-container', [
friendList, friendList,
messaging, messaging,
]); ]);

@ -12,7 +12,7 @@ define([
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
var m = function (md) { var m = function (md) {
var d = h('div.content'); var d = h('div.cp-app-contacts-content');
try { try {
d.innerHTML = Marked(md || ''); d.innerHTML = Marked(md || '');
} catch (e) { } catch (e) {
@ -36,6 +36,8 @@ define([
}; };
UI.create = function (messenger, $userlist, $messages, common) { UI.create = function (messenger, $userlist, $messages, common) {
var origin = common.getMetadataMgr().getPrivateData().origin;
var state = window.state = { var state = window.state = {
active: '', active: '',
}; };
@ -57,21 +59,21 @@ define([
}; };
var notify = function (curvePublic) { var notify = function (curvePublic) {
find.inList(curvePublic).addClass('notify'); find.inList(curvePublic).addClass('cp-app-contacts-notify');
}; };
var unnotify = function (curvePublic) { var unnotify = function (curvePublic) {
find.inList(curvePublic).removeClass('notify'); find.inList(curvePublic).removeClass('cp-app-contacts-notify');
}; };
var markup = {}; var markup = {};
markup.message = function (msg) { markup.message = function (msg) {
var curvePublic = msg.author; var curvePublic = msg.author;
var name = displayNames[msg.author]; var name = displayNames[msg.author];
return h('div.message', { return h('div.cp-app-contacts-message', {
title: msg.time? new Date(msg.time).toLocaleString(): '?', title: msg.time? new Date(msg.time).toLocaleString(): '?',
'data-key': curvePublic, 'data-key': curvePublic,
}, [ }, [
name? h('div.sender', name): undefined, name? h('div.cp-app-contacts-sender', name): undefined,
m(msg.text), m(msg.text),
]); ]);
}; };
@ -81,10 +83,10 @@ define([
}; };
var normalizeLabels = function ($messagebox) { var normalizeLabels = function ($messagebox) {
$messagebox.find('div.message').toArray().reduce(function (a, b) { $messagebox.find('div.cp-app-contacts-message').toArray().reduce(function (a, b) {
var $b = $(b); var $b = $(b);
if ($(a).data('key') === $b.data('key')) { if ($(a).data('key') === $b.data('key')) {
$b.find('.sender').hide(); $b.find('.cp-app-contacts-sender').hide();
return a; return a;
} }
return b; return b;
@ -92,7 +94,7 @@ define([
}; };
markup.chatbox = function (curvePublic, data) { markup.chatbox = function (curvePublic, data) {
var moreHistory = h('span.more-history.fa.fa-history', { var moreHistory = h('span.cp-app-contacts-more-history.fa.fa-history', {
title: Messages.contacts_fetchHistory, title: Messages.contacts_fetchHistory,
}); });
var displayName = data.displayName; var displayName = data.displayName;
@ -105,14 +107,14 @@ define([
var channel = state.channels[curvePublic]; var channel = state.channels[curvePublic];
if (channel.exhausted) { if (channel.exhausted) {
return void $moreHistory.addClass('faded'); return void $moreHistory.addClass('cp-app-contacts-faded');
} }
console.log('getting history'); console.log('getting history');
var sig = channel.TAIL || channel.HEAD; var sig = channel.TAIL || channel.HEAD;
fetching = true; fetching = true;
var $messagebox = $(getChat(curvePublic)).find('.messages'); var $messagebox = $(getChat(curvePublic)).find('.cp-app-contacts-messages');
messenger.getMoreHistory(curvePublic, sig, 10, function (e, history) { messenger.getMoreHistory(curvePublic, sig, 10, function (e, history) {
fetching = false; fetching = false;
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
@ -129,7 +131,7 @@ define([
console.error('No more messages to fetch'); console.error('No more messages to fetch');
channel.exhausted = true; channel.exhausted = true;
console.log(channel); console.log(channel);
return void $moreHistory.addClass('faded'); return void $moreHistory.addClass('cp-app-contacts-faded');
} else { } else {
channel.TAIL = msg.sig; channel.TAIL = msg.sig;
} }
@ -151,7 +153,7 @@ define([
}); });
}); });
var removeHistory = h('span.remove-history.fa.fa-eraser', { var removeHistory = h('span.cp-app-contacts-remove-history.fa.fa-eraser', {
title: Messages.contacts_removeHistoryTitle title: Messages.contacts_removeHistoryTitle
}); });
@ -169,12 +171,12 @@ define([
}); });
var avatar = h('div.cp-avatar'); var avatar = h('div.cp-avatar');
var header = h('div.header', [ var header = h('div.cp-app-contacts-header', [
avatar, avatar,
moreHistory, moreHistory,
removeHistory, removeHistory,
]); ]);
var messages = h('div.messages'); var messages = h('div.cp-app-contacts-messages');
var input = h('textarea', { var input = h('textarea', {
placeholder: Messages.contacts_typeHere placeholder: Messages.contacts_typeHere
}); });
@ -182,8 +184,8 @@ define([
title: Messages.contacts_send, title: Messages.contacts_send,
}); });
var rightCol = h('span.right-col', [ var rightCol = h('span.cp-app-contacts-right-col', [
h('span.name', displayName), h('span.cp-app-contacts-name', displayName),
]); ]);
var $avatar = $(avatar); var $avatar = $(avatar);
@ -249,12 +251,12 @@ define([
$(input).on('keydown', onKeyDown); $(input).on('keydown', onKeyDown);
$(sendButton).click(function () { send(input.value); }); $(sendButton).click(function () { send(input.value); });
return h('div.chat', { return h('div.cp-app-contacts-chat', {
'data-key': curvePublic, 'data-key': curvePublic,
}, [ }, [
header, header,
messages, messages,
h('div.input', [ h('div.cp-app-contacts-input', [
input, input,
sendButton, sendButton,
]), ]),
@ -262,11 +264,11 @@ define([
}; };
var hideInfo = function () { var hideInfo = function () {
$messages.find('.info').hide(); $messages.find('.cp-app-contacts-info').hide();
}; };
var updateStatus = function (curvePublic) { var updateStatus = function (curvePublic) {
var $status = find.inList(curvePublic).find('.status'); var $status = find.inList(curvePublic).find('.cp-app-contacts-status');
// FIXME this stopped working :( // FIXME this stopped working :(
messenger.getStatus(curvePublic, function (e, online) { messenger.getStatus(curvePublic, function (e, online) {
// if error maybe you shouldn't display this friend... // if error maybe you shouldn't display this friend...
@ -278,9 +280,9 @@ define([
} }
if (online) { if (online) {
return void $status return void $status
.removeClass('offline').addClass('online'); .removeClass('cp-app-contacts-offline').addClass('cp-app-contacts-online');
} }
$status.removeClass('online').addClass('offline'); $status.removeClass('cp-app-contacts-online').addClass('cp-app-contacts-offline');
}); });
}; };
@ -299,11 +301,11 @@ define([
unnotify(curvePublic); unnotify(curvePublic);
var $chat = getChat(curvePublic); var $chat = getChat(curvePublic);
hideInfo(); hideInfo();
$messages.find('div.chat[data-key]').hide(); $messages.find('div.cp-app-contacts-chat[data-key]').hide();
if ($chat.length) { if ($chat.length) {
var $chat_messages = $chat.find('div.message'); var $chat_messages = $chat.find('div.cp-app-contacts-message');
if (!$chat_messages.length) { if (!$chat_messages.length) {
var $more = $chat.find('.more-history'); var $more = $chat.find('.cp-app-contacts-more-history');
$more.click(); $more.click();
} }
return void $chat.show(); return void $chat.show();
@ -325,16 +327,16 @@ define([
markup.friend = function (data) { markup.friend = function (data) {
var curvePublic = data.curvePublic; var curvePublic = data.curvePublic;
var friend = h('div.friend.cp-avatar', { var friend = h('div.cp-app-contacts-friend.cp-avatar', {
'data-key': curvePublic, 'data-key': curvePublic,
}); });
var remove = h('span.remove.fa.fa-user-times', { var remove = h('span.cp-app-contacts-remove.fa.fa-user-times', {
title: Messages.contacts_remove title: Messages.contacts_remove
}); });
var status = h('span.status'); var status = h('span.cp-app-contacts-status');
var rightCol = h('span.right-col', [ var rightCol = h('span.cp-app-contacts-right-col', [
h('span.name', [data.displayName]), h('span.cp-app-contacts-name', [data.displayName]),
remove, remove,
]); ]);
@ -343,7 +345,7 @@ define([
display(curvePublic); display(curvePublic);
}) })
.dblclick(function () { .dblclick(function () {
if (data.profile) { window.open('/profile/#' + data.profile); } if (data.profile) { window.open(origin + '/profile/#' + data.profile); }
}); });
$(remove).click(function (e) { $(remove).click(function (e) {
@ -400,7 +402,7 @@ define([
console.error("Got a message but the chat isn't open"); console.error("Got a message but the chat isn't open");
} }
var $messagebox = $chat.find('.messages'); var $messagebox = $chat.find('.cp-app-contacts-messages');
var shouldScroll = isBottomedOut($messagebox); var shouldScroll = isBottomedOut($messagebox);
$messagebox.append(el_message); $messagebox.append(el_message);
@ -444,11 +446,12 @@ define([
var name = displayNames[curvePublic] = info.displayName; var name = displayNames[curvePublic] = info.displayName;
// update label in friend list // update label in friend list
find.inList(curvePublic).find('.name').text(name); find.inList(curvePublic).find('.cp-app-contacts-name').text(name);
// update title bar and messages // update title bar and messages
$messages.find(dataQuery(curvePublic) + ' .header .name, div.message'+ $messages.find(dataQuery(curvePublic) + ' .cp-app-contacts-header ' +
dataQuery(curvePublic) + ' div.sender').text(name).text(name); '.cp-app-contacts-name, div.cp-app-contacts-message'+
dataQuery(curvePublic) + ' div.cp-app-contacts-sender').text(name).text(name);
}); });
var connectToFriend = function (curvePublic, cb) { var connectToFriend = function (curvePublic, cb) {

Loading…
Cancel
Save