Creation page with mobile support

pull/1/head
yflory 7 years ago
parent e96d54e655
commit 1922dbfd75

@ -1,35 +1,146 @@
@import (once) "./colortheme-all.less"; @import (once) "./colortheme-all.less";
@import (once) "./tools.less";
.creation_main() { .creation_main() {
#cp-creation { .tippy-popper {
position: fixed; z-index: 100000001 !important;
z-index: 10000000; // #loading }
top: 0px; #cp-creation-container {
bottom: 0px; //position: fixed;
left: 0px; z-index: 100000000; // #loading * 10
right: 0px; //top: 0px;
//bottom: 0px;
//left: 0px;
//right: 0px;
background: @colortheme_loading-bg; background: @colortheme_loading-bg;
color: @colortheme_loading-color; color: @colortheme_loading-color;
display: flex;
align-items: center;
width: 100%;
height: 100%;
overflow: auto;
@media screen and (max-height: 600px), screen and (max-width: 500px) {
align-items: baseline;
}
}
#cp-creation {
text-align: center; text-align: center;
font-size: 1.5em; font: @colortheme_app-font;
.cp-loading-container { width: 100%;
margin-top: 50vh; & > div {
transform: translateY(-50%); width: 60vw;
max-width: 100%;
margin: 40px auto;
text-align: left;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
h2, p {
width: 100%;
}
h2 {
display: flex;
justify-content: space-between;
.cp-creation-help {
display: none;
}
}
@media screen and (max-width: 500px) {
width: ~"calc(100% - 30px)";
}
@media screen and (max-height: 600px), screen and (max-width: 500px) {
h2 .cp-creation-help {
display: inline;
}
p {
display: none;
}
}
@media screen and (min-height: 601px) {
@media screen and (min-width: 501px) {
p {
display: block !important;
}
}
}
} }
.cp-loading-cryptofist {
margin-left: auto; .cp-creation-create{
margin-right: auto; button {
height: 300px; .tools_unselectable();
margin-bottom: 2em; padding: 15px;
@media screen and (max-height: @browser_media-short-screen) { background: darken(@colortheme_loading-bg, 10%);
display: none; color: @colortheme_loading-color;
margin: 3px 10px;
border: none;
cursor: pointer;
&:hover {
background: darken(@colortheme_loading-bg, 5%);
}
}
}
input[type="radio"] {
display: none;
&:checked {
& + label {
font-weight: bold;
background-color: lighten(@colortheme_loading-bg, 20%);
cursor: default;
border: 1px solid #c1158e;
&:hover {
background-color: lighten(@colortheme_loading-bg, 20%);
}
}
} }
} }
.cp-loading-spinner-container { input[type="radio"] + label {
position: relative; .tools_unselectable();
height: 100px; padding: 15px;
> div { display: inline-flex;
height: 100px; align-items: center;
justify-content: center;
width: 200px;
height: 50px;
padding: 5px;
margin: 0 20px;
border: 1px solid @colortheme_loading-color;
cursor: pointer;
&:hover {
background-color: lighten(@colortheme_loading-bg, 10%);
}
}
.cp-creation-expire {
#cp-creation-expire-true {
display: none;
&:checked {
& + label {
height: 100px;
.cp-creation-expire-picker {
display: inline;
}
}
}
}
label[for="cp-creation-expire-true"] {
flex-wrap: wrap;
.cp-creation-expire-picker {
display: none;
}
input {
width: 70px;
}
select {
width: 100px;
}
input, select {
border: none;
height: 30px;
background: @colortheme_loading-bg;
color: @colortheme_loading-color;
border-radius: 3px;
}
} }
} }
} }

@ -787,5 +787,24 @@ define(function () {
out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken."; out.feedback_privacy = "We care about your privacy, and at the same time we want CryptPad to be very easy to use. We use this file to figure out which UI features matter to our users, by requesting it along with a parameter specifying which action was taken.";
out.feedback_optout = "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback"; out.feedback_optout = "If you would like to opt out, visit <a href='/settings/'>your user settings page</a>, where you'll find a checkbox to enable or disable user feedback";
// Creation page
out.creation_404 = "This pad not longer exists. Use the following form to create a new pad";
out.creation_ownedTitle = "Type of pad";
out.creation_ownedTrue = "Owned pad";
out.creation_ownedFalse = "Open pad";
out.creation_owned1 = "An <b>owned</b> pad is a pad that you can delete from the server whenever you want. Once it is deleted, no one else can access it, even if it is stored in their CryptDrive.";
out.creation_owned2 = "An <b>open</b> pad doesn't have any owner and thus, it can't be deleted from the server unless it has reached its expiration time.";
out.creation_expireTitle = "Life time";
out.creation_expireTrue = "Add a life time";
out.creation_expireFalse = "Unlimited";
out.creation_expireHours = "Hours";
out.creation_expireDays = "Days";
out.creation_expireMonths = "Months";
out.creation_expire1 = "By default, a pad stored by a registered users will never be removed from the server, unless it is requested by its owner.";
out.creation_expire2 = "If you prefer, you can set a life time to make sure the pad will be permanently deleted from the server and unavailable after the specified date.";
out.creation_createTitle = "Create a pad";
out.creation_createFromTemplate = "From template";
out.creation_createFromScratch = "From scratch";
return out; return out;
}); });

