mirror of https://github.com/xwiki-labs/cryptpad
Merge pull request #1578 from cryptpad/Misaligned-file-menu-items
Fix misaligned/missing file dropdown menu items
This commit is contained in:
commit
b0407255ff
|
@ -73,8 +73,8 @@
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.fa:not(:last-child) {
|
i:not(:last-child) {
|
||||||
margin-right: 5px;
|
margin-right: 0.5rem;
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: fade(@cp_toolbar-fg, 30%);
|
background-color: fade(@cp_toolbar-fg, 30%);
|
||||||
|
|
|
@ -987,11 +987,8 @@
|
||||||
height: @toolbar_line-height;
|
height: @toolbar_line-height;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.fa, .cptools {
|
i ~ span {
|
||||||
margin-right: 5px;
|
margin-left: 0.5rem;
|
||||||
}
|
|
||||||
.cp-dropdown-button-title .cp-icon {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: fade(@cp_toolbar-bottom-bg, 70%);
|
background-color: fade(@cp_toolbar-bottom-bg, 70%);
|
||||||
|
@ -1113,15 +1110,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.cp-toolbar-bottom-left {
|
.cp-toolbar-bottom-left {
|
||||||
.cp-toolbar-appmenu, .cp-toolbar-file {
|
|
||||||
button {
|
|
||||||
&::before, .fa {
|
|
||||||
min-width: 20px;
|
|
||||||
text-align: center;
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.cp-toolbar-file {
|
.cp-toolbar-file {
|
||||||
order: 1;
|
order: 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,13 +623,22 @@ define([
|
||||||
var appType = (common.getMetadataMgr().getMetadata().type || 'pad').toUpperCase();
|
var appType = (common.getMetadataMgr().getMetadata().type || 'pad').toUpperCase();
|
||||||
data = data || {};
|
data = data || {};
|
||||||
if (!callback && data.callback) { callback = data.callback; }
|
if (!callback && data.callback) { callback = data.callback; }
|
||||||
|
|
||||||
|
let makeButton = function(iconClasses, buttonClasses, title, text) {
|
||||||
|
const ariaLabel = title || text || '';
|
||||||
|
return $(h('button', {
|
||||||
|
class: buttonClasses,
|
||||||
|
title: title,
|
||||||
|
'aria-label': ariaLabel
|
||||||
|
}, [
|
||||||
|
iconClasses ? h('i', { class: iconClasses }) : null,
|
||||||
|
text ? h('span', { class: 'cp-toolbar-drawer-element' }, text) : null
|
||||||
|
]));
|
||||||
|
};
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'export':
|
case 'export':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-download', 'cp-toolbar-icon-export', Messages.exportButtonTitle, Messages.exportButton);
|
||||||
'class': 'fa fa-download cp-toolbar-icon-export',
|
|
||||||
title: Messages.exportButtonTitle,
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.exportButton));
|
|
||||||
|
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(UI.clearTooltipsDelay);
|
.click(UI.clearTooltipsDelay);
|
||||||
|
@ -638,34 +647,28 @@ define([
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'import':
|
case 'import':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-upload', 'cp-toolbar-icon-import', Messages.importButtonTitle, Messages.importButton);
|
||||||
'class': 'fa fa-upload cp-toolbar-icon-import',
|
var importer = importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, {
|
||||||
title: Messages.importButtonTitle,
|
accept: data ? data.accept : undefined,
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.importButton));
|
binary: data ? data.binary : undefined
|
||||||
var importer = importContent((data && data.binary) ? 'application/octet-stream' : 'text/plain', callback, {
|
});
|
||||||
accept: data ? data.accept : undefined,
|
|
||||||
binary: data ? data.binary : undefined
|
|
||||||
});
|
|
||||||
|
|
||||||
var handler = data.first? function () {
|
var handler = data.first? function () {
|
||||||
data.first(function () {
|
data.first(function () {
|
||||||
importer(); // Make sure we don't pass arguments to importer
|
importer(); // Make sure we don't pass arguments to importer
|
||||||
});
|
|
||||||
}: importer; //importContent;
|
|
||||||
|
|
||||||
button
|
|
||||||
.click(common.prepareFeedback(type))
|
|
||||||
.click(function () {
|
|
||||||
handler();
|
|
||||||
UI.clearTooltipsDelay();
|
|
||||||
});
|
});
|
||||||
|
}: importer; //importContent;
|
||||||
|
|
||||||
|
button
|
||||||
|
.click(common.prepareFeedback(type))
|
||||||
|
.click(function () {
|
||||||
|
handler();
|
||||||
|
UI.clearTooltipsDelay();
|
||||||
|
});
|
||||||
//}
|
//}
|
||||||
break;
|
break;
|
||||||
case 'upload':
|
case 'upload':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-upload', 'btn btn-primary new', Messages.uploadButtonTitle, Messages.uploadButton);
|
||||||
'class': 'btn btn-primary new',
|
|
||||||
title: Messages.uploadButtonTitle,
|
|
||||||
}).append($('<span>', {'class':'fa fa-upload'})).append(' '+Messages.uploadButton);
|
|
||||||
if (!data.FM) { return; }
|
if (!data.FM) { return; }
|
||||||
var $input = $('<input>', {
|
var $input = $('<input>', {
|
||||||
'type': 'file',
|
'type': 'file',
|
||||||
|
@ -697,9 +700,7 @@ define([
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'copy':
|
case 'copy':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-files-o', 'cp-toolbar-icon-import', '', Messages.makeACopy);
|
||||||
'class': 'fa fa-files-o cp-toolbar-icon-import',
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.makeACopy));
|
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
|
@ -710,9 +711,7 @@ define([
|
||||||
case 'importtemplate':
|
case 'importtemplate':
|
||||||
if (!AppConfig.enableTemplates) { return; }
|
if (!AppConfig.enableTemplates) { return; }
|
||||||
if (!common.isLoggedIn()) { return; }
|
if (!common.isLoggedIn()) { return; }
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-upload', 'cp-toolbar-icon-import', '', Messages.template_import);
|
||||||
'class': 'fa fa-upload cp-toolbar-icon-import',
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.template_import));
|
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
|
@ -724,9 +723,7 @@ define([
|
||||||
case 'template':
|
case 'template':
|
||||||
if (!AppConfig.enableTemplates) { return; }
|
if (!AppConfig.enableTemplates) { return; }
|
||||||
if (!common.isLoggedIn()) { return; }
|
if (!common.isLoggedIn()) { return; }
|
||||||
button = $('<button>', {
|
button = makeButton('cptools cptools-new-template', 'cp-toolbar-icon-template', '', Messages.saveTemplateButton);
|
||||||
'class': 'cptools cptools-new-template cp-toolbar-icon-template',
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.saveTemplateButton));
|
|
||||||
if (data.rt || data.callback) {
|
if (data.rt || data.callback) {
|
||||||
button
|
button
|
||||||
.click(function () {
|
.click(function () {
|
||||||
|
@ -774,9 +771,7 @@ define([
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'forget':
|
case 'forget':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-trash', 'cp-toolbar-icon-forget', '', Messages.fc_delete);
|
||||||
'class': "fa fa-trash cp-toolbar-icon-forget"
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.fc_delete));
|
|
||||||
callback = typeof callback === "function" ? callback : function () {};
|
callback = typeof callback === "function" ? callback : function () {};
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
|
@ -837,25 +832,16 @@ define([
|
||||||
])).click(common.prepareFeedback(type));
|
])).click(common.prepareFeedback(type));
|
||||||
break;
|
break;
|
||||||
case 'print':
|
case 'print':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-print', 'cp-toolbar-icon-print', Messages.printButtonTitle2, Messages.printText);
|
||||||
title: Messages.printButtonTitle2,
|
|
||||||
'class': "fa fa-print cp-toolbar-icon-print",
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.printText));
|
|
||||||
break;
|
break;
|
||||||
case 'history':
|
case 'history':
|
||||||
if (!AppConfig.enableHistory) {
|
if (!AppConfig.enableHistory) {
|
||||||
button = $('<span>');
|
button = $('<span>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-history', 'cp-toolbar-icon-history', Messages.historyButton, Messages.historyText, Messages.historyButton);
|
||||||
title: Messages.historyButton,
|
|
||||||
'aria-label': Messages.historyButton,
|
|
||||||
'class': "fa fa-history cp-toolbar-icon-history",
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.historyText));
|
|
||||||
if (data.histConfig) {
|
if (data.histConfig) {
|
||||||
button
|
button.click(common.prepareFeedback(type)).on('click', function () {
|
||||||
.click(common.prepareFeedback(type))
|
|
||||||
.on('click', function () {
|
|
||||||
common.getHistory(data.histConfig);
|
common.getHistory(data.histConfig);
|
||||||
UI.clearTooltipsDelay();
|
UI.clearTooltipsDelay();
|
||||||
});
|
});
|
||||||
|
@ -879,9 +865,10 @@ define([
|
||||||
if (callback) { button.click(callback); }
|
if (callback) { button.click(callback); }
|
||||||
break;
|
break;
|
||||||
case 'storeindrive':
|
case 'storeindrive':
|
||||||
button = $(h('button.cp-toolbar-storeindrive.fa.fa-hdd-o', {
|
button = $(h('button.cp-toolbar-storeindrive', {
|
||||||
style: 'display:none;'
|
style: 'display:none;'
|
||||||
}, [
|
}, [
|
||||||
|
h('i.fa.fa-hdd-o'),
|
||||||
h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_storeInDrive)
|
h('span.cp-toolbar-name.cp-toolbar-drawer-element', Messages.toolbar_storeInDrive)
|
||||||
])).click(common.prepareFeedback(type)).click(function () {
|
])).click(common.prepareFeedback(type)).click(function () {
|
||||||
$(button).hide();
|
$(button).hide();
|
||||||
|
@ -902,10 +889,7 @@ define([
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'hashtag':
|
case 'hashtag':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-hashtag', 'cp-toolbar-icon-hashtag', Messages.tags_title, Messages.fc_hashtag);
|
||||||
'class': 'fa fa-hashtag cp-toolbar-icon-hashtag',
|
|
||||||
title: Messages.tags_title,
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.fc_hashtag));
|
|
||||||
button.click(common.prepareFeedback(type))
|
button.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
common.isPadStored(function (err, data) {
|
common.isPadStored(function (err, data) {
|
||||||
|
@ -950,11 +934,8 @@ define([
|
||||||
//updateIcon(data.element.is(':visible'));
|
//updateIcon(data.element.is(':visible'));
|
||||||
break;
|
break;
|
||||||
case 'properties':
|
case 'properties':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-info-circle', 'cp-toolbar-icon-properties', Messages.propertiesButtonTitle, Messages.propertiesButton);
|
||||||
'class': 'fa fa-info-circle cp-toolbar-icon-properties',
|
button
|
||||||
title: Messages.propertiesButtonTitle,
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'})
|
|
||||||
.text(Messages.propertiesButton))
|
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
var isTop;
|
var isTop;
|
||||||
|
@ -970,11 +951,8 @@ define([
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'save': // OnlyOffice save
|
case 'save': // OnlyOffice save
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-save', '', Messages.settings_save, Messages.settings_save);
|
||||||
'class': 'fa fa-save',
|
button
|
||||||
title: Messages.settings_save,
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'})
|
|
||||||
.text(Messages.settings_save))
|
|
||||||
.click(function() {
|
.click(function() {
|
||||||
common.prepareFeedback(type);
|
common.prepareFeedback(type);
|
||||||
UI.clearTooltipsDelay();
|
UI.clearTooltipsDelay();
|
||||||
|
@ -982,10 +960,7 @@ define([
|
||||||
if (callback) { button.click(callback); }
|
if (callback) { button.click(callback); }
|
||||||
break;
|
break;
|
||||||
case 'newpad':
|
case 'newpad':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-plus', 'cp-toolbar-icon-newpad', Messages.newButtonTitle, Messages.newButton);
|
||||||
title: Messages.newButtonTitle,
|
|
||||||
'class': 'fa fa-plus cp-toolbar-icon-newpad',
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.newButton));
|
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
|
@ -994,10 +969,7 @@ define([
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'snapshots':
|
case 'snapshots':
|
||||||
button = $('<button>', {
|
button = makeButton('fa fa-camera', 'cp-toolbar-icon-snapshots', Messages.snapshots_button,Messages.snapshots_button);
|
||||||
title: Messages.snapshots_button,
|
|
||||||
'class': 'fa fa-camera cp-toolbar-icon-snapshots',
|
|
||||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.snapshots_button));
|
|
||||||
button
|
button
|
||||||
.click(common.prepareFeedback(type))
|
.click(common.prepareFeedback(type))
|
||||||
.click(function () {
|
.click(function () {
|
||||||
|
@ -1280,6 +1252,7 @@ define([
|
||||||
kanban: 'kanban',
|
kanban: 'kanban',
|
||||||
form: 'form',
|
form: 'form',
|
||||||
whiteboard: 'whiteboard',
|
whiteboard: 'whiteboard',
|
||||||
|
diagram: 'diagram',
|
||||||
};
|
};
|
||||||
|
|
||||||
var href = "https://docs.cryptpad.org/en/user_guide/applications.html";
|
var href = "https://docs.cryptpad.org/en/user_guide/applications.html";
|
||||||
|
|
|
@ -4,20 +4,24 @@
|
||||||
|
|
||||||
// This is the initialization loading the CryptPad libraries
|
// This is the initialization loading the CryptPad libraries
|
||||||
define([
|
define([
|
||||||
|
'jquery',
|
||||||
'/common/sframe-app-framework.js',
|
'/common/sframe-app-framework.js',
|
||||||
'/customize/messages.js', // translation keys
|
'/customize/messages.js', // translation keys
|
||||||
'/components/pako/dist/pako.min.js',
|
'/components/pako/dist/pako.min.js',
|
||||||
'/components/x2js/x2js.js',
|
'/components/x2js/x2js.js',
|
||||||
'/diagram/util.js',
|
'/diagram/util.js',
|
||||||
|
'/common/common-ui-elements.js',
|
||||||
'/components/tweetnacl/nacl-fast.min.js',
|
'/components/tweetnacl/nacl-fast.min.js',
|
||||||
'less!/diagram/app-diagram.less',
|
'less!/diagram/app-diagram.less',
|
||||||
'css!/diagram/drawio.css',
|
'css!/diagram/drawio.css',
|
||||||
], function (
|
], function (
|
||||||
|
$,
|
||||||
Framework,
|
Framework,
|
||||||
Messages,
|
Messages,
|
||||||
pako,
|
pako,
|
||||||
X2JS,
|
X2JS,
|
||||||
DiagramUtil
|
DiagramUtil,
|
||||||
|
UIElements
|
||||||
) {
|
) {
|
||||||
const Nacl = window.nacl;
|
const Nacl = window.nacl;
|
||||||
const APP = window.APP = {};
|
const APP = window.APP = {};
|
||||||
|
@ -61,6 +65,15 @@ define([
|
||||||
return JSON.stringify(o1) === JSON.stringify(o2);
|
return JSON.stringify(o1) === JSON.stringify(o2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var mkHelpMenu = function (framework) {
|
||||||
|
var $codeMirrorContainer = $('#cp-app-diagram-container');
|
||||||
|
var helpMenu = framework._.sfCommon.createHelpMenu(['diagram']);
|
||||||
|
$codeMirrorContainer.prepend(helpMenu.menu);
|
||||||
|
|
||||||
|
var $helpMenuButton = UIElements.getEntryFromButton(helpMenu.button);
|
||||||
|
framework._.toolbar.$drawer.append($helpMenuButton);
|
||||||
|
};
|
||||||
|
|
||||||
// This is the main initialization loop
|
// This is the main initialization loop
|
||||||
var onFrameworkReady = function (framework) {
|
var onFrameworkReady = function (framework) {
|
||||||
var EMPTY_DRAWIO = "<mxfile type=\"embed\"><diagram id=\"bWoO5ACGZIaXrIiKNTKd\" name=\"Page-1\"><mxGraphModel dx=\"1259\" dy=\"718\" grid=\"1\" gridSize=\"10\" guides=\"1\" tooltips=\"1\" connect=\"1\" arrows=\"1\" fold=\"1\" page=\"1\" pageScale=\"1\" pageWidth=\"827\" pageHeight=\"1169\" math=\"0\" shadow=\"0\"><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel></diagram></mxfile>";
|
var EMPTY_DRAWIO = "<mxfile type=\"embed\"><diagram id=\"bWoO5ACGZIaXrIiKNTKd\" name=\"Page-1\"><mxGraphModel dx=\"1259\" dy=\"718\" grid=\"1\" gridSize=\"10\" guides=\"1\" tooltips=\"1\" connect=\"1\" arrows=\"1\" fold=\"1\" page=\"1\" pageScale=\"1\" pageWidth=\"827\" pageHeight=\"1169\" math=\"0\" shadow=\"0\"><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel></diagram></mxfile>";
|
||||||
|
@ -69,6 +82,11 @@ define([
|
||||||
var lastContent = x2js.xml2js(EMPTY_DRAWIO);
|
var lastContent = x2js.xml2js(EMPTY_DRAWIO);
|
||||||
var drawIoInitalized = false;
|
var drawIoInitalized = false;
|
||||||
|
|
||||||
|
var privateData = framework._.cpNfInner.metadataMgr.getPrivateData();
|
||||||
|
if (!privateData.isEmbed) {
|
||||||
|
mkHelpMenu(framework);
|
||||||
|
}
|
||||||
|
|
||||||
var postMessageToDrawio = function(msg) {
|
var postMessageToDrawio = function(msg) {
|
||||||
if (!drawIoInitalized) {
|
if (!drawIoInitalized) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue