Copy print options to present mode
This commit is contained in:
@@ -137,6 +137,8 @@ define([
|
||||
var $modal = $pad.contents().find('#modal');
|
||||
var $content = $pad.contents().find('#content');
|
||||
var $print = $pad.contents().find('#print');
|
||||
var slideOptions = {};
|
||||
|
||||
$( window ).resize(function() {
|
||||
// 20vh
|
||||
// 20 * 16 / 9vw
|
||||
@@ -149,7 +151,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 +166,7 @@ define([
|
||||
}
|
||||
};
|
||||
var leavePresentationMode = function () {
|
||||
setStyleState(false);
|
||||
Slide.show(false);
|
||||
};
|
||||
|
||||
@@ -229,7 +238,8 @@ define([
|
||||
content: textValue,
|
||||
metadata: {
|
||||
users: userData,
|
||||
defaultTitle: defaultName
|
||||
defaultTitle: defaultName,
|
||||
slideOptions: slideOptions
|
||||
}
|
||||
};
|
||||
if (!initializing) {
|
||||
@@ -370,6 +380,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 +398,14 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
var updateOptions = function (newOpt) {
|
||||
if (stringify(newOpt) !== stringify(slideOptions)) {
|
||||
$.extend(slideOptions, newOpt);
|
||||
// TODO: manage realtime + cursor in the "options" modal ??
|
||||
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 = $('<div class="alertify">');
|
||||
var $container2 = $('<div class="dialog">').appendTo($container);
|
||||
var $div = $('<div id="printOptions">').appendTo($container2);
|
||||
@@ -440,21 +462,21 @@ define([
|
||||
$('<input>', {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');
|
||||
$('<label>', {'for': 'checkNumber'}).text(Messages.printSlideNumber).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Date
|
||||
$('<input>', {type: 'checkbox', id: 'checkDate', checked: 'checked'}).on('change', function () {
|
||||
var c = this.checked;
|
||||
printOptions.date = c;
|
||||
slideOptionsTmp.date = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'checkDate'}).text(Messages.printDate).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Title
|
||||
$('<input>', {type: 'checkbox', id: 'checkTitle', checked: 'checked'}).on('change', function () {
|
||||
var c = this.checked;
|
||||
printOptions.title = c;
|
||||
slideOptionsTmp.title = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'checkTitle'}).text(Messages.printTitle).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
@@ -462,34 +484,19 @@ define([
|
||||
$('<label>', {'for': 'cssPrint'}).text(Messages.printCSS).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
var $textarea = $('<textarea>', {'id':'cssPrint'}).css({'width':'100%', 'height':'100px'}).appendTo($p);
|
||||
$textarea.val(slideOptionsTmp.style);
|
||||
|
||||
|
||||
var fixCSS = function (css) {
|
||||
var append = '.cp #print ';
|
||||
return css.replace(/(\n*)([^\n]+)\s*\{/g, '$1' + append + '$2 {');
|
||||
};
|
||||
|
||||
var todo = function () {
|
||||
var $style = $('<style>').text(fixCSS($textarea.val()));
|
||||
$print.prepend($style);
|
||||
var length = $print.find('.slide-frame').length;
|
||||
$print.find('.slide-frame').each(function (i, el) {
|
||||
if (printOptions.slide) {
|
||||
$('<div>', {'class': 'slideNumber'}).text((i+1)+'/'+length).appendTo($(el));
|
||||
}
|
||||
if (printOptions.date) {
|
||||
$('<div>', {'class': 'slideDate'}).text(new Date().toLocaleDateString()).appendTo($(el));
|
||||
}
|
||||
if (printOptions.title) {
|
||||
$('<div>', {'class': 'slideTitle'}).text(APP.title).appendTo($(el));
|
||||
}
|
||||
});
|
||||
window.frames["pad-iframe"].focus();
|
||||
window.frames["pad-iframe"].print();
|
||||
$.extend(slideOptions, slideOptionsTmp);
|
||||
slideOptions.style = $textarea.val();
|
||||
onLocal();
|
||||
$container.remove();
|
||||
};
|
||||
|
||||
var $nav = $('<nav>').appendTo($div);
|
||||
var $ok = $('<button>', {'class': 'ok'}).text(Messages.printButton).appendTo($nav).click(todo);
|
||||
var $ok = $('<button>', {'class': 'ok'}).text(Messages.settings_save).appendTo($nav).click(todo);
|
||||
var $cancel = $('<button>', {'class': 'cancel'}).text(Messages.cancel).appendTo($nav).click(function () {
|
||||
$container.remove();
|
||||
});
|
||||
@@ -556,10 +563,24 @@ define([
|
||||
'class': 'rightside-button fa fa-print',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
Slide.update(editor.getValue(), true);
|
||||
$print.html($content.html());
|
||||
Cryptpad.confirm("Are you sure you want to print?", function (yes) {
|
||||
if (yes) {
|
||||
window.frames["pad-iframe"].focus();
|
||||
window.frames["pad-iframe"].print();
|
||||
}
|
||||
}, {ok: Messages.printButton});
|
||||
//$('body').append(createPrintDialog());
|
||||
});
|
||||
$rightside.append($printButton);
|
||||
|
||||
var $slideOptions = $('<button>', {
|
||||
title: Messages.slideOptionsTitle,
|
||||
'class': 'rightside-button fa fa-cog',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
$rightside.append($printButton);
|
||||
$('body').append(createPrintDialog());
|
||||
});
|
||||
$rightside.append($slideOptions);
|
||||
|
||||
@@ -726,8 +747,6 @@ define([
|
||||
|
||||
// Update the user list (metadata) from the hyperjson
|
||||
updateMetadata(userDoc);
|
||||
Slide.update(newDoc, true);
|
||||
Slide.draw();
|
||||
|
||||
editor.setValue(newDoc || initialState);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user