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

This commit is contained in:
ansuz
2017-05-12 10:54:32 +02:00
11 changed files with 169 additions and 21 deletions

View File

@@ -143,7 +143,7 @@ define([
return {
show: function () {
$target.show();
$target.css('display', 'inline');
return this;
},
hide: function () {

View File

@@ -840,21 +840,17 @@ define([
return;
}
var rootFiles = getFiles([ROOT, TEMPLATE]).slice();
//var toClean = [];
var root = find([ROOT]);
us.forEach(function (el) {
if (!isFile(el) || rootFiles.indexOf(el) !== -1) {
return;
//toClean.push(idx);
}
var name = getFileData(el).title || NEW_FILE_NAME;
var data = getFileData(el);
var name = data ? data.title : NEW_FILE_NAME;
var newName = getAvailableName(root, name);
root[newName] = el;
});
delete files[UNSORTED];
/*toClean.forEach(function (idx) {
us.splice(idx, 1);
});*/
};
var fixTemplate = function () {
if (!Array.isArray(files[TEMPLATE])) { debug("TEMPLATE was not an array"); files[TEMPLATE] = []; }

View File

@@ -371,6 +371,7 @@ define([
e.stopPropagation();
});
// Arrow keys to modify the selection
$(ifrw).keydown(function (e) {
var $searchBar = $tree.find('#searchInput');
if ($searchBar.is(':focus') && $searchBar.val()) { return; }
@@ -381,6 +382,7 @@ define([
if (e.ctrlKey) { ev.ctrlKey = true; }
if (e.shiftKey) { ev.shiftKey = true; }
var click = function (el) {
if (!el) { return; }
module.onElementClick(ev, $(el));
};
@@ -402,6 +404,7 @@ define([
// [Left, Up, Right, Down]
if ([37, 38, 39, 40].indexOf(e.which) === -1) { return; }
e.preventDefault();
var $selection = $content.find('.element.selected');
if ($selection.length === 0) { return void click($elements.first()[0]); }
@@ -715,6 +718,21 @@ define([
updatePathSize();
};
var scrollTo = function ($element) {
// Current scroll position
var st = $content.scrollTop();
// Block height
var h = $content.height();
// Current top position of the element relative to the scroll position
var pos = Math.round($element.offset().top - $content.position().top);
// Element height
var eh = $element.outerHeight();
// New scroll value
var v = st + pos + eh - h;
// If the element is completely visile, don't change the scroll position
if (pos+eh <= h && pos >= 0) { return; }
$content.scrollTop(v);
};
// Add the "selected" class to the "li" corresponding to the clicked element
var onElementClick = module.onElementClick = function (e, $element) {
// If "Ctrl" is pressed, do not remove the current selection
@@ -730,6 +748,7 @@ define([
log(Messages.fm_selectError);
return;
}
scrollTo($element);
// Add the selected class to the clicked / right-clicked element
// Remove the class if it already has it
// If ctrlKey, add to the selection
@@ -1793,7 +1812,11 @@ define([
module.resetTree();
// in history mode we want to focus the version number input
if (!history.isHistoryMode && !APP.mobile()) { $tree.find('#searchInput').focus(); }
if (!history.isHistoryMode && !APP.mobile()) {
var st = $tree.scrollTop() || 0;
$tree.find('#searchInput').focus();
$tree.scrollTop(st);
}
$tree.find('#searchInput')[0].selectionStart = getSearchCursor();
$tree.find('#searchInput')[0].selectionEnd = getSearchCursor();
@@ -2080,12 +2103,14 @@ define([
};
module.resetTree = function () {
var s = $tree.scrollTop() || 0;
$tree.html('');
if (displayedCategories.indexOf(SEARCH) !== -1) { createSearch($tree); }
if (displayedCategories.indexOf(ROOT) !== -1) { createTree($tree, [ROOT]); }
if (displayedCategories.indexOf(TEMPLATE) !== -1) { createTemplate($tree, [TEMPLATE]); }
if (displayedCategories.indexOf(FILES_DATA) !== -1) { createAllFiles($tree, [FILES_DATA]); }
if (displayedCategories.indexOf(TRASH) !== -1) { createTrash($tree, [TRASH]); }
$tree.scrollTop(s);
};
module.hideMenu = function () {
@@ -2665,12 +2690,16 @@ define([
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px');
if (quota >= 0.8) {
var origin = encodeURIComponent(window.location.origin);
var $upgradeLink = $('<a>', {
href: "https://account.cryptpad.fr/#!on=" + origin,
rel: "noreferrer noopener",
target: "_blank",
}).appendTo($leftside);
$('<button>', {
'class': 'upgrade buttonSuccess',
title: Messages.upgradeTitle
}).text(Messages.upgrade).click(function () {
// TODO
}).appendTo($leftside);
}).text(Messages.upgrade).appendTo($upgradeLink);
}
if (quota < 0.8) { $usage.addClass('normal'); }

View File

@@ -188,6 +188,7 @@ define([
title: false,
slide: false,
date: false,
transition: true,
style: ''
};
@@ -220,6 +221,13 @@ define([
}).appendTo($p).css('width', 'auto');
$('<label>', {'for': 'checkTitle'}).text(Messages.printTitle).appendTo($p);
$p.append($('<br>'));
// Transition
$('<input>', {type: 'checkbox', id: 'checkTransition', checked: slideOptionsTmp.transition}).on('change', function () {
var c = this.checked;
slideOptionsTmp.transition = c;
}).appendTo($p).css('width', 'auto');
$('<label>', {'for': 'checkTransition'}).text(Messages.printTransition).appendTo($p);
$p.append($('<br>'));
// CSS
$('<label>', {'for': 'cssPrint'}).text(Messages.printCSS).appendTo($p);
$p.append($('<br>'));

View File

@@ -168,13 +168,16 @@ body .CodeMirror-focused .cm-matchhighlight {
}
.cp div.modal #content,
.cp div#modal #content {
transition: margin-left 1s;
font-size: 20vh;
position: relative;
height: 100%;
overflow: visible;
white-space: nowrap;
}
.cp div.modal #content.transition,
.cp div#modal #content.transition {
transition: margin-left 1s;
}
.cp div.modal #content .slide-frame,
.cp div#modal #content .slide-frame {
display: inline-block;
@@ -198,10 +201,11 @@ body .CodeMirror-focused .cm-matchhighlight {
}
.cp div.modal #content .slide-container,
.cp div#modal #content .slide-container {
display: inline-block;
display: inline-flex;
height: 100%;
width: 100vw;
text-align: center;
vertical-align: top;
}
.cp div.modal .center,
.cp div#modal .center {

View File

@@ -184,6 +184,10 @@ define([
$('<div>', {'class': 'slideTitle'}).text(APP.title).appendTo($(el));
}
});
$content.removeClass('transition');
if (options.transition) {
$content.addClass('transition');
}
//$content.find('.' + slideClass).hide();
//$content.find('.' + slideClass + ':eq( ' + i + ' )').show();
$content.css('margin-left', -(i*100)+'vw');

View File

@@ -161,7 +161,9 @@ div.modal, div#modal {
width: 100%;
}
#content {
transition: margin-left 1s;
&.transition {
transition: margin-left 1s;
}
font-size: 20vh;
position: relative;
height: 100%;
@@ -191,9 +193,10 @@ div.modal, div#modal {
margin: auto;
}
.slide-container {
display: inline-block;
display: inline-flex;
height: 100%; width: 100vw;
text-align: center;
vertical-align: top;
}
}