From 45ac3e40a2181efaf06e7d1e6aea577fda5ec8bc Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 17 Mar 2017 17:49:03 +0100 Subject: [PATCH] Copy print options to present mode --- customize.dist/translations/messages.fr.js | 4 +- customize.dist/translations/messages.js | 4 +- q | 478 +++++++++++++++++++++ www/slide/main.js | 81 ++-- www/slide/slide.css | 52 ++- www/slide/slide.js | 32 +- www/slide/slide.less | 46 +- 7 files changed, 622 insertions(+), 75 deletions(-) create mode 100644 q diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 96e36a4b1..4ad51bdf7 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -79,12 +79,14 @@ define(function () { out.printButton = "Imprimer"; out.printButtonTitle = "Imprimer votre présentation ou l'enregistrer au format PDF"; - out.printOptions = "Options d'impression"; + out.printOptions = "Options de mise en page"; out.printSlideNumber = "Afficher le numéro des slides"; out.printDate = "Afficher la date"; out.printTitle = "Afficher le titre du pad"; out.printCSS = "Personnaliser l'apparence (CSS):"; + out.slideOptionsTitle = "Personnaliser la présentation"; + out.editShare = "Lien d'édition"; out.editShareTitle = "Copier le lien d'édition dans le presse-papiers"; out.editOpen = "Éditer dans un nouvel onglet"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index b463b4853..15540fd1a 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -81,12 +81,14 @@ define(function () { out.printButton = "Print"; out.printButtonTitle = "Print your slides or export them as a PDF file"; - out.printOptions = "Print options"; + out.printOptions = "Layout options"; out.printSlideNumber = "Display the slide number"; out.printDate = "Display the date"; out.printTitle = "Display the pad title"; out.printCSS = "Custom style rules (CSS):"; + out.slideOptionsTitle = "Customize your slides"; + out.editShare = "Editing link"; out.editShareTitle = "Copy the editing link to clipboard"; out.editOpen = "Open editing link in a new tab"; diff --git a/q b/q new file mode 100644 index 000000000..cbba0eb66 --- /dev/null +++ b/q @@ -0,0 +1,478 @@ +warning: LF will be replaced by CRLF in customize.dist/translations/messages.fr.js. +The file will have its original line endings in your working directory. +diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js +index 96e36a4..4ad51bd 100644 +--- a/customize.dist/translations/messages.fr.js ++++ b/customize.dist/translations/messages.fr.js +@@ -79,12 +79,14 @@ define(function () { +  + out.printButton = "Imprimer"; + out.printButtonTitle = "Imprimer votre présentation ou l'enregistrer au format PDF"; +- out.printOptions = "Options d'impression"; ++ out.printOptions = "Options de mise en page"; + out.printSlideNumber = "Afficher le numéro des slides"; + out.printDate = "Afficher la date"; + out.printTitle = "Afficher le titre du pad"; + out.printCSS = "Personnaliser l'apparence (CSS):"; +  ++ out.slideOptionsTitle = "Personnaliser la présentation"; ++ + out.editShare = "Lien d'édition"; + out.editShareTitle = "Copier le lien d'édition dans le presse-papiers"; + out.editOpen = "Éditer dans un nouvel onglet"; +diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js +index b463b48..15540fd 100644 +--- a/customize.dist/translations/messages.js ++++ b/customize.dist/translations/messages.js +@@ -81,12 +81,14 @@ define(function () { +  + out.printButton = "Print"; + out.printButtonTitle = "Print your slides or export them as a PDF file"; +- out.printOptions = "Print options"; ++ out.printOptions = "Layout options"; + out.printSlideNumber = "Display the slide number"; + out.printDate = "Display the date"; + out.printTitle = "Display the pad title"; + out.printCSS = "Custom style rules (CSS):"; +  ++ out.slideOptionsTitle = "Customize your slides"; ++ + out.editShare = "Editing link"; + out.editShareTitle = "Copy the editing link to clipboard"; + out.editOpen = "Open editing link in a new tab"; +diff --git a/www/slide/main.js b/www/slide/main.js +index 50f216e..0bc6f5f 100644 +--- a/www/slide/main.js ++++ b/www/slide/main.js +@@ -136,7 +136,8 @@ define([ +  + var $modal = $pad.contents().find('#modal'); + var $content = $pad.contents().find('#content'); +- var $print = $pad.contents().find('#print'); ++ var $print = $pad.contents().find('#print'); var slideOptions = {}; ++ + $( window ).resize(function() { + // 20vh + // 20 * 16 / 9vw +@@ -149,7 +150,13 @@ define([ + // $print.css('font-size', (20*9/16)+'vw'); + }); +  +- Slide.setModal($modal, $content, $pad, ifrw, initialState); ++ Slide.setModal(APP, $modal, $content, $pad, ifrw, slideOptions, initialState); ++ ++ var setStyleState = function (state) { ++ $pad.contents().find('#print, #content').find('style').each(function (i, el) { ++ el.disabled = !state; ++ }); ++ }; +  + var enterPresentationMode = function (shouldLog) { + Slide.show(true, editor.getValue()); +@@ -158,6 +165,7 @@ define([ + } + }; + var leavePresentationMode = function () { ++ setStyleState(false); + Slide.show(false); + }; +  +@@ -229,7 +237,8 @@ define([ + content: textValue, + metadata: { + users: userData, +- defaultTitle: defaultName ++ defaultTitle: defaultName, ++ slideOptions: slideOptions + } + }; + if (!initializing) { +@@ -370,6 +379,7 @@ define([ + setTabTitle(); + $bar.find('.' + Toolbar.constants.title).find('span.title').text(data); + $bar.find('.' + Toolbar.constants.title).find('input').val(data); ++ if (slideOptions.title) { Slide.updateOptions(); } + }); + }; +  +@@ -387,6 +397,15 @@ define([ + } + }; +  ++ var updateOptions = function (newOpt) { ++ if (stringify(newOpt) !== stringify(slideOptions)) { ++ $.extend(slideOptions, newOpt); ++ // TODO: manage realtime + cursor in the "options" modal ?? ++ console.log('updating options'); ++ Slide.updateOptions(); ++ } ++ }; ++ + var updateDefaultTitle = function (defaultTitle) { + defaultName = defaultTitle; + $bar.find('.' + Toolbar.constants.title).find('input').attr("placeholder", defaultName); +@@ -409,6 +428,7 @@ define([ + updateTitle(json.metadata.title || defaultName); + titleUpdated = true; + } ++ updateOptions(json.metadata.slideOptions); + updateColors(json.metadata.color, json.metadata.backColor); + } + if (!titleUpdated) { +@@ -424,12 +444,14 @@ define([ + }; +  + var createPrintDialog = function () { +- var printOptions = { ++ var slideOptionsTmp = { + title: true, + slide: true, +- date: true ++ date: true, ++ style: '' + }; +  ++ $.extend(slideOptionsTmp, slideOptions);  + var $container = $('
'); + var $container2 = $('
').appendTo($container); + var $div = $('
').appendTo($container2); +@@ -440,21 +462,21 @@ define([ + $('', {type: 'checkbox', id: 'checkNumber', checked: 'checked'}).on('change', function () { + var c = this.checked; + console.log(c); +- printOptions.slide = c; ++ slideOptionsTmp.slide = c; + }).appendTo($p).css('width', 'auto'); + $('