Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
Caleb James DeLisle 7 years ago
commit cc6b2192e4

@ -42,7 +42,8 @@
"diff-dom": "2.1.1", "diff-dom": "2.1.1",
"nthen": "^0.1.5", "nthen": "^0.1.5",
"open-sans-fontface": "^1.4.2", "open-sans-fontface": "^1.4.2",
"bootstrap-tokenfield": "^0.12.1" "bootstrap-tokenfield": "^0.12.1",
"localforage": "^1.5.2"
}, },
"resolutions": { "resolutions": {
"bootstrap": "v4.0.0-alpha.6" "bootstrap": "v4.0.0-alpha.6"

@ -44,6 +44,10 @@
flex-flow: row; flex-flow: row;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
&.cp-app-code-present {
.CodeMirror { display: none; }
#cp-app-code-preview { border: 0; }
}
} }
#cp-app-code-preview { #cp-app-code-preview {
flex: 1; flex: 1;

@ -62,10 +62,14 @@ define([
'xml', 'xml',
]); ]);
var mkPreviewPane = function (editor, CodeMirror, framework) { var mkPreviewPane = function (editor, CodeMirror, framework, isPresentMode) {
var $previewContainer = $('#cp-app-code-preview'); var $previewContainer = $('#cp-app-code-preview');
var $preview = $('#cp-app-code-preview-content'); var $preview = $('#cp-app-code-preview-content');
var $editorContainer = $('#cp-app-code-editor');
var $codeMirror = $('.CodeMirror'); var $codeMirror = $('.CodeMirror');
var $previewButton = framework._.sfCommon.createButton(null, true);
var forceDrawPreview = function () { var forceDrawPreview = function () {
try { try {
DiffMd.apply(DiffMd.render(editor.getValue()), $preview); DiffMd.apply(DiffMd.render(editor.getValue()), $preview);
@ -73,11 +77,10 @@ define([
}; };
var drawPreview = Util.throttle(function () { var drawPreview = Util.throttle(function () {
if (CodeMirror.highlightMode !== 'markdown') { return; } if (CodeMirror.highlightMode !== 'markdown') { return; }
if (!$previewContainer.is(':visible')) { return; } if (!$previewButton.is('.cp-toolbar-button-active')) { return; }
forceDrawPreview(); forceDrawPreview();
}, 150); }, 150);
var $previewButton = framework._.sfCommon.createButton(null, true);
$previewButton.removeClass('fa-question').addClass('fa-eye'); $previewButton.removeClass('fa-question').addClass('fa-eye');
$previewButton.attr('title', Messages.previewButtonTitle); $previewButton.attr('title', Messages.previewButtonTitle);
var previewTo; var previewTo;
@ -126,12 +129,16 @@ define([
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
if (data !== false) { if (data !== false) {
$previewContainer.show(); $previewContainer.show();
$previewButton.addClass('active'); $previewButton.addClass('cp-toolbar-button-active');
$codeMirror.removeClass('cp-app-code-fullpage'); $codeMirror.removeClass('cp-app-code-fullpage');
if (isPresentMode) {
$editorContainer.addClass('cp-app-code-present');
}
} }
}); });
return; return;
} }
$editorContainer.removeClass('cp-app-code-present');
$previewButton.hide(); $previewButton.hide();
$previewContainer.hide(); $previewContainer.hide();
$previewButton.removeClass('active'); $previewButton.removeClass('active');
@ -224,11 +231,11 @@ define([
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////
var andThen2 = function (editor, CodeMirror, framework) { var andThen2 = function (editor, CodeMirror, framework, isPresentMode) {
var common = framework._.sfCommon; var common = framework._.sfCommon;
var previewPane = mkPreviewPane(editor, CodeMirror, framework); var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode);
var evModeChange = Util.mkEvent(); var evModeChange = Util.mkEvent();
evModeChange.reg(previewPane.modeChange); evModeChange.reg(previewPane.modeChange);
@ -335,8 +342,12 @@ define([
editor = CodeMirror.editor; editor = CodeMirror.editor;
}).nThen(waitFor()); }).nThen(waitFor());
}).nThen(function (waitFor) {
common.getSframeChannel().onReady(waitFor());
}).nThen(function (/*waitFor*/) { }).nThen(function (/*waitFor*/) {
andThen2(editor, CodeMirror, framework); common.isPresentUrl(function (err, val) {
andThen2(editor, CodeMirror, framework, val);
});
}); });
}; };
main(); main();

