From e96d54e655f183abdbdaf7767e9e79bf16f395ad Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 7 Dec 2017 18:51:50 +0100 Subject: [PATCH 1/2] Add a pad creation page --- customize.dist/application_config.js | 2 + .../src/less2/include/creation.less | 36 +++++ www/code/app-code.less | 2 + www/common/common-ui-elements.js | 77 +++++++++- www/common/cryptpad-common.js | 9 +- www/common/outer/async-store.js | 3 + www/common/outer/chainpad-netflux-worker.js | 10 ++ www/common/sframe-app-framework.js | 8 +- www/common/sframe-chainpad-netflux-outer.js | 8 +- www/common/sframe-common-history.js | 2 +- www/common/sframe-common-outer.js | 134 +++++++++++++----- www/common/sframe-common.js | 1 + www/common/sframe-protocol.js | 5 +- 13 files changed, 256 insertions(+), 41 deletions(-) create mode 100644 customize.dist/src/less2/include/creation.less diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 079c36eab..6e6bb803d 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -65,5 +65,7 @@ define(function() { contacts: 'fa-users', }; + config.displayCreationScreen = true; + return config; }); diff --git a/customize.dist/src/less2/include/creation.less b/customize.dist/src/less2/include/creation.less new file mode 100644 index 000000000..d82c47adf --- /dev/null +++ b/customize.dist/src/less2/include/creation.less @@ -0,0 +1,36 @@ +@import (once) "./colortheme-all.less"; + +.creation_main() { + #cp-creation { + position: fixed; + z-index: 10000000; // #loading + top: 0px; + bottom: 0px; + left: 0px; + right: 0px; + background: @colortheme_loading-bg; + color: @colortheme_loading-color; + text-align: center; + font-size: 1.5em; + .cp-loading-container { + margin-top: 50vh; + transform: translateY(-50%); + } + .cp-loading-cryptofist { + margin-left: auto; + margin-right: auto; + height: 300px; + margin-bottom: 2em; + @media screen and (max-height: @browser_media-short-screen) { + display: none; + } + } + .cp-loading-spinner-container { + position: relative; + height: 100px; + > div { + height: 100px; + } + } + } +} diff --git a/www/code/app-code.less b/www/code/app-code.less index 592078086..b3b327c0c 100644 --- a/www/code/app-code.less +++ b/www/code/app-code.less @@ -4,6 +4,7 @@ @import (once) '../../customize/src/less2/include/fileupload.less'; @import (once) '../../customize/src/less2/include/alertify.less'; @import (once) '../../customize/src/less2/include/tokenfield.less'; +@import (once) '../../customize/src/less2/include/creation.less'; @_cp-toolbar-color-warn: @colortheme_code-warn; @@ -11,6 +12,7 @@ .fileupload_main(); .alertify_main(); .tokenfield_main(); +.creation_main(); // body &.cp-app-code { diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index c22cd28a4..e9487859f 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -387,7 +387,6 @@ define([ common.getAttribute(['general', 'markdown-help'], function (e, data) { if (e) { return void console.error(e); } if (data === true && $toolbarButton.length && tbState) { - console.log($toolbar.is(':visible')); $toolbarButton.click(); } }); @@ -1120,5 +1119,81 @@ define([ }); }; + UIElements.getPadCreationScreen = function (common, Toolbar, cb) { + if (!common.isLoggedIn()) { return void cb(); } + var sframeChan = common.getSframeChannel(); + var metadataMgr = common.getMetadataMgr(); + + var $body = $('body'); + var $creation = $('
', { id: 'cp-creation' }).appendTo($body); + var $bar = $('
', {'class': 'cp-toolbar'}).appendTo($creation); + + // Create a toolbar? + var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle']; + var configTb = { + displayed: displayed, + hideDisplayName: true, + $container: $bar, + metadataMgr: metadataMgr, + sfCommon: common, + pageTitle: 'Pad creation BETA' + }; + var toolbar = Toolbar.create(configTb); + toolbar.$rightside.html(''); + + // Create the pad + var create = function (template) { + sframeChan.query("Q_CREATE_PAD", { + owned: true, // TODO + expire: false, // TODO + template: template + }, function () { + $creation.remove(); + cb(); + }); + }; + + // Pick a template? + var type = metadataMgr.getMetadataLazy().type; + sframeChan.query("Q_TEMPLATE_EXIST", type, function (err, data) { + if (!data) { return; } + var $templateButton = $('