@ -6,11 +6,12 @@ define([
'/common/common-language.js', '/common/common-language.js',
'/common/common-interface.js', '/common/common-interface.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/hyperscript.js',
'/common/media-tag.js', '/common/media-tag.js',
'/customize/messages.js', '/customize/messages.js',
'css!/common/tippy.css', 'css!/common/tippy.css',
], function ($, Config, Util, Hash, Language, UI, Feedback, MediaTag, Messages) { ], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages) {
var UIElements = {}; var UIElements = {};
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
@ -1119,33 +1120,124 @@ define([
}); });
}; };
UIElements.getPadCreationScreen = function (common, Toolbar, cb) { UIElements.getPadCreationScreen = function (common, cb) {
if (!common.isLoggedIn()) { return void cb(); } if (!common.isLoggedIn()) { return void cb(); }
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var metadataMgr = common.getMetadataMgr(); var metadataMgr = common.getMetadataMgr();
var type = metadataMgr.getMetadataLazy().type;
var $body = $('body'); var $body = $('body');
var $creation = $('<div>', { id: 'cp-creation' }).appendTo($body); var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
var $bar = $('<div>', {'class': 'cp-toolbar'}).appendTo($creation); var $creation = $('<div>', { id: 'cp-creation' }).appendTo($creationContainer);
// Create a toolbar? var setHTML = function (e, html) {
var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle']; e.innerHTML = html;
var configTb = { return e;
displayed: displayed, };
hideDisplayName: true,
$container: $bar, // Title
metadataMgr: metadataMgr, $creation.append(h('h1.cp-creation-title', Messages['button_new'+type]));
sfCommon: common,
pageTitle: 'Pad creation BETA' // Deleted pad warning
if (metadataMgr.getPrivateData().isDeleted) {
$creation.append(h('div.cp-creation-deleted', Messages.creation_404));
}
var createHelper = function (text) {
var q = h('span.cp-creation-help.fa.fa-question', {
title: text
});
return q;
}; };
var toolbar = Toolbar.create(configTb);
toolbar.$rightside.html(''); // Owned pads
var owned = h('div.cp-creation-owned', [
h('h2', [
Messages.creation_ownedTitle,
createHelper(Messages.creation_owned1 + '\n' + Messages.creation_owned2)
]),
setHTML(h('p'), Messages.creation_owned1 + '<br>' + Messages.creation_owned2),
h('input#cp-creation-owned-true.cp-creation-owned-value', {
type: 'radio',
name: 'cp-creation-owned',
value: 1,
checked: 'checked'
}),
h('label', { 'for': 'cp-creation-owned-true' }, Messages.creation_ownedTrue),
h('input#cp-creation-owned-false.cp-creation-owned-value', {
type: 'radio',
name: 'cp-creation-owned',
value: 0
}),
h('label', { 'for': 'cp-creation-owned-false' }, Messages.creation_ownedFalse)
]);
$creation.append(owned);
// Life time
var expire = h('div.cp-creation-expire', [
h('h2', [
Messages.creation_expireTitle,
createHelper(Messages.creation_expire1, Messages.creation_expire2)
]),
setHTML(h('p'), Messages.creation_expire1 + '<br>' + Messages.creation_expire2),
h('input#cp-creation-expire-false.cp-creation-expire-value', {
type: 'radio',
name: 'cp-creation-expire',
value: 0,
checked: 'checked'
}),
h('label', { 'for': 'cp-creation-expire-false' }, Messages.creation_expireFalse),
h('input#cp-creation-expire-true.cp-creation-expire-value', {
type: 'radio',
name: 'cp-creation-expire',
value: 1
}),
h('label', { 'for': 'cp-creation-expire-true' }, [
Messages.creation_expireTrue,
h('span.cp-creation-expire-picker', [
h('input#cp-creation-expire-val', {
type: "number",
min: 1,
max: 100,
value: 3
}),
h('select#cp-creation-expire-unit', [
h('option', { value: 'hour' }, Messages.creation_expireHours),
h('option', { value: 'day' }, Messages.creation_expireDays),
h('option', {
value: 'month',
selected: 'selected'
}, Messages.creation_expireMonths)
])
])
])
]);
$creation.append(expire);
// Create the pad // Create the pad
var create = function (template) { var create = function (template) {
// Type of pad
var ownedVal = parseInt($('input[name="cp-creation-owned"]:checked').val());
// Life time
var expireVal = 0;
if(parseInt($('input[name="cp-creation-expire"]:checked').val())) {
var unit = 0;
switch ($('#cp-creation-expire-unit').val()) {
case "hour" : unit = 3600; break;
case "day" : unit = 3600 * 24; break;
case "month": unit = 3600 * 24 * 30; break;
default: unit = 0;
}
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
}
// TODO remove these lines
ownedVal = undefined;
expire = undefined;
sframeChan.query("Q_CREATE_PAD", { sframeChan.query("Q_CREATE_PAD", {
owned: true, // TODO owned: ownedVal,
expire: false, // TODO expire: expireVal,
template: template template: template
}, function () { }, function () {
$creation.remove(); $creation.remove();
@ -1153,12 +1245,14 @@ define([
}); });
}; };
var $create = $(h('div.cp-creation-create', [
h('h2', Messages.creation_createTitle)
])).appendTo($creation);
// Pick a template? // Pick a template?
var type = metadataMgr.getMetadataLazy().type;
sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) {
if (!data) { return; } if (!data) { return; }
var $templateButton = $('<button>').text('Create pad from template') var $templateButton = $('<button>').text(Messages.creation_createFromTemplate)
.appendTo($creation); .appendTo($create);
var pickerCfg = { var pickerCfg = {
types: [type], types: [type],
@ -1175,15 +1269,8 @@ define([
var fileDialogCfg = { var fileDialogCfg = {
onSelect: function (data) { onSelect: function (data) {
if (data.type === type && first) { if (data.type === type && first) {
//UI.addLoadingScreen({hideTips: true});
create(data.href); create(data.href);
first = false; first = false;
/*sframeChan.query('Q_TEMPLATE_USE', data.href, function () {
UI.removeLoadingScreen();
Feedback.send('TEMPLATE_USED');
});*/
//if (focus) { focus.focus(); }
//return;
} }
} }
}; };
@ -1191,8 +1278,10 @@ define([
}); });
}); });
var $button = $('<button>').text('Create pad').appendTo($creation); var $button = $('<button>').text(Messages.creation_createFromScratch).appendTo($create);
$button.click(); $button.click(function () {
create();
});
}; };
return UIElements; return UIElements;