@ -3,14 +3,19 @@ define([
'/api/config', '/api/config',
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-hash.js',
'/common/media-tag.js', '/common/media-tag.js',
'/common/tippy.min.js', '/common/tippy.min.js',
'/customize/application_config.js', '/customize/application_config.js',
'/file/file-crypto.js',
'/bower_components/localforage/dist/localforage.min.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
'css!/common/tippy.css', 'css!/common/tippy.css',
], function ($, Config, Cryptpad, Util, MediaTag, Tippy, AppConfig) { ], function ($, Config, Cryptpad, Util, Hash, MediaTag, Tippy, AppConfig, FileCrypto, localForage) {
var UI = {}; var UI = {};
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
var Nacl = window.nacl;
/** /**
* Requirements from cryptpad-common.js * Requirements from cryptpad-common.js
@ -28,6 +33,40 @@ define([
* - createDropdown * - createDropdown
*/ */
var addThumbnail = function (err, thumb, $span, cb) {
var img = new Image();
img.src = 'data:;base64,'+thumb;
$span.find('.cp-icon').hide();
$span.prepend(img);
cb($(img));
};
UI.displayThumbnail = function (href, $container, cb) {
cb = cb || $.noop;
var parsed = Hash.parsePadUrl(href);
if (parsed.type !== 'file') { return; }
var k ='thumbnail-' + href;
var whenNewThumb = function () {
var secret = Hash.getSecrets('file', parsed.hash);
var hexFileName = Util.base64ToHex(secret.channel);
var src = Hash.getBlobPathFromHex(hexFileName);
var cryptKey = secret.keys && secret.keys.fileKeyStr;
var key = Nacl.util.decodeBase64(cryptKey);
FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) {
if (!metadata.thumbnail) {
return void localForage.setItem(k, 'EMPTY');
}
localForage.setItem(k, metadata.thumbnail, function (err) {
addThumbnail(err, metadata.thumbnail, $container, cb);
});
});
};
localForage.getItem(k, function (err, v) {
if (!v) { return void whenNewThumb(); }
if (v === 'EMPTY') { return; }
addThumbnail(err, v, $container, cb);
});
};
UI.updateTags = function (common, href) { UI.updateTags = function (common, href) {
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
sframeChan.query('Q_TAGS_GET', href || null, function (err, res) { sframeChan.query('Q_TAGS_GET', href || null, function (err, res) {
@ -92,7 +131,7 @@ define([
target: data.target target: data.target
}; };
if (data.filter && !data.filter(file)) { if (data.filter && !data.filter(file)) {
Cryptpad.log('TODO: invalid avatar (type or size)'); Cryptpad.log('Invalid avatar (type or size)');
return; return;
} }
data.FM.handleFile(file, ev); data.FM.handleFile(file, ev);
@ -398,9 +437,6 @@ define([
}, LIMIT_REFRESH_RATE * 3); }, LIMIT_REFRESH_RATE * 3);
updateUsage(); updateUsage();
/*getProxy().on('change', ['drive'], function () {
updateUsage();
}); TODO*/
cb(null, $container); cb(null, $container);
}; };

@ -80,6 +80,7 @@ define([
funcs.createButton = callWithCommon(UI.createButton); funcs.createButton = callWithCommon(UI.createButton);
funcs.createUsageBar = callWithCommon(UI.createUsageBar); funcs.createUsageBar = callWithCommon(UI.createUsageBar);
funcs.updateTags = callWithCommon(UI.updateTags); funcs.updateTags = callWithCommon(UI.updateTags);
funcs.displayThumbnail = UI.displayThumbnail;
// History // History
funcs.getHistory = callWithCommon(History.create); funcs.getHistory = callWithCommon(History.create);

@ -443,7 +443,7 @@ define([
$shareBlock.find('a.cp-toolbar-share-view-embed').click(function () { $shareBlock.find('a.cp-toolbar-share-view-embed').click(function () {
var url = origin + pathname + '#' + hashes.viewHash; var url = origin + pathname + '#' + hashes.viewHash;
var parsed = Cryptpad.parsePadUrl(url); var parsed = Cryptpad.parsePadUrl(url);
url = origin + parsed.getUrl({embed: true}); url = origin + parsed.getUrl({embed: true, present: true});
// Alertify content // Alertify content
var $content = $('<div>'); var $content = $('<div>');
$('<input>', {'style':'display:none;'}).appendTo($content); $('<input>', {'style':'display:none;'}).appendTo($content);

@ -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) {

@ -51,6 +51,7 @@ min-height: auto;
text-overflow: ellipsis; text-overflow: ellipsis;
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
border: 1px solid transparent;
&:not(.cp-app-drive-element-selected):not(.cp-app-drive-element-selected-tmp) { &:not(.cp-app-drive-element-selected):not(.cp-app-drive-element-selected-tmp) {
border: 1px solid #CCC; border: 1px solid #CCC;
@ -516,6 +517,13 @@ span {
font-size: 18px; font-size: 18px;
} }
} }
.cp-app-drive-element-thumbnail {
max-width: 64px;
max-height: 64px;
& ~ .fa {
display: none;
}
}
} }
.cp-app-drive-element-list { .cp-app-drive-element-list {
display: none; display: none;

@ -546,7 +546,7 @@ define([
}; };
var getFileNameExtension = function (name) { var getFileNameExtension = function (name) {
var matched = /\.\S+$/.exec(name); var matched = /\.[^\. ]+$/.exec(name);
if (matched && matched.length) { return matched[matched.length -1]; } if (matched && matched.length) { return matched[matched.length -1]; }
return ''; return '';
}; };
@ -1159,11 +1159,18 @@ define([
// The element with the class '.name' is underlined when the 'li' is hovered // The element with the class '.name' is underlined when the 'li' is hovered
var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name); var $name = $('<span>', {'class': 'cp-app-drive-element-name'}).text(name);
$span.html('');
$span.append($name); $span.append($name);
$span.append($state); $span.append($state);
var type = Messages.type[hrefData.type] || hrefData.type; var type = Messages.type[hrefData.type] || hrefData.type;
common.displayThumbnail(data.href, $span, function ($thumb) {
// Called only if the thumbnail exists
// Remove the .hide() added by displayThumnail() because it hides the icon in
// list mode too
$span.find('.cp-icon').removeAttr('style').addClass('cp-app-drive-element-list');
$thumb.addClass('cp-app-drive-element-grid')
.addClass('cp-app-drive-element-thumbnail');
});
var $type = $('<span>', { var $type = $('<span>', {
'class': 'cp-app-drive-element-type cp-app-drive-element-list' 'class': 'cp-app-drive-element-type cp-app-drive-element-list'
}).text(type); }).text(type);
@ -1181,7 +1188,6 @@ define([
var addFolderData = function (element, key, $span) { var addFolderData = function (element, key, $span) {
if (!element || !filesOp.isFolder(element)) { return; } if (!element || !filesOp.isFolder(element)) { return; }
$span.html('');
// The element with the class '.name' is underlined when the 'li' is hovered // The element with the class '.name' is underlined when the 'li' is hovered
var sf = filesOp.hasSubfolder(element); var sf = filesOp.hasSubfolder(element);
var files = filesOp.hasFile(element); var files = filesOp.hasFile(element);
@ -1239,11 +1245,6 @@ define([
APP.selectedFiles.splice(idx, 1); APP.selectedFiles.splice(idx, 1);
} }
} }
if (isFolder) {
addFolderData(element, key, $element);
} else {
addFileData(element, $element);
}
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
if (isFolder) { if (isFolder) {
APP.displayDirectory(newPath); APP.displayDirectory(newPath);
@ -1252,6 +1253,11 @@ define([
if (isTrash) { return; } if (isTrash) { return; }
openFile(root[key]); openFile(root[key]);
}); });
if (isFolder) {
addFolderData(element, key, $element);
} else {
addFileData(element, $element);
}
$element.addClass(liClass); $element.addClass(liClass);
$element.data('path', newPath); $element.data('path', newPath);
addDragAndDropHandlers($element, newPath, isFolder, !isTrash); addDragAndDropHandlers($element, newPath, isFolder, !isTrash);
@ -1586,10 +1592,11 @@ define([
['cp-app-drive-element-title', 'cp-app-drive-element-type', ['cp-app-drive-element-title', 'cp-app-drive-element-type',
'cp-app-drive-element-atime', 'cp-app-drive-element-ctime'].some(function (c) { 'cp-app-drive-element-atime', 'cp-app-drive-element-ctime'].some(function (c) {
if ($span.hasClass(c)) { if ($span.hasClass(c)) {
if (value === c) { descValue = descValue ? false : true; } var nValue = c.replace(/cp-app-drive-element-/, '');
if (value === nValue) { descValue = descValue ? false : true; }
else { else {
// atime and ctime should be ordered in a desc order at the first click // atime and ctime should be ordered in a desc order at the first click
value = c.replace(/cp-app-drive-element-/, ''); value = nValue;
descValue = value !== 'title'; descValue = value !== 'title';
} }
return true; return true;
@ -1641,7 +1648,7 @@ define([
} }
var classSorted; var classSorted;
if (APP.store[SORT_FILE_BY] === '') { classSorted = 'cp-app-drive-sort-filename'; } if (APP.store[SORT_FILE_BY] === '') { classSorted = 'cp-app-drive-sort-filename'; }
else if (APP.store[SORT_FILE_BY]) { classSorted = APP.store[SORT_FILE_BY]; } else if (APP.store[SORT_FILE_BY]) { classSorted = 'cp-app-drive-element-' + APP.store[SORT_FILE_BY]; }
if (classSorted) { if (classSorted) {
$list.find('.' + classSorted).addClass('cp-app-drive-sort-active').prepend($icon); $list.find('.' + classSorted).addClass('cp-app-drive-sort-active').prepend($icon);
} }
@ -1850,10 +1857,10 @@ define([
APP.selectedFiles.splice(sidx, 1); APP.selectedFiles.splice(sidx, 1);
} }
} }
addFileData(id, $element);
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
openFile(id); openFile(id);
}); });
addFileData(id, $element);
var path = [rootName, idx]; var path = [rootName, idx];
$element.data('path', path); $element.data('path', path);
$element.click(function(e) { $element.click(function(e) {
@ -1886,12 +1893,12 @@ define([
var $element = $('<li>', { var $element = $('<li>', {
'class': 'cp-app-drive-element cp-app-drive-element-row' + roClass 'class': 'cp-app-drive-element cp-app-drive-element-row' + roClass
}); });
addFileData(id, $element);
$element.data('path', [FILES_DATA, id]);
$element.data('element', id);
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
openFile(id); openFile(id);
}); });
addFileData(id, $element);
$element.data('path', [FILES_DATA, id]);
$element.data('element', id);
$element.click(function(e) { $element.click(function(e) {
e.stopPropagation(); e.stopPropagation();
onElementClick(e, $element); onElementClick(e, $element);
@ -2018,10 +2025,10 @@ define([
var $element = $('<li>', { var $element = $('<li>', {
'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass, 'class': 'cp-app-drive-element cp-app-drive-element-file cp-app-drive-element-row' + roClass,
}); });
addFileData(id, $element);
$element.prepend($icon).dblclick(function () { $element.prepend($icon).dblclick(function () {
openFile(id); openFile(id);
}); });
addFileData(id, $element);
$element.data('path', path); $element.data('path', path);
$element.click(function(e) { $element.click(function(e) {
e.stopPropagation(); e.stopPropagation();
@ -2487,6 +2494,18 @@ define([
})); }));
} }
$('<label>', {'for': 'cp-app-drive-prop-ctime'}).text(Messages.fm_creation)
.appendTo($d);
$d.append(Cryptpad.dialog.selectable(new Date(data.ctime).toLocaleString(), {
id: 'cp-app-drive-prop-ctime',
}));
$('<label>', {'for': 'cp-app-drive-prop-atime'}).text(Messages.fm_lastAccess)
.appendTo($d);
$d.append(Cryptpad.dialog.selectable(new Date(data.atime).toLocaleString(), {
id: 'cp-app-drive-prop-atime',
}));
if (APP.loggedIn && AppConfig.enablePinning) { if (APP.loggedIn && AppConfig.enablePinning) {
// check the size of this file... // check the size of this file...
common.getFileSize(data.href, function (e, bytes) { common.getFileSize(data.href, function (e, bytes) {

@ -21,11 +21,15 @@
.cp-filepicker-content-element { .cp-filepicker-content-element {
@darker: darken(@colortheme_modal-fg, 30%); @darker: darken(@colortheme_modal-fg, 30%);
width: 200px; width: 125px;
min-width: 200px; //min-width: 200px;
height: 1em; //height: 1em;
padding: 0.5em; padding: 10px;
margin: 5px; margin: 5px;
display: inline-flex;
flex-flow: column;
box-sizing: content-box; box-sizing: content-box;
text-align: left; text-align: left;
@ -41,15 +45,24 @@
color: @colortheme_modal-fg; color: @colortheme_modal-fg;
} }
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
align-items: center; align-items: center;
.cp-filepicker-content-element-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
height: 20px;
line-height: 20px;
margin-top: 5px;
max-width: 100%;
}
.fa { .fa {
cursor: pointer; cursor: pointer;
margin-right: 0.5em; width: 100px;
height: 100px;
font-size: 70px;
text-align: center;
line-height: 100px;
} }
} }
} }

@ -114,6 +114,7 @@ define([
} }
var $container = $('<span>', {'class': 'cp-filepicker-content'}).appendTo($block); var $container = $('<span>', {'class': 'cp-filepicker-content'}).appendTo($block);
// Update the files list when needed // Update the files list when needed
updateContainer = function () { updateContainer = function () {
$container.html(''); $container.html('');
@ -132,10 +133,14 @@ define([
'title': name, 'title': name,
}).appendTo($container); }).appendTo($container);
$span.append(Cryptpad.getFileIcon(data)); $span.append(Cryptpad.getFileIcon(data));
$span.append(name); $('<span>', {'class': 'cp-filepicker-content-element-name'}).text(name)
.appendTo($span);
$span.click(function () { $span.click(function () {
if (typeof onSelect === "function") { onSelect(data.href); } if (typeof onSelect === "function") { onSelect(data.href); }
}); });
// Add thumbnail if it exists
common.displayThumbnail(data.href, $span);
}); });
$input.focus(); $input.focus();
}; };

@ -567,7 +567,7 @@ div.cp-app-poll-realtime {
padding: 5px 10px; padding: 5px 10px;
.cp-app-poll-comments-list-msg-text { .cp-app-poll-comments-list-msg-text {
flex: 1; flex: 1;
white-space: pre; white-space: pre-wrap;
} }
.cp-app-poll-comments-list-msg-actions { .cp-app-poll-comments-list-msg-actions {
button { button {

@ -838,12 +838,9 @@ define([
prepareProxy(uncommitted, copyObject(Render.Example)); prepareProxy(uncommitted, copyObject(Render.Example));
if (!APP.readOnly) { if (!APP.readOnly) {
var coluid = Render.coluid(); var coluid = Render.coluid();
if (proxy.content.colsOrder.indexOf(userid) === -1 && if (userid) {
uncommitted.content.colsOrder.indexOf(userid) === -1) { // If userid exists, it means the user already has a pinned column
// The user doesn't have his own column: the new one should be his // and we should unlock it
coluid = userid;
} else {
// The user already has his own column: unlock it
unlockColumn(userid); unlockColumn(userid);
} }
uncommitted.content.colsOrder.push(coluid); uncommitted.content.colsOrder.push(coluid);
@ -968,10 +965,10 @@ define([
}); });
// If the user's column is not committed, add his username // If the user's column is not committed, add his username
var $userInput = $('.cp-app-poll-table-uncommitted > input[data-rt-id^='+ APP.userid +']'); var $userInput = $('.cp-app-poll-table-uncommitted > input');
if ($userInput.val() === '') { if (!APP.userid) {
var uname = metadataMgr.getUserData().name; var uname = metadataMgr.getUserData().name;
APP.uncommitted.content.cols[APP.userid] = uname; APP.uncommitted.content.cols[APP.uncommitted.content.colsOrder[0]] = uname;
$userInput.val(uname); $userInput.val(uname);
} }
@ -1164,7 +1161,6 @@ define([
.on('ready', function (info) { .on('ready', function (info) {
common.getPadAttribute('userid', function (e, userid) { common.getPadAttribute('userid', function (e, userid) {
if (e) { console.error(e); } if (e) { console.error(e); }
if (!userid) { userid = Render.coluid(); }
APP.userid = userid; APP.userid = userid;
onReady(info, userid); onReady(info, userid);
}); });

@ -401,7 +401,7 @@ define([
ifrw: window, ifrw: window,
common: Cryptpad, common: Cryptpad,
$container: APP.$toolbar, $container: APP.$toolbar,
pageTitle: Messages.settings_title pageTitle: Messages.profileButton
}; };
var toolbar = APP.toolbar = Toolbar.create(configTb); var toolbar = APP.toolbar = Toolbar.create(configTb);
toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar

Loading…
Cancel
Save