Merge branch 'newCk' into staging

This commit is contained in:
yflory
2017-06-20 14:57:19 +02:00
15 changed files with 264 additions and 89 deletions

View File

@@ -67,6 +67,11 @@ define([
id: uid(),
});
var parsed = Cryptpad.parsePadUrl(window.location.href);
if (typeof parsed.type === "string") {
$toolbar.addClass(parsed.type);
}
var $topContainer = $('<div>', {'class': TOP_CLS});
var $userContainer = $('<span>', {
'class': USER_CLS
@@ -396,7 +401,6 @@ define([
'class': TITLE_CLS
}).appendTo(toolbar.$top);
// TODO: move these functions to toolbar or common?
if (typeof config.title !== "object") {
console.error("config.title", config);
throw new Error("config.title is not an object");
@@ -413,6 +417,10 @@ define([
'class': 'pencilIcon',
'title': Messages.clickToEdit
});
var $saveIcon = $('<span>', {
'class': 'saveIcon',
'title': Messages.saveTitle
}).hide();
if (config.readOnly === 1 || typeof(Cryptpad) === "undefined") { return $titleContainer; }
var $input = $('<input>', {
type: 'text',
@@ -426,6 +434,11 @@ define([
style: 'font-family: FontAwesome;'
});
$pencilIcon.append($icon).appendTo($titleContainer);
var $icon2 = $('<span>', {
'class': 'fa fa-check readonly',
style: 'font-family: FontAwesome;'
});
$saveIcon.append($icon2).appendTo($titleContainer);
}
// Events
@@ -436,26 +449,34 @@ define([
e.stopPropagation();
return true;
});
var save = function () {
var name = $input.val().trim();
if (name === "") {
name = $input.attr('placeholder');
}
Cryptpad.renamePad(name, function (err, newtitle) {
if (err) { return; }
$text.text(newtitle);
callback(null, newtitle);
$input.hide();
$text.show();
$pencilIcon.show();
$saveIcon.hide();
//$pencilIcon.css('display', '');
});
};
$input.on('keyup', function (e) {
if (e.which === 13 && toolbar.connected === true) {
var name = $input.val().trim();
if (name === "") {
name = $input.attr('placeholder');
}
Cryptpad.renamePad(name, null, function (err, newtitle) {
if (err) { return; }
$text.text(newtitle);
callback(null, newtitle);
$input.hide();
$text.show();
//$pencilIcon.css('display', '');
});
save();
} else if (e.which === 27) {
$input.hide();
$text.show();
$pencilIcon.show();
$saveIcon.hide();
//$pencilIcon.css('display', '');
}
});
$saveIcon.click(save);
var displayInput = function () {
if (toolbar.connected === false) { return; }
@@ -465,6 +486,8 @@ define([
$input.val(inputVal);
$input.show();
$input.focus();
$pencilIcon.hide();
$saveIcon.show();
};
$text.on('click', displayInput);
$pencilIcon.on('click', displayInput);
@@ -486,16 +509,16 @@ define([
title: Messages.header_logoTitle,
'class': "cryptpad-logo"
}).append($imgTag);
var $span = $('<span>').text('CryptPad');
var $span = $('<span>').text('CryptDrive');
var $aTagBig = $aTagSmall.clone().addClass('large').append($span);
$aTagSmall.addClass('narrow');
var onClick = function (e) {
e.preventDefault();
if (e.ctrlKey) {
window.open('/');
window.open('/drive');
return;
}
window.location = "/";
window.location = "/drive";
};
var onContext = function (e) { e.stopPropagation(); };

View File

@@ -227,6 +227,7 @@ span.fa-folder-open {
display: flex;
flex-flow: column;
flex: 1;
min-width: 0;
}
#content {
box-sizing: border-box;
@@ -461,6 +462,8 @@ span.fa-folder-open {
z-index: 100;
box-sizing: content-box;
padding: 0 6px;
display: flex;
flex-flow: row;
/* The container <div> - needed to position the dropdown content */
}
#driveToolbar .newPadContainer {
@@ -479,15 +482,10 @@ span.fa-folder-open {
font-family: FontAwesome;
}
#driveToolbar button.element {
border-radius: 2px;
background: #888;
color: #eee;
font-size: 14px;
border: 1px solid #888;
font-weight: bold;
}
#driveToolbar button.element:hover {
background: #777;
height: 26px;
width: 26px;
padding: 0;
box-sizing: border-box;
}
#driveToolbar button.new {
padding: 0 5px;
@@ -515,7 +513,7 @@ span.fa-folder-open {
margin-right: 2px;
}
#driveToolbar .leftside {
width: 250px;
width: auto;
margin: 0;
padding: 0;
display: inline-block;
@@ -527,6 +525,7 @@ span.fa-folder-open {
float: right;
}
#driveToolbar .path {
flex: 1;
width: 100%;
height: 30px;
line-height: 30px;

View File

@@ -276,7 +276,9 @@ span {
display: flex;
flex-flow: column;
flex: 1;
}
// Needed to avoid the folder's path to overflows
// https://stackoverflow.com/questions/38223879/white-space-nowrap-breaks-flexbox-layout
min-width: 0;}
#content {
box-sizing: border-box;
background: @content-bg;
@@ -533,6 +535,8 @@ span {
z-index: 100;
box-sizing: content-box;
padding: 0 6px;
display: flex;
flex-flow: row;
.newPadContainer {
display: inline-block;
@@ -549,15 +553,10 @@ span {
font-family: FontAwesome;
}
&.element {
border-radius: 2px;
background: @toolbar-button-bg;
color: @toolbar-button-fg;
font-size: 14px;
border: 1px solid @toolbar-button-border;
font-weight: bold;
&:hover {
background: @toolbar-button-bg-hover;
}
height: 26px;
width: 26px;
padding: 0;
box-sizing: border-box;
}
&.new {
padding: 0 5px;
@@ -588,7 +587,7 @@ span {
}
.leftside {
width: 250px;
width: auto;
margin: 0;
padding: 0;
display: inline-block;
@@ -600,6 +599,7 @@ span {
float: right;
}
.path {
flex: 1;
width: 100%;
height: 30px;
line-height: 30px;

View File

@@ -650,7 +650,10 @@ define([
};
var updatePathSize = function () {
$driveToolbar.find('.path').css('max-width', 'calc(100vw - '+$tree.width()+'px - 50px)');
return;
var $tb = $driveToolbar;
var w = $tree.width() + $tb.find('.leftside').width() + $tb.find('.rightside').width();
$driveToolbar.find('.path').css('max-width', 'calc(100vw - '+w+'px)');
};
var getSelectedPaths = function ($element) {
@@ -1339,10 +1342,10 @@ define([
});
var $listButton = $('<button>', {
'class': 'element'
'class': 'element btn btn-secondary'
}).append($listIcon.clone());
var $gridButton = $('<button>', {
'class': 'element'
'class': 'element btn btn-secondary'
}).append($gridIcon.clone());
$listButton.click(function () {
@@ -1381,6 +1384,12 @@ define([
content: Messages.fm_folder
});
options.push({tag: 'hr'});
options.push({
tag: 'a',
attributes: {'class': 'uploadFile'},
content: Messages.uploadButton
});
options.push({tag: 'hr'});
}
AppConfig.availablePadTypes.forEach(function (type) {
if (type === 'drive') { return; }
@@ -1427,6 +1436,20 @@ define([
$block.find('a.newFolder').click(function () {
filesOp.addFolder(currentPath, null, onCreated);
});
$block.find('a.uploadFile').click(function () {
var $input = $('<input>', {
'type': 'file',
'style': 'display: none;'
}).on('change', function (e) {
var file = e.target.files[0];
var ev = {
target: $content[0]
};
APP.FM.handleFile(file, ev);
if (callback) { callback(); }
});
$input.click();
});
}
$block.find('a.newdoc').click(function () {
var type = $(this).attr('data-type') || 'pad';
@@ -1437,16 +1460,6 @@ define([
return $block;
};
var createUploadButton = function () {
var inTrash = filesOp.isPathIn(currentPath, [TRASH]);
if (inTrash) { return; }
var data = {
FM: APP.FM,
target: $content[0]
};
return Cryptpad.createButton('upload', false, data);
};
var hideNewButton = function () {
$iframe.find('.dropdown-bar-content').hide();
};
@@ -1620,8 +1633,8 @@ define([
var $toolbar = $driveToolbar;
$toolbar.html('');
$('<div>', {'class': 'leftside'}).appendTo($toolbar);
$('<div>', {'class': 'rightside'}).appendTo($toolbar);
$('<div>', {'class': 'path unselectable'}).appendTo($toolbar);
$('<div>', {'class': 'rightside'}).appendTo($toolbar);
return $toolbar;
};
@@ -1846,6 +1859,9 @@ define([
}
var $list = $('<ul>').appendTo($dirContent);
// NewButton can be undefined if we're in read only mode
$toolbar.find('.leftside').append(createNewButton(isInRoot));
createTitle(path).appendTo($toolbar.find('.path'));
updatePathSize();
@@ -1879,11 +1895,6 @@ define([
}
updateContextButton();
// NewButton can be undefined if we're in read only mode
$toolbar.find('.leftside').append(createNewButton(isInRoot));
$toolbar.find('.leftside').append(createUploadButton());
var $folderHeader = getFolderListHeader();
var $fileHeader = getFileListHeader(true);

View File

@@ -3,6 +3,9 @@ body {
margin: 0px;
height: 100%;
}
#toolbar {
display: flex;
}
body {
display: flex;
flex-flow: column;
@@ -17,7 +20,6 @@ body {
align-items: center;
}
.cryptpad-toolbar {
margin-bottom: 1px;
padding: 0px;
display: inline-block;
}

View File

@@ -7,6 +7,11 @@ html, body {
margin: 0px;
height: 100%;
}
#toolbar {
display: flex; // We need this to remove a 3px border at the bottom of the toolbar
}
body {
display: flex;
flex-flow: column;
@@ -21,7 +26,6 @@ body {
align-items: center;
}
.cryptpad-toolbar {
margin-bottom: 1px;
padding: 0px;
display: inline-block;
}

View File

@@ -12,15 +12,19 @@
}
#cke_1_top {
overflow: visible;
padding: 0 6px;
padding: 0px;
}
#cke_1_toolbox {
display: inline-block;
width: 100%;
background-color: #c1e7ff;
}
#cke_1_toolbox .cke_toolbar {
height: 28px;
padding: 2px 0;
}
#cke_1_top .cryptpad-toolbar {
margin-bottom: 1px;
padding: 0px;
padding: 0 6px;
display: inline-block;
}
</style>

View File

@@ -1,6 +1,7 @@
define(function () {
define(['/common/cryptpad-common.js'], function (Cryptpad) {
// Adds a context menu entry to open the selected link in a new tab.
// See https://github.com/xwiki-contrib/application-ckeditor/commit/755d193497bf23ed874d874b4ae92fbee887fc10
var Messages = Cryptpad.Messages;
return {
addSupportForOpeningLinksInNewTab : function (Ckeditor) {
// Returns the DOM element of the active (currently focused) link. It has also support for linked image widgets.
@@ -35,7 +36,7 @@ define(function () {
});
if (typeof editor.addMenuItem === 'function') {
editor.addMenuItem('openLink', {
label: 'Open Link in New Tab',
label: Messages.openLinkInNewTab,
command: 'openLink',
group: 'link',
order: -1