From bd16e0f0e7022dd94184f5e7fa7e8613af9cbd69 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 10 Apr 2017 14:19:15 +0200 Subject: [PATCH] Templates in polls and canvas, and ability to disable templates --- customize.dist/application_config.js | 1 + www/common/cryptpad-common.js | 13 ++++++++++--- www/drive/main.js | 3 ++- www/poll/main.js | 22 +++++++++++++++++++++- www/whiteboard/main.js | 21 ++++++++++++++++++++- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 63cc96f18..cb5fdb91b 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -30,6 +30,7 @@ define(function() { '#FF00C0', // hot pink '#800080', // purple ]; + config.enableTemplates = true; return config; }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 2f5755ce3..e7dbc02dc 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -572,12 +572,15 @@ define([ }); }; var selectTemplate = common.selectTemplate = function (type, rt, Crypt) { + if (!AppConfig.enableTemplates) { return; } + var temps = listTemplates(type); + if (temps.length === 0) { return; } var $content = $('
'); $('').text(Messages.selectTemplate).appendTo($content); $('

', {id:"selectTemplate"}).appendTo($content); Cryptpad.alert($content.html(), null, true); var $p = $('#selectTemplate'); - listTemplates(type).forEach(function (t) { + temps.forEach(function (t, i) { $('', {href: t.href, title: t.title}).text(t.title).click(function (e) { e.preventDefault(); var parsed = parsePadUrl(t.href); @@ -592,6 +595,7 @@ define([ }); }); }).appendTo($p); + if (i !== temps.length) { $('
').appendTo($p); } }); common.findOKButton().text(Messages.cancelButton); }; @@ -1101,6 +1105,7 @@ define([ } break; case 'template': + if (!AppConfig.enableTemplates) { return; } button = $('