Remove tag and filepicker buttons for anon users

pull/1/head
yflory 7 years ago
parent c18d4297e1
commit d666e9e7ee

@ -156,7 +156,7 @@ define(function () {
out.filePickerButton = "Intégrer un fichier stocké dans CryptDrive"; out.filePickerButton = "Intégrer un fichier stocké dans CryptDrive";
out.filePicker_close = "Fermer"; out.filePicker_close = "Fermer";
out.filePicker_description = "Choisissez un fichier de votre CryptDrive pour l'intégrer ou uploadez-en un nouveau"; out.filePicker_description = "Choisissez un fichier de votre CryptDrive pour l'intégrer ou importez-en un nouveau";
out.filePicker_filter = "Filtrez les fichiers par leur nom"; out.filePicker_filter = "Filtrez les fichiers par leur nom";
out.or = 'ou'; out.or = 'ou';

@ -342,6 +342,7 @@ define([
}; };
var createFilePicker = function () { var createFilePicker = function () {
if (!common.isLoggedIn()) { return; }
common.initFilePicker({ common.initFilePicker({
onSelect: function (data) { onSelect: function (data) {
if (data.type !== 'file') { if (data.type !== 'file') {
@ -369,6 +370,7 @@ define([
}).appendTo(toolbar.$rightside).hide(); }).appendTo(toolbar.$rightside).hide();
}; };
var setMediaTagEmbedder = function (mte) { var setMediaTagEmbedder = function (mte) {
if (!common.isLoggedIn()) { return; }
if (!mte || readOnly) { if (!mte || readOnly) {
$embedButton.hide(); $embedButton.hide();
return; return;

@ -2638,6 +2638,10 @@ define([
APP.hideMenu(); APP.hideMenu();
}); });
if (!APP.loggedIn) {
$defaultContextMenu.find('.cp-app-drive-context-delete').text(Messages.fc_remove)
.attr('data-icon', 'fa-eraser');
}
$defaultContextMenu.on("click", "a", function(e) { $defaultContextMenu.on("click", "a", function(e) {
e.stopPropagation(); e.stopPropagation();
var paths = $(this).data('paths'); var paths = $(this).data('paths');

@ -1142,27 +1142,29 @@ define([
APP.$publishButton = $publish; APP.$publishButton = $publish;
updatePublishButton(); updatePublishButton();
var fileDialogCfg = { if (common.isLoggedIn()) {
onSelect: function (data) { var fileDialogCfg = {
if (data.type === 'file' && APP.editor) { onSelect: function (data) {
var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; if (data.type === 'file' && APP.editor) {
APP.editor.replaceSelection(mt); var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>';
return; APP.editor.replaceSelection(mt);
return;
}
} }
}
};
common.initFilePicker(fileDialogCfg);
APP.$mediaTagButton = $('<button>', {
title: Messages.filePickerButton,
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
style: 'font-size: 17px'
}).click(function () {
var pickerCfg = {
types: ['file'],
where: ['root']
}; };
common.openFilePicker(pickerCfg); common.initFilePicker(fileDialogCfg);
}).appendTo($rightside); APP.$mediaTagButton = $('<button>', {
title: Messages.filePickerButton,
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
style: 'font-size: 17px'
}).click(function () {
var pickerCfg = {
types: ['file'],
where: ['root']
};
common.openFilePicker(pickerCfg);
}).appendTo($rightside);
}
var $tags = common.createButton('hashtag', true); var $tags = common.createButton('hashtag', true);
$rightside.append($tags); $rightside.append($tags);

@ -470,36 +470,39 @@ define([
.click(function () { .click(function () {
$('<input>', {type:'file'}).on('change', onUpload).click(); $('<input>', {type:'file'}).on('change', onUpload).click();
}).appendTo($rightside); }).appendTo($rightside);
var fileDialogCfg = {
onSelect: function (data) { if (common.isLoggedIn()) {
if (data.type === 'file') { var fileDialogCfg = {
var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'; onSelect: function (data) {
common.displayMediatagImage($(mt), function (err, $image) { if (data.type === 'file') {
Util.blobURLToImage($image.attr('src'), function (imgSrc) { var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>';
var img = new Image(); common.displayMediatagImage($(mt), function (err, $image) {
img.onload = function () { addImageToCanvas(img); }; Util.blobURLToImage($image.attr('src'), function (imgSrc) {
img.src = imgSrc; var img = new Image();
img.onload = function () { addImageToCanvas(img); };
img.src = imgSrc;
});
}); });
}); return;
return; }
}
}
};
common.initFilePicker(fileDialogCfg);
APP.$mediaTagButton = $('<button>', {
title: Messages.filePickerButton,
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
style: 'font-size: 17px'
}).click(function () {
var pickerCfg = {
types: ['file'],
where: ['root'],
filter: {
fileType: ['image/']
} }
}; };
common.openFilePicker(pickerCfg); common.initFilePicker(fileDialogCfg);
}).appendTo($rightside); APP.$mediaTagButton = $('<button>', {
title: Messages.filePickerButton,
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
style: 'font-size: 17px'
}).click(function () {
var pickerCfg = {
types: ['file'],
where: ['root'],
filter: {
fileType: ['image/']
}
};
common.openFilePicker(pickerCfg);
}).appendTo($rightside);
}
} }
metadataMgr.onChange(function () { metadataMgr.onChange(function () {

Loading…
Cancel
Save