@ -373,11 +373,12 @@ define([
nThen(function (waitFor) { nThen(function (waitFor) {
UI.addLoadingScreen(); UI.addLoadingScreen();
SFCommon.create(waitFor(function (c) { common = c; })); SFCommon.create(waitFor(function (c) { common = c; }));
}).nThen(function (waitFor) {
common.getSframeChannel().onReady(waitFor());
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
if (!AppConfig.displayCreationScreen) { return; } if (!AppConfig.displayCreationScreen) { return; }
if (common.getMetadataMgr().getPrivateData().isNewFile) { if (common.getMetadataMgr().getPrivateData().isNewFile) {
console.log('newFile'); common.getPadCreationScreen(waitFor());
common.getPadCreationScreen(Toolbar, waitFor());
} }
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
cpNfInner = common.startRealtime({ cpNfInner = common.startRealtime({

@ -186,7 +186,8 @@ define([
donateURL: Cryptpad.donateURL, donateURL: Cryptpad.donateURL,
upgradeURL: Cryptpad.upgradeURL upgradeURL: Cryptpad.upgradeURL
}, },
isNewFile: isNewFile isNewFile: isNewFile,
isDeleted: window.location.hash.length > 0
}; };
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; } for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
@ -620,6 +621,9 @@ define([
if (data.owned) { if (data.owned) {
//rtConfig.owners = [edPublic]; //rtConfig.owners = [edPublic];
} }
if (data.expire) {
//rtConfig.expire = data.expire;
}
if (data.template) { if (data.template) {
// Pass rtConfig to useTemplate because Cryptput will create the file and // Pass rtConfig to useTemplate because Cryptput will create the file and

Loading…
Cancel
Save