Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
@@ -263,5 +263,28 @@ define([
|
||||
};
|
||||
};
|
||||
|
||||
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file icon"});
|
||||
var $fileAppIcon = $('<span>', {"class": "fa fa-file-text-o file icon fileColor"});
|
||||
var $padIcon = $('<span>', {"class": "fa fa-file-word-o file icon padColor"});
|
||||
var $codeIcon = $('<span>', {"class": "fa fa-file-code-o file icon codeColor"});
|
||||
var $slideIcon = $('<span>', {"class": "fa fa-file-powerpoint-o file icon slideColor"});
|
||||
var $pollIcon = $('<span>', {"class": "fa fa-calendar file icon pollColor"});
|
||||
var $whiteboardIcon = $('<span>', {"class": "fa fa-paint-brush whiteboardColor"});
|
||||
UI.getIcon = function (type) {
|
||||
var $icon;
|
||||
|
||||
switch(type) {
|
||||
case 'pad': $icon = $padIcon.clone(); break;
|
||||
case 'file': $icon = $fileAppIcon.clone(); break;
|
||||
case 'code': $icon = $codeIcon.clone(); break;
|
||||
case 'slide': $icon = $slideIcon.clone(); break;
|
||||
case 'poll': $icon = $pollIcon.clone(); break;
|
||||
case 'whiteboard': $icon = $whiteboardIcon.clone(); break;
|
||||
default: $icon = $fileIcon.clone();
|
||||
}
|
||||
|
||||
return $icon;
|
||||
};
|
||||
|
||||
return UI;
|
||||
});
|
||||
|
||||
@@ -12,12 +12,13 @@ define([
|
||||
'/common/common-metadata.js',
|
||||
'/common/common-codemirror.js',
|
||||
'/common/common-file.js',
|
||||
'/file/file-crypto.js',
|
||||
|
||||
'/common/clipboard.js',
|
||||
'/common/pinpad.js',
|
||||
'/customize/application_config.js'
|
||||
], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata,
|
||||
CodeMirror, Files, Clipboard, Pinpad, AppConfig) {
|
||||
CodeMirror, Files, FileCrypto, Clipboard, Pinpad, AppConfig) {
|
||||
|
||||
/* This file exposes functionality which is specific to Cryptpad, but not to
|
||||
any particular pad type. This includes functions for committing metadata
|
||||
@@ -65,6 +66,7 @@ define([
|
||||
common.errorLoadingScreen = UI.errorLoadingScreen;
|
||||
common.notify = UI.notify;
|
||||
common.unnotify = UI.unnotify;
|
||||
common.getIcon = UI.getIcon;
|
||||
|
||||
// import common utilities for export
|
||||
common.find = Util.find;
|
||||
@@ -850,8 +852,9 @@ define([
|
||||
common.createUsageBar = function (cb) {
|
||||
// getPinnedUsage updates common.account.usage, and other values
|
||||
// so we can just use those and only check for errors
|
||||
var $container = $('<span>', {'class':'limit-container'});
|
||||
var todo = function (err) {
|
||||
var $container = $('<span>', {'class':'limit-container'});
|
||||
$container.html('');
|
||||
if (err) {
|
||||
return void window.setTimeout(function () {
|
||||
common.getPinnedUsage(todo);
|
||||
@@ -867,8 +870,7 @@ define([
|
||||
|
||||
var $limit = $('<span>', {'class': 'cryptpad-limit-bar'}).appendTo($container);
|
||||
var quota = usage/limit;
|
||||
var width = Math.floor(Math.min(quota, 1)*$limit.width()); // the bar is 200px width
|
||||
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px');
|
||||
var $usage = $('<span>', {'class': 'usage'}).css('width', quota*100+'%');
|
||||
|
||||
var makeDonateButton = function () {
|
||||
$('<a>', {
|
||||
@@ -921,9 +923,9 @@ define([
|
||||
window.setTimeout(function () {
|
||||
common.getPinnedUsage(todo);
|
||||
}, LIMIT_REFRESH_RATE);
|
||||
cb(err, $container);
|
||||
};
|
||||
common.getPinnedUsage(todo);
|
||||
cb(null, $container);
|
||||
};
|
||||
|
||||
var prepareFeedback = common.prepareFeedback = function (key) {
|
||||
@@ -975,9 +977,14 @@ define([
|
||||
var ev = {
|
||||
target: data.target
|
||||
};
|
||||
if (data.filter && !data.filter(file)) {
|
||||
common.log('TODO: invalid avatar (type or size)');
|
||||
return;
|
||||
}
|
||||
data.FM.handleFile(file, ev);
|
||||
if (callback) { callback(); }
|
||||
});
|
||||
if (data.accept) { $input.attr('accept', data.accept); }
|
||||
button.click(function () { $input.click(); });
|
||||
break;
|
||||
case 'template':
|
||||
@@ -1099,8 +1106,7 @@ define([
|
||||
}
|
||||
button = $('<button>', {
|
||||
title: Messages.historyButton,
|
||||
'class': "fa fa-history",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
'class': "fa fa-history history",
|
||||
});
|
||||
if (data.histConfig) {
|
||||
button
|
||||
@@ -1130,6 +1136,70 @@ define([
|
||||
return button;
|
||||
};
|
||||
|
||||
common.avatarAllowedTypes = [
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/jpg',
|
||||
'image/gif',
|
||||
];
|
||||
common.displayAvatar = function ($container, href) {
|
||||
var MutationObserver = window.MutationObserver;
|
||||
$container.html('');
|
||||
if (href) {
|
||||
var parsed = common.parsePadUrl(href);
|
||||
var secret = common.getSecrets('file', parsed.hash);
|
||||
if (secret.keys && secret.channel) {
|
||||
var cryptKey = secret.keys && secret.keys.fileKeyStr;
|
||||
var hexFileName = common.base64ToHex(secret.channel);
|
||||
var src = common.getBlobPathFromHex(hexFileName);
|
||||
common.getFileSize(href, function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
if (typeof data !== "number") { return; }
|
||||
if (common.bytesToMegabytes(data) > 0.5) { return; }
|
||||
var $img = $('<media-tag>').appendTo($container);
|
||||
$img.attr('src', src);
|
||||
$img.attr('data-crypto-key', 'cryptpad:' + cryptKey);
|
||||
require(['/common/media-tag.js'], function (MediaTag) {
|
||||
MediaTag.CryptoFilter.setAllowedMediaTypes(common.avatarAllowedTypes);
|
||||
MediaTag($img[0]);
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type === 'childList' && mutation.addedNodes.length) {
|
||||
console.log(mutation);
|
||||
if (mutation.addedNodes.length > 1 ||
|
||||
mutation.addedNodes[0].nodeName !== 'IMG') {
|
||||
$img.remove();
|
||||
return;
|
||||
//TODO display default avatar
|
||||
}
|
||||
var $image = $img.find('img');
|
||||
var onLoad = function () {
|
||||
var w = $image.width();
|
||||
var h = $image.height();
|
||||
if (w>h) {
|
||||
$image.css('max-height', '100%');
|
||||
$img.css('flex-direction', 'row');
|
||||
return;
|
||||
}
|
||||
$image.css('max-width', '100%');
|
||||
$img.css('flex-direction', 'column');
|
||||
};
|
||||
if ($image[0].complete) { onLoad(); }
|
||||
$image.on('load', onLoad);
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe($img[0], {
|
||||
attributes: false,
|
||||
childList: true,
|
||||
characterData: false
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Create a button with a dropdown menu
|
||||
// input is a config object with parameters:
|
||||
// - container (optional): the dropdown container (span)
|
||||
|
||||
@@ -156,7 +156,6 @@ define([
|
||||
MediaTag(el);
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
console.log(mutation);
|
||||
if (mutation.type === 'childList') {
|
||||
var list_values = [].slice.call(el.children);
|
||||
mediaMap[el.getAttribute('src')] = list_values;
|
||||
|
||||
@@ -71,7 +71,7 @@ define([
|
||||
$('<span>', {'class': STATE_CLS}).hide().appendTo($userContainer);
|
||||
$('<span>', {'class': LAG_CLS}).hide().appendTo($userContainer);
|
||||
$('<span>', {'class': LIMIT_CLS}).hide().appendTo($userContainer);
|
||||
//$('<span>', {'class': NEWPAD_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
|
||||
$('<span>', {'class': NEWPAD_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
|
||||
$('<span>', {'class': USERADMIN_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
|
||||
|
||||
$toolbar.append($topContainer)
|
||||
@@ -177,9 +177,8 @@ define([
|
||||
var numberOfViewUsers = numberOfUsers - userList.length;
|
||||
|
||||
// Update the userlist
|
||||
var $usersTitle = $('<h2>').text(Messages.users);
|
||||
var $editUsers = $userlistContent;
|
||||
$editUsers.html('').append($usersTitle);
|
||||
var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html('');
|
||||
|
||||
|
||||
var $editUsersList = $('<div>', {'class': 'userlist-others'});
|
||||
|
||||
@@ -248,7 +247,10 @@ define([
|
||||
throw new Error("You must provide a `userList` object to display the userlist");
|
||||
}
|
||||
var $content = $('<div>', {'class': 'userlist-drawer'});
|
||||
var $closeIcon = $('<span>', {"class": "fa fa-window-close close"}).appendTo($content);
|
||||
$('<h2>').text(Messages.users).appendTo($content);
|
||||
$('<p>', {'class': USERLIST_CLS}).appendTo($content);
|
||||
|
||||
toolbar.userlistContent = $content;
|
||||
|
||||
var $container = $('<span>', {id: 'userButtons'});
|
||||
@@ -263,15 +265,41 @@ define([
|
||||
config.$contentContainer.prepend($content);
|
||||
}
|
||||
|
||||
var $ck = config.$container.find('.cke_toolbox_main');
|
||||
var hide = function () {
|
||||
$content.hide();
|
||||
$button.removeClass('active');
|
||||
$ck.css({
|
||||
'display': '',
|
||||
'padding-left': '',
|
||||
'margin-bottom': ''
|
||||
});
|
||||
};
|
||||
var show = function () {
|
||||
$content.show();
|
||||
$button.addClass('active');
|
||||
$ck.css({
|
||||
'display': 'inline-block',
|
||||
'padding-left': '175px',
|
||||
'margin-bottom': '-3px'
|
||||
});
|
||||
$content.css('margin-top', (-$ck.height())+'px');
|
||||
};
|
||||
|
||||
$closeIcon.click(hide);
|
||||
$button.click(function () {
|
||||
$content.toggle();
|
||||
var visible = $content.is(':visible');
|
||||
if (visible) { hide(); }
|
||||
else { show(); }
|
||||
visible = !visible;
|
||||
Cryptpad.setAttribute('userlist-drawer', visible);
|
||||
Cryptpad.feedback(visible?'USERLIST_SHOW': 'USERLIST_HIDE');
|
||||
});
|
||||
|
||||
|
||||
Cryptpad.getAttribute('userlist-drawer', function (err, val) {
|
||||
if (val === false) { $content.hide(); }
|
||||
if (val === false) { return void hide(); }
|
||||
show();
|
||||
});
|
||||
|
||||
return $container;
|
||||
@@ -658,9 +686,10 @@ define([
|
||||
};
|
||||
|
||||
var createNewPad = function (toolbar) {
|
||||
var $newPad = $('<span>', {
|
||||
/*var $newPad = $('<span>', {
|
||||
'class': NEWPAD_CLS + " dropdown-bar"
|
||||
}).appendTo(toolbar.$top);
|
||||
}).appendTo(toolbar.$top);*/
|
||||
var $newPad = toolbar.$top.find('.'+NEWPAD_CLS).show();
|
||||
|
||||
var pads_options = [];
|
||||
Config.availablePadTypes.forEach(function (p) {
|
||||
@@ -673,19 +702,20 @@ define([
|
||||
'target': '_blank',
|
||||
'href': '/' + p + '/',
|
||||
},
|
||||
content: Messages.type[p]
|
||||
content: $('<div>').append(Cryptpad.getIcon(p)).html() + Messages.type[p]
|
||||
});
|
||||
});
|
||||
var dropdownConfig = {
|
||||
text: '', // Button initial text
|
||||
options: pads_options, // Entries displayed in the menu
|
||||
container: $newPad,
|
||||
left: true,
|
||||
feedback: /drive/.test(window.location.pathname)?
|
||||
'DRIVE_NEWPAD': 'NEWPAD',
|
||||
};
|
||||
var $newPadBlock = Cryptpad.createDropdown(dropdownConfig);
|
||||
$newPadBlock.find('button').attr('title', Messages.newButtonTitle);
|
||||
$newPadBlock.find('button').addClass('fa fa-plus');
|
||||
$newPadBlock.find('button').addClass('fa fa-th');
|
||||
return $newPadBlock;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user