From 7de268316961066ba1907290674d4a1f1b1b518c Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 27 Jun 2017 18:17:52 +0200 Subject: [PATCH] make all apps use clientside templates --- customize.dist/pages.js | 22 ++++++++- customize.dist/src/less/loading.less | 2 + customize.dist/template.js | 67 +++++++++++++++++++++------- www/code/index.html | 18 +------- www/code/main.js | 1 + www/drive/index.html | 18 +------- www/file/index.html | 19 +------- www/pad/index.html | 19 +------- www/poll/index.html | 10 ++--- www/poll/main.js | 1 - www/slide/index.html | 22 +-------- www/whiteboard/index.html | 5 --- 12 files changed, 87 insertions(+), 117 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 3ca0028d1..7c8b45163 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -263,7 +263,7 @@ define([ }; var loadingScreen = function () { - return h('div#loading', + return h('div#loading', h('div.loadingContainer', [ h('img.cryptofist', { src: '/customize/cryptofist_small.png' @@ -479,5 +479,25 @@ define([ ]; }; + Pages['/drive/'] = Pages['/drive/index.html'] = function () { + return loadingScreen(); + }; + + Pages['/file/'] = Pages['/file/index.html'] = function () { + return loadingScreen(); + }; + + Pages['/pad/'] = Pages['/pad/index.html'] = function () { + return loadingScreen(); + }; + + Pages['/code/'] = Pages['/code/index.html'] = function () { + return loadingScreen(); + }; + + Pages['/slide/'] = Pages['/slide/index.html'] = function () { + return loadingScreen(); + }; + return Pages; }); diff --git a/customize.dist/src/less/loading.less b/customize.dist/src/less/loading.less index cc23c49d9..3f2ac0381 100644 --- a/customize.dist/src/less/loading.less +++ b/customize.dist/src/less/loading.less @@ -1,3 +1,5 @@ +@import "./variables.less"; + .cp #loading { position: fixed; z-index: 9999; diff --git a/customize.dist/template.js b/customize.dist/template.js index 02dace9df..c0ca4f1d5 100644 --- a/customize.dist/template.js +++ b/customize.dist/template.js @@ -10,7 +10,8 @@ $(function () { var Messages = Cryptpad.Messages; var $body = $('body'); var isMainApp = function () { - return /^\/(pad|code|slide|poll|whiteboard|file|media)\//.test(location.pathname); + console.error("Checking if is main app"); + return /^\/(pad|code|slide|poll|whiteboard|file|media|drive)\/$/.test(location.pathname); }; var rightLink = function (ref, loc, txt) { @@ -115,25 +116,61 @@ $(function () { var pathname = location.pathname; - if (isMainApp()) { + console.log("Is main app"); if (typeof(Pages[pathname]) === 'function') { - $('body').html(h('body', Pages[pathname]()).innerHTML); + require([ + 'less!/customize/src/less/loading.less' + ], function () { + //$('body').html(h('body', Pages[pathname]()).innerHTML); + + console.log("TEMPLATED"); - if (/whiteboard/.test(pathname)) { - setTimeout(function () { - require(['/whiteboard/main.js'], function () { - $('body').removeClass('noscroll'); + if (/whiteboard/.test(pathname)) { + $('body').html(h('body', Pages[pathname]()).innerHTML); + setTimeout(function () { + require(['/whiteboard/main.js'], function () { + $('body').removeClass('noscroll'); + }); + }); + } else if (/poll/.test(pathname)) { + $('body').html(h('body', Pages[pathname]()).innerHTML); + setTimeout(function () { + require(['/poll/main.js'], function () { + $('body').removeClass('noscroll'); + console.log("TEMPLATE!"); + }); + }); + } else if (/drive/.test(pathname)) { + $('body').append(h('body', Pages[pathname]()).innerHTML); + setTimeout(function () { + require(['/drive/main.js'], function () { + console.log("Templating done"); + }); }); - }); - } else if (/poll/.test(pathname)) { - setTimeout(function () { - require(['/poll/main.js'], function () { - $('body').removeClass('noscroll'); - console.log("TEMPLATE!"); + } else if (/file/.test(pathname)) { + $('body').append(h('body', Pages[pathname]()).innerHTML); + require([ '/file/main.js' ], function () { + console.log("Templating done"); }); - }); - } + } else if (/pad/.test(pathname)) { + $('body').append(h('body', Pages[pathname]()).innerHTML); + require([ '/pad/main.js' ], function () { + console.log("Templating done"); + }); + } else if (/code/.test(pathname)) { + $('body').append(h('body', Pages[pathname]()).innerHTML); + require([ '/code/main.js' ], function () { + console.log("Templating done"); + }); + } else if (/slide/.test(pathname)) { + $('body').append(h('body', Pages[pathname]()).innerHTML); + require([ '/slide/main.js' ], function () { + console.log("Templating done"); + }); + } + }); + return; } } diff --git a/www/code/index.html b/www/code/index.html index 0959d023e..be053d582 100644 --- a/www/code/index.html +++ b/www/code/index.html @@ -5,12 +5,7 @@ - - +