From d63c912af0442f433213cf9f92c7b5e62633be3c Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 10 Oct 2016 17:01:04 +0200 Subject: [PATCH] Use the HTML5 color picker to change the colors in slides --- customize.dist/translations/messages.fr.js | 5 + customize.dist/translations/messages.js | 5 + www/slide/main.js | 109 ++++++++++++++------- www/slide/slide.js | 63 ++++++++---- 4 files changed, 128 insertions(+), 54 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 8ef04bea5..df9deb63c 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -70,6 +70,11 @@ define(function () { out.sourceButton = 'VOIR LA SOURCE'; out.sourceButtonTitle = "Quitter le mode présentation"; + out.backgroundButton = 'COULEUR DE FOND'; + out.backgroundButtonTitle = 'Changer la couleur de fond de la présentation'; + out.colorButton = 'COULEUR DU TEXTE'; + out.colorButtonTitle = 'Changer la couleur du texte en mode présentation'; + out.commitButton = 'VALIDER'; out.getViewButton = 'LECTURE SEULE'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 09c044481..d46fb6e5a 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -71,6 +71,11 @@ define(function () { out.sourceButton = 'VIEW SOURCE'; out.sourceButtonTitle = "Leave presentation mode"; + out.backgroundButton = 'BACKGROUND COLOR'; + out.backgroundButtonTitle = 'Change the background color in the presentation'; + out.colorButton = 'TEXT COLOR'; + out.colorButtonTitle = 'Change the text color in presentation mode'; + out.commitButton = 'COMMIT'; out.getViewButton = 'READ-ONLY URL'; diff --git a/www/slide/main.js b/www/slide/main.js index 9ec4f060b..f31afc6d5 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -15,7 +15,6 @@ define([ '/slide/slide.js', '/bower_components/file-saver/FileSaver.min.js', '/bower_components/jquery/dist/jquery.min.js', - '/common/jscolor.js', '/customize/pad.js' ], function (Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Modes, Themes, Visible, Notify, Slide) { var $ = window.jQuery; @@ -29,6 +28,8 @@ define([ }; var APP = window.APP; + var SLIDE_BACKCOLOR_ID = "cryptpad-backcolor"; + var SLIDE_COLOR_ID = "cryptpad-color"; Cryptpad.styleAlerts(); module.spinner.show(); @@ -157,6 +158,9 @@ define([ } }; + var textColor; + var backColor; + var myData = {}; var myUserName = ''; // My "pretty name" var myID; // My server ID @@ -188,23 +192,34 @@ define([ var initializing = true; + var stringifyInner = function (textValue) { + var obj = { + content: textValue, + metadata: { + users: userList + } + }; + if (!isDefaultTitle()) { + obj.metadata.title = APP.title; + } + if (textColor) { + obj.metadata.color = textColor; + } + if (backColor) { + obj.metadata.backColor = backColor; + } + // stringify the json and send it into chainpad + return stringify(obj); + }; + var onLocal = config.onLocal = function () { if (initializing) { return; } if (readOnly) { return; } editor.save(); - var textValue = canonicalize($textarea.val()); - var obj = {content: textValue}; - // append the userlist to the hyperjson structure - obj.metadata = { - users: userList - }; - if (!isDefaultTitle()) { - obj.metadata.title = APP.title; - } - // stringify the json and send it into chainpad - var shjson = stringify(obj); + var textValue = canonicalize($textarea.val()); + var shjson = stringifyInner(textValue); module.patchText(shjson); Slide.update(textValue); @@ -431,21 +446,36 @@ define([ }; var configureColors = function () { - /*var $background = $('', { - id: "cryptpad-bg-color", - value: "#5367ce" - }).colorpicker();*/ - console.log(jscolor); - var $background = $('', { - value: 'BACKGROUND', - style: "position:absolute; top:100px; left: 50px; z-index:1000" + $back = $('