Move slide to secure iframe
This commit is contained in:
@@ -1,31 +1,29 @@
|
||||
@import "/customize/src/less/variables.less";
|
||||
@import "/customize/src/less/mixins.less";
|
||||
@import "/common/markdown.less";
|
||||
@import (once) "../../customize/src/less2/include/browser.less";
|
||||
@import (once) "../../customize/src/less2/include/toolbar.less";
|
||||
@import (once) "../../customize/src/less2/include/markdown.less";
|
||||
@import (once) '../../customize/src/less2/include/fileupload.less';
|
||||
@import (once) '../../customize/src/less2/include/alertify.less';
|
||||
@import (once) "../../customize/src/less2/include/mediatag.less";
|
||||
|
||||
// used for slides
|
||||
.viewportRatio (@x, @y, @p: 100) {
|
||||
width: @p * 100vw;
|
||||
height: @y * (@p * 100vw) / @x;
|
||||
max-width: @x / @y * (@p * 100vh);
|
||||
max-height: (@p * 100vh);
|
||||
.mediatag_base();
|
||||
.toolbar_main();
|
||||
.fileupload_main();
|
||||
.alertify_main();
|
||||
|
||||
// body
|
||||
font-size: unset;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
|
||||
@slide-default-bg: #000;
|
||||
.size (@n) {
|
||||
// font-size: @n * 1vmin;
|
||||
// line-height: @n * 1.1vmin;
|
||||
font-size: @n * 10%;
|
||||
// line-height: @n * 11%;
|
||||
line-height: 110%;
|
||||
}
|
||||
|
||||
html, body{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
body {
|
||||
font-size: unset;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
|
||||
//.cp {
|
||||
h1 { font-size: 40px; }
|
||||
h2 { font-size: 37px; }
|
||||
h3 { font-size: 34px; }
|
||||
@@ -33,72 +31,25 @@ h4 { font-size: 31px; }
|
||||
h5 { font-size: 27px; }
|
||||
h6 { font-size: 24px; }
|
||||
|
||||
body {
|
||||
.CodeMirror {
|
||||
height: 100%;
|
||||
font-size: initial;
|
||||
}
|
||||
.CodeMirror-focused .cm-matchhighlight {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
|
||||
background-position: bottom;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
.CodeMirror {
|
||||
height: 100%;
|
||||
font-size: initial;
|
||||
}
|
||||
#colorPicker_check {
|
||||
.CodeMirror-focused .cm-matchhighlight {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
|
||||
background-position: bottom;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
#cp-app-slide-colorpicker {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
margin: 0;
|
||||
size: landscape;
|
||||
}
|
||||
body {
|
||||
.CodeMirror, #cme_toolbox {
|
||||
display: none;
|
||||
}
|
||||
* {
|
||||
visibility: hidden;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
}
|
||||
display:block;
|
||||
}
|
||||
html, body {
|
||||
height: auto;
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
html {
|
||||
.cp #print {
|
||||
display: block;
|
||||
visibility: visible;
|
||||
* {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
.cp #modal {
|
||||
display: none !important;
|
||||
}
|
||||
.cp {
|
||||
flex: 1 !important;
|
||||
overflow: visible !important;
|
||||
}
|
||||
.userlist-drawer {
|
||||
display: none !important;
|
||||
}
|
||||
#editorContainer {
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#cme_toolbox {
|
||||
z-index: 10000;
|
||||
}
|
||||
#editorContainer {
|
||||
|
||||
#cp-app-slide-editor {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
@@ -108,29 +59,29 @@ body {
|
||||
resize: none;
|
||||
width: 100vw;
|
||||
}
|
||||
&.preview {
|
||||
&.cp-app-slide-preview {
|
||||
.CodeMirror {
|
||||
//resize: horizontal;
|
||||
width: 50vw;
|
||||
}
|
||||
}
|
||||
}
|
||||
.preview {
|
||||
.cp {
|
||||
.cp-app-slide-preview {
|
||||
.cp-app-slide-viewer {
|
||||
width: 50vw;
|
||||
overflow: hidden;
|
||||
div#modal:not(.shown) {
|
||||
div#cp-app-slide-modal:not(.cp-app-slide-shown) {
|
||||
position: relative;
|
||||
top: auto;
|
||||
left: auto;
|
||||
width: auto;
|
||||
display: block;
|
||||
height: 100%;
|
||||
#content {
|
||||
.slide-container {
|
||||
#cp-app-slide-modal-content {
|
||||
.cp-app-slide-container {
|
||||
width: 100%;
|
||||
}
|
||||
.slide-frame {
|
||||
.cp-app-slide-frame {
|
||||
width: 50vw;
|
||||
height: 28.125vw; // height:width ratio = 9/16 = .5625
|
||||
max-height: ~"calc(100vh - 96px)";
|
||||
@@ -139,7 +90,7 @@ body {
|
||||
//max-width: 177.78vh; // 16/9 = 1.778
|
||||
}
|
||||
}
|
||||
#button_exit {
|
||||
#cp-app-slide-modal-exit {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
@@ -148,16 +99,16 @@ body {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
.cp {
|
||||
|
||||
/* Slide position (print mode) */
|
||||
@ratio:0.9;
|
||||
#print {
|
||||
#cp-app-slide-print {
|
||||
position: relative;
|
||||
display: none;
|
||||
font-size: @ratio*11.25vw;
|
||||
.slide-frame {
|
||||
display: block !important;
|
||||
.cp-app-slide-frame {
|
||||
display: flex !important;
|
||||
flex-flow: column;
|
||||
padding: 0.5em;
|
||||
margin: auto;
|
||||
border: 1px solid black;
|
||||
@@ -173,11 +124,9 @@ body {
|
||||
h1 {
|
||||
padding-top: 0;
|
||||
}
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
}
|
||||
.slide-container {
|
||||
.cp-app-slide-container {
|
||||
width: 90vw;
|
||||
height: 100vh;
|
||||
margin: 0vh 5vw !important;
|
||||
@@ -189,13 +138,13 @@ body {
|
||||
}
|
||||
|
||||
/* Slide position (present mode) */
|
||||
div.modal, div#modal {
|
||||
div#cp-app-slide-modal {
|
||||
display: none;
|
||||
background-color: black;
|
||||
color: white;
|
||||
|
||||
/* Navigation buttons */
|
||||
.button {
|
||||
.cp-app-slide-modal-button {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
font-size: 30px;
|
||||
@@ -203,23 +152,23 @@ div.modal, div#modal {
|
||||
display: none;
|
||||
z-index: 9001;
|
||||
}
|
||||
.button:hover {
|
||||
.cp-app-slie-modal-button:hover {
|
||||
opacity: 1;
|
||||
display: block !important;
|
||||
}
|
||||
#button_exit {
|
||||
#cp-app-slide-modal-exit {
|
||||
left: 20px;
|
||||
top: 20px;
|
||||
}
|
||||
#button_left {
|
||||
#cp-app-slide-modal-left {
|
||||
left: 6vw;
|
||||
bottom: 10vh;
|
||||
}
|
||||
#button_right {
|
||||
#cp-app-slide-modal-right {
|
||||
right: 6vw;
|
||||
bottom: 10vh;
|
||||
}
|
||||
&.shown {
|
||||
&.cp-app-slide-shown {
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
@@ -228,13 +177,13 @@ div.modal, div#modal {
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
#content {
|
||||
#cp-app-slide-modal-content {
|
||||
font-size: 20vh;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
.slide-frame {
|
||||
.cp-app-slide-frame {
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-flow: column !important;
|
||||
@@ -252,14 +201,14 @@ div.modal, div#modal {
|
||||
max-width: 177.78vh; // 16/9 = 1.778
|
||||
margin: auto;
|
||||
}
|
||||
.slide-container {
|
||||
.cp-app-slide-container {
|
||||
display: inline-flex;
|
||||
height: 100%; width: 100vw;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
}
|
||||
&.transition {
|
||||
.slide-container {
|
||||
&.cp-app-slide-transition {
|
||||
.cp-app-slide-container {
|
||||
transition: margin-left 1s;
|
||||
}
|
||||
}
|
||||
@@ -280,26 +229,11 @@ div.modal, div#modal {
|
||||
display: none;
|
||||
|
||||
background-color: @slide-default-bg;
|
||||
|
||||
.center {
|
||||
position: relative;
|
||||
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
border: 1px solid @light-base;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.shown {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
/* Slide content */
|
||||
div#modal #content, #print {
|
||||
.slide-frame {
|
||||
div#cp-app-slide-modal #cp-app-slide-modal-content, #cp-app-slide-print {
|
||||
.cp-app-slide-frame {
|
||||
* {
|
||||
.size(2.75);
|
||||
* {
|
||||
@@ -351,19 +285,19 @@ div#modal #content, #print {
|
||||
min-width: 1%;
|
||||
margin: auto;
|
||||
}
|
||||
.slideNumber {
|
||||
.cp-app-slide-number {
|
||||
position: absolute;
|
||||
right: 5vh;
|
||||
bottom: 5vh;
|
||||
.size(1);
|
||||
}
|
||||
.slideDate {
|
||||
.cp-app-slide-date {
|
||||
position: absolute;
|
||||
left: 5vh;
|
||||
bottom: 5vh;
|
||||
.size(1);
|
||||
}
|
||||
.slideTitle {
|
||||
.cp-app-slide-title {
|
||||
position: absolute;
|
||||
bottom: 5vh;
|
||||
left: 0px; right: 0px;
|
||||
@@ -374,25 +308,16 @@ div#modal #content, #print {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@import "/common/file-dialog.less";
|
||||
|
||||
.slide-frame * {
|
||||
.cp-app-slide-frame * {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
p {
|
||||
//display: flex;
|
||||
//flex-flow: row wrap;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
min-height:0;
|
||||
min-width:0;
|
||||
//flex: 1;
|
||||
}
|
||||
|
||||
@import "../customize/src/less2/include/mediatag.less";
|
||||
|
||||
.mediatag_base();
|
||||
@@ -1,40 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="cp slide">
|
||||
<html>
|
||||
<head>
|
||||
<title>CryptPad</title>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer" />
|
||||
<script async data-bootload="/customize/template.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<script async data-bootload="main.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<style>
|
||||
html, body {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
#iframe-container {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
left: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#pad-iframe {
|
||||
#sbox-iframe {
|
||||
position:fixed;
|
||||
top:0px;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
border:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
overflow:hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body #pad-iframe.fullscreen {
|
||||
top: 0px;
|
||||
#sbox-filePicker-iframe {
|
||||
position: fixed;
|
||||
top:0; left:0;
|
||||
bottom:0; right:0;
|
||||
width:100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="iframe-container">
|
||||
<iframe id="pad-iframe", name="pad-iframe"></iframe><script src="/common/noscriptfix.js"></script>
|
||||
</div>
|
||||
|
||||
<iframe id="sbox-iframe">
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html class="cp-app-noscroll cp-app-print">
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
|
||||
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<script async data-bootload="inner.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<style>.loading-hidden { display: none; } </style>
|
||||
<script async data-bootload="/slide/inner.js" data-main="/common/sframe-boot.js?ver=1.1" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
|
||||
<style>
|
||||
.loading-hidden { display: none; }
|
||||
#editor1 { display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="loading-hidden">
|
||||
<div id="bar"></div>
|
||||
<!-- <textarea></textarea>-->
|
||||
<div id="cme_toolbox" class="toolbar-container"></div>
|
||||
|
||||
<div id="editorContainer">
|
||||
<body class="cp-app-slide">
|
||||
<div id="cme_toolbox" class="cp-toolbar-container"></div>
|
||||
<div id="cp-app-slide-editor">
|
||||
<textarea id="editor1" name="editor1"></textarea>
|
||||
<div class="cp slide" tabindex="2">
|
||||
<div id="modal">
|
||||
<div id="button_exit" class="button"><span class="fa fa-times"></span></div>
|
||||
<div id="button_left" class="button"><span class="fa fa-chevron-left"></span></div>
|
||||
<div id="button_right" class="button"><span class="fa fa-chevron-right"></span></div>
|
||||
<div id="content"></div>
|
||||
<div class="cp-app-slide-viewer" tabindex="2">
|
||||
<div id="cp-app-slide-modal">
|
||||
<div id="cp-app-slide-modal-exit" class="cp-app-slide-modal-button">
|
||||
<span class="fa fa-times"></span>
|
||||
</div>
|
||||
<div id="cp-app-slide-modal-left" class="cp-app-slide-modal-button">
|
||||
<span class="fa fa-chevron-left"></span>
|
||||
</div>
|
||||
<div id="cp-app-slide-modal-right" class="cp-app-slide-modal-button">
|
||||
<span class="fa fa-chevron-right"></span>
|
||||
</div>
|
||||
<div id="cp-app-slide-modal-content"></div>
|
||||
</div>
|
||||
<div id="print"></div>
|
||||
<div id="cp-app-slide-print"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="nope"></div>
|
||||
<div id="colorPicker_check"></div>
|
||||
<div id="cp-app-slide-colorpicker"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/bower_components/textpatcher/TextPatcher.js',
|
||||
'/common/toolbar3.js',
|
||||
'json.sortify',
|
||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||
'/common/cryptpad-common.js',
|
||||
'/common/cryptget.js',
|
||||
'/common/diffMarked.js',
|
||||
'/bower_components/nthen/index.js',
|
||||
'/common/sframe-common.js',
|
||||
'/api/config',
|
||||
'/common/common-realtime.js',
|
||||
'/slide/slide.js',
|
||||
|
||||
'cm/lib/codemirror',
|
||||
|
||||
|
||||
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
||||
'less!/customize/src/less/toolbar.less',
|
||||
'less!/customize/src/less/cryptpad.less',
|
||||
'less!/slide/slide.less',
|
||||
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||
'less!/customize/src/less2/main.less',
|
||||
|
||||
'css!cm/lib/codemirror.css',
|
||||
'css!cm/addon/dialog/dialog.css',
|
||||
@@ -35,7 +46,701 @@ define([
|
||||
'cm/addon/fold/comment-fold',
|
||||
'cm/addon/display/placeholder',
|
||||
|
||||
], function ($, CMeditor) {
|
||||
], function (
|
||||
$,
|
||||
Crypto,
|
||||
TextPatcher,
|
||||
Toolbar,
|
||||
JSONSortify,
|
||||
JsonOT,
|
||||
Cryptpad,
|
||||
Cryptget,
|
||||
DiffMd,
|
||||
nThen,
|
||||
SFCommon,
|
||||
ApiConfig,
|
||||
CommonRealtime,
|
||||
Slide,
|
||||
CMeditor)
|
||||
{
|
||||
window.CodeMirror = CMeditor;
|
||||
$('.loading-hidden').removeClass('loading-hidden');
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
var APP = window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
};
|
||||
var SLIDE_BACKCOLOR_ID = "cp-app-slide-toolbar-backcolor";
|
||||
var SLIDE_COLOR_ID = "cp-app-slide-toolbar-color";
|
||||
|
||||
var stringify = function (obj) {
|
||||
return JSONSortify(obj);
|
||||
};
|
||||
|
||||
var toolbar;
|
||||
var isPresentMode;
|
||||
|
||||
var onConnectError = function () {
|
||||
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
||||
};
|
||||
|
||||
var andThen = function (editor, CodeMirror, common) {
|
||||
var readOnly = false;
|
||||
var cpNfInner;
|
||||
var metadataMgr;
|
||||
var $bar = $('#cme_toolbox');
|
||||
|
||||
var isHistoryMode = false;
|
||||
|
||||
var setEditable = APP.setEditable = function (bool) {
|
||||
if (readOnly && bool) { return; }
|
||||
editor.setOption('readOnly', !bool);
|
||||
};
|
||||
|
||||
var Title;
|
||||
|
||||
var config = {
|
||||
readOnly: readOnly,
|
||||
transformFunction: JsonOT.validate,
|
||||
// cryptpad debug logging (default is 1)
|
||||
// logLevel: 0,
|
||||
validateContent: function (content) {
|
||||
try {
|
||||
JSON.parse(content);
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log("Failed to parse, rejecting patch");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
||||
|
||||
var setHistory = function (bool, update) {
|
||||
isHistoryMode = bool;
|
||||
setEditable(!bool);
|
||||
if (!bool && update) {
|
||||
config.onRemote();
|
||||
}
|
||||
};
|
||||
|
||||
var setTabTitle = function (title) {
|
||||
console.error('TODO'); // TODO iframe
|
||||
return;
|
||||
var slideNumber = '';
|
||||
if (Slide.shown) { //Slide.index && Slide.content.length) {
|
||||
slideNumber = ' (' + Slide.index + '/' + Slide.content.length + ')';
|
||||
}
|
||||
document.title = title + slideNumber;
|
||||
};
|
||||
|
||||
var $contentContainer = $('#cp-app-slide-editor');
|
||||
var $modal = $('#cp-app-slide-modal');
|
||||
var $content = $('#cp-app-slide-modal-content');
|
||||
var $print = $('#cp-app-slide-print');
|
||||
var slideOptions = {};
|
||||
var initialState = Messages.slideInitialState;
|
||||
var textColor;
|
||||
var backColor;
|
||||
|
||||
$content.click(function (e) {
|
||||
if (!e.target) { return; }
|
||||
var $t = $(e.target);
|
||||
if ($t.is('a') || $t.parents('a').length) {
|
||||
e.preventDefault();
|
||||
var $a = $t.is('a') ? $t : $t.parents('a').first();
|
||||
var href = $a.attr('href');
|
||||
window.open(href);
|
||||
}
|
||||
});
|
||||
|
||||
Slide.setModal(common, $modal, $content, slideOptions, initialState);
|
||||
|
||||
var enterPresentationMode = function (shouldLog) {
|
||||
Slide.show(true, editor.getValue());
|
||||
if (shouldLog) {
|
||||
Cryptpad.log(Messages.presentSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
if (isPresentMode) {
|
||||
enterPresentationMode(true);
|
||||
}
|
||||
|
||||
CommonRealtime.onInfiniteSpinner(function () { setEditable(false); });
|
||||
|
||||
setEditable(false);
|
||||
var initializing = true;
|
||||
|
||||
var stringifyInner = function (textValue) {
|
||||
var obj = {
|
||||
content: textValue,
|
||||
metadata: metadataMgr.getMetadataLazy()
|
||||
};
|
||||
|
||||
// stringify the json and send it into chainpad
|
||||
return stringify(obj);
|
||||
};
|
||||
|
||||
var onLocal = config.onLocal = function () {
|
||||
if (initializing) { return; }
|
||||
if (isHistoryMode) { return; }
|
||||
if (readOnly) { return; }
|
||||
|
||||
editor.save();
|
||||
|
||||
var textValue = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson = stringifyInner(textValue);
|
||||
|
||||
APP.patchText(shjson);
|
||||
Slide.update(textValue);
|
||||
|
||||
if (APP.realtime.getUserDoc() !== shjson) {
|
||||
console.error("realtime.getUserDoc() !== shjson");
|
||||
}
|
||||
};
|
||||
|
||||
var updateSlideOptions = function (newOpt) {
|
||||
if (stringify(newOpt) !== stringify(slideOptions)) {
|
||||
$.extend(slideOptions, newOpt);
|
||||
// TODO: manage realtime + cursor in the "options" modal ??
|
||||
Slide.updateOptions();
|
||||
}
|
||||
};
|
||||
var updateLocalOptions = function (newOpt) {
|
||||
updateSlideOptions(newOpt);
|
||||
var metadata = JSON.parse(JSON.stringify(metadataMgr.getMetadata()));
|
||||
metadata.slideOptions = slideOptions;
|
||||
metadataMgr.updateMetadata(metadata);
|
||||
onLocal();
|
||||
};
|
||||
var updateColors = function (text, back) {
|
||||
if (text) {
|
||||
textColor = text;
|
||||
$modal.css('color', text);
|
||||
$modal.css('border-color', text);
|
||||
$('#' + SLIDE_COLOR_ID).css('color', text);
|
||||
}
|
||||
if (back) {
|
||||
backColor = back;
|
||||
$modal.css('background-color', back);
|
||||
$('#' + SLIDE_BACKCOLOR_ID).css('color', back);
|
||||
}
|
||||
};
|
||||
var updateLocalColors = function (text, back) {
|
||||
updateColors(text, back);
|
||||
var metadata = JSON.parse(JSON.stringify(metadataMgr.getMetadata()));
|
||||
if (backColor) { metadata.backColor = backColor; }
|
||||
if (textColor) { metadata.color = textColor; }
|
||||
metadataMgr.updateMetadata(metadata);
|
||||
onLocal();
|
||||
console.log(metadataMgr.getMetadata());
|
||||
};
|
||||
|
||||
var createPrintDialog = function () {
|
||||
var slideOptionsTmp = {
|
||||
title: false,
|
||||
slide: false,
|
||||
date: false,
|
||||
transition: true,
|
||||
style: ''
|
||||
};
|
||||
|
||||
$.extend(slideOptionsTmp, slideOptions);
|
||||
var $container = $('<div class="alertify">');
|
||||
var $container2 = $('<div class="dialog">').appendTo($container);
|
||||
var $div = $('<div id="printOptions">').appendTo($container2);
|
||||
var $p = $('<p>', {'class': 'msg'}).appendTo($div);
|
||||
$('<b>').text(Messages.printOptions).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Slide number
|
||||
$('<input>', {
|
||||
type: 'checkbox',
|
||||
id: 'cp-app-slide-options-number',
|
||||
checked: slideOptionsTmp.slide
|
||||
}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.slide = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'cp-app-slide-options-number'}).text(Messages.printSlideNumber)
|
||||
.appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Date
|
||||
$('<input>', {
|
||||
type: 'checkbox',
|
||||
id: 'cp-app-slide-options-date',
|
||||
checked: slideOptionsTmp.date
|
||||
}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.date = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'cp-app-slide-options-date'}).text(Messages.printDate)
|
||||
.appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Title
|
||||
$('<input>', {
|
||||
type: 'checkbox',
|
||||
id: 'cp-app-slide-options-title',
|
||||
checked: slideOptionsTmp.title
|
||||
}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.title = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'cp-app-slide-options-title'}).text(Messages.printTitle)
|
||||
.appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Transition
|
||||
$('<input>', {
|
||||
type: 'checkbox',
|
||||
id: 'cp-app-slide-options-transition',
|
||||
checked: slideOptionsTmp.transition
|
||||
}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.transition = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'cp-app-slide-options-transition'}).text(Messages.printTransition)
|
||||
.appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// CSS
|
||||
$('<label>', {'for': 'cp-app-slide-options-css'}).text(Messages.printCSS).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
var $textarea = $('<textarea>', {'id':'cp-app-slide-options-css'})
|
||||
.css({'width':'100%', 'height':'100px'}).appendTo($p)
|
||||
.on('keydown keyup', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
$textarea.val(slideOptionsTmp.style);
|
||||
window.setTimeout(function () { $textarea.focus(); }, 0);
|
||||
|
||||
var h;
|
||||
|
||||
var todo = function () {
|
||||
slideOptionsTmp.style = $textarea.val();
|
||||
updateLocalOptions(slideOptionsTmp);
|
||||
$container.remove();
|
||||
Cryptpad.stopListening(h);
|
||||
};
|
||||
var todoCancel = function () {
|
||||
$container.remove();
|
||||
Cryptpad.stopListening(h);
|
||||
};
|
||||
|
||||
h = Cryptpad.listenForKeys(todo, todoCancel);
|
||||
|
||||
var $nav = $('<nav>').appendTo($div);
|
||||
$('<button>', {'class': 'cancel'}).text(Messages.cancelButton).appendTo($nav).click(todoCancel);
|
||||
$('<button>', {'class': 'ok'}).text(Messages.settings_save).appendTo($nav).click(todo);
|
||||
|
||||
return $container;
|
||||
};
|
||||
|
||||
config.onInit = function (info) {
|
||||
readOnly = metadataMgr.getPrivateData().readOnly;
|
||||
|
||||
var titleCfg = { getHeadingText: CodeMirror.getHeadingText };
|
||||
Title = common.createTitle(titleCfg, config.onLocal);
|
||||
Slide.setTitle(Title);
|
||||
|
||||
var configTb = {
|
||||
displayed: ['title', 'useradmin', 'spinner', 'share', 'userlist', 'newpad', 'limit'],
|
||||
title: Title.getTitleConfig(),
|
||||
metadataMgr: metadataMgr,
|
||||
readOnly: readOnly,
|
||||
ifrw: window,
|
||||
realtime: info.realtime,
|
||||
common: Cryptpad,
|
||||
sfCommon: common,
|
||||
$container: $bar,
|
||||
$contentContainer: $contentContainer
|
||||
};
|
||||
toolbar = APP.toolbar = Toolbar.create(configTb);
|
||||
Title.setToolbar(toolbar);
|
||||
CodeMirror.init(config.onLocal, Title, toolbar);
|
||||
|
||||
var $rightside = toolbar.$rightside;
|
||||
var $drawer = toolbar.$drawer;
|
||||
|
||||
/* add a history button */
|
||||
var histConfig = {
|
||||
onLocal: config.onLocal,
|
||||
onRemote: config.onRemote,
|
||||
setHistory: setHistory,
|
||||
applyVal: function (val) {
|
||||
var remoteDoc = JSON.parse(val || '{}').content;
|
||||
editor.setValue(remoteDoc || '');
|
||||
editor.save();
|
||||
},
|
||||
$toolbar: $bar
|
||||
};
|
||||
var $hist = common.createButton('history', true, {histConfig: histConfig});
|
||||
$drawer.append($hist);
|
||||
|
||||
/* save as template */
|
||||
if (!metadataMgr.getPrivateData().isTemplate) {
|
||||
var templateObj = {
|
||||
rt: info.realtime,
|
||||
getTitle: function () { return metadataMgr.getMetadata().title; }
|
||||
};
|
||||
var $templateButton = common.createButton('template', true, templateObj);
|
||||
$rightside.append($templateButton);
|
||||
}
|
||||
|
||||
/* add an export button */
|
||||
var $export = common.createButton('export', true, {}, CodeMirror.exportText);
|
||||
$drawer.append($export);
|
||||
|
||||
if (!readOnly) {
|
||||
/* add an import button */
|
||||
var $import = common.createButton('import', true, {}, CodeMirror.importText);
|
||||
$drawer.append($import);
|
||||
}
|
||||
|
||||
/* add a forget button */
|
||||
var forgetCb = function (err) {
|
||||
if (err) { return; }
|
||||
setEditable(false);
|
||||
};
|
||||
var $forgetPad = common.createButton('forget', true, {}, forgetCb);
|
||||
$rightside.append($forgetPad);
|
||||
|
||||
var $previewButton = APP.$previewButton = common.createButton(null, true);
|
||||
$previewButton.removeClass('fa-question').addClass('fa-eye');
|
||||
$previewButton.attr('title', Messages.previewButtonTitle);
|
||||
$previewButton.click(function () {
|
||||
var $c = $contentContainer;
|
||||
if ($c.hasClass('cp-app-slide-preview')) {
|
||||
common.setPadAttribute('previewMode', false, function (e) {
|
||||
if (e) { return console.log(e); }
|
||||
});
|
||||
$previewButton.removeClass('cp-toolbar-button-active');
|
||||
return void $c.removeClass('cp-app-slide-preview');
|
||||
}
|
||||
common.setPadAttribute('previewMode', true, function (e) {
|
||||
if (e) { return console.log(e); }
|
||||
});
|
||||
$c.addClass('cp-app-slide-preview');
|
||||
$previewButton.addClass('cp-toolbar-button-active');
|
||||
Slide.updateFontSize();
|
||||
});
|
||||
$rightside.append($previewButton);
|
||||
|
||||
var $printButton = $('<button>', {
|
||||
title: Messages.printButtonTitle,
|
||||
'class': 'cp-toolbar-rightside-button fa fa-print',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
Slide.update(editor.getValue(), true);
|
||||
$print.html($content.html());
|
||||
// TODO use translation key
|
||||
Cryptpad.confirm("Are you sure you want to print?", function (yes) {
|
||||
if (yes) {
|
||||
window.focus();
|
||||
window.print();
|
||||
}
|
||||
}, {ok: Messages.printButton});
|
||||
common.feedback('PRINT_SLIDES');
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.printText));
|
||||
$drawer.append($printButton);
|
||||
|
||||
var $slideOptions = $('<button>', {
|
||||
title: Messages.slideOptionsTitle,
|
||||
'class': 'cp-toolbar-rightside-button fa fa-cog',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
$('body').append(createPrintDialog());
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.slideOptionsText));
|
||||
$drawer.append($slideOptions);
|
||||
|
||||
var $present = common.createButton('present', true)
|
||||
.click(function () {
|
||||
enterPresentationMode(true);
|
||||
});
|
||||
$rightside.append($present);
|
||||
|
||||
var configureColors = function () {
|
||||
var $back = $('<button>', {
|
||||
id: SLIDE_BACKCOLOR_ID,
|
||||
'class': 'fa fa-square cp-toolbar-rightside-button',
|
||||
'style': 'font-family: FontAwesome; color: #000;',
|
||||
title: Messages.backgroundButtonTitle
|
||||
});
|
||||
var $text = $('<button>', {
|
||||
id: SLIDE_COLOR_ID,
|
||||
'class': 'fa fa-i-cursor cp-toolbar-rightside-button',
|
||||
'style': 'font-family: FontAwesome; font-weight: bold; color: #fff;',
|
||||
title: Messages.colorButtonTitle
|
||||
});
|
||||
var $testColor = $('<input>', { type: 'color', value: '!' });
|
||||
var $check = $("#cp-app-slide-colorpicker");
|
||||
if ($testColor.attr('type') !== "color" || $testColor.val() === '!') { return; }
|
||||
$back.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: backColor })
|
||||
.css({ display: 'none', })
|
||||
.on('change', function() {
|
||||
updateLocalColors(undefined, this.value);
|
||||
$check.html('');
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
$text.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: textColor })
|
||||
.css({ display: 'none', })
|
||||
.on('change', function() {
|
||||
updateLocalColors(this.value, undefined);
|
||||
$check.html('');
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
$rightside.append($back).append($text);
|
||||
};
|
||||
configureColors();
|
||||
|
||||
CodeMirror.configureTheme();
|
||||
|
||||
var fileDialogCfg = {
|
||||
onSelect: function (data) {
|
||||
if (data.type === 'file') {
|
||||
var mt = '<media-tag src="' + data.src + '" data-crypto-key="cryptpad:' + data.key + '"></media-tag>';
|
||||
editor.replaceSelection(mt);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
common.initFilePicker(fileDialogCfg);
|
||||
APP.$mediaTagButton = $('<button>', {
|
||||
title: Messages.filePickerButton,
|
||||
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
var pickerCfg = {
|
||||
types: ['file'],
|
||||
where: ['root']
|
||||
};
|
||||
common.openFilePicker(pickerCfg);
|
||||
}).appendTo($rightside);
|
||||
|
||||
metadataMgr.onChange(function () {
|
||||
var md = metadataMgr.getMetadata();
|
||||
if (md.color || md.backColor) {
|
||||
updateLocalColors(md.color, md.backColor);
|
||||
}
|
||||
if (md.slideOptions) {
|
||||
updateLocalOptions(md.slideOptions);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
config.onReady = function (info) {
|
||||
console.log('onready');
|
||||
if (APP.realtime !== info.realtime) {
|
||||
var realtime = APP.realtime = info.realtime;
|
||||
APP.patchText = TextPatcher.create({
|
||||
realtime: realtime,
|
||||
//logging: true
|
||||
});
|
||||
}
|
||||
|
||||
var userDoc = APP.realtime.getUserDoc();
|
||||
|
||||
var isNew = false;
|
||||
if (userDoc === "" || userDoc === "{}") { isNew = true; }
|
||||
|
||||
var newDoc = "";
|
||||
if (userDoc !== "") {
|
||||
var hjson = JSON.parse(userDoc);
|
||||
|
||||
if (hjson && hjson.metadata) {
|
||||
metadataMgr.updateMetadata(hjson.metadata);
|
||||
}
|
||||
if (typeof (hjson) !== 'object' || Array.isArray(hjson) ||
|
||||
(typeof(hjson.type) !== 'undefined' && hjson.type !== 'code')) {
|
||||
var errorText = Messages.typeError;
|
||||
Cryptpad.errorLoadingScreen(errorText);
|
||||
throw new Error(errorText);
|
||||
}
|
||||
|
||||
newDoc = hjson.content;
|
||||
|
||||
if (hjson.highlightMode) {
|
||||
CodeMirror.setMode(hjson.highlightMode);
|
||||
}
|
||||
} else {
|
||||
Title.updateTitle(Cryptpad.initialName || Title.defaultTitle);
|
||||
}
|
||||
|
||||
if (!CodeMirror.highlightMode) {
|
||||
CodeMirror.setMode('markdown');
|
||||
}
|
||||
|
||||
editor.setValue(newDoc || initialState);
|
||||
|
||||
if (Cryptpad.initialName && Title.isDefaultTitle()) {
|
||||
Title.updateTitle(Cryptpad.initialName);
|
||||
}
|
||||
|
||||
common.getPadAttribute('previewMode', function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
if (data !== false && APP.$previewButton) {
|
||||
APP.$previewButton.click();
|
||||
}
|
||||
});
|
||||
|
||||
Slide.onChange(function (o, n, l) {
|
||||
console.log('TODO: remove that part?');
|
||||
var slideNumber = '';
|
||||
if (n !== null) {
|
||||
if (Slide.shown) {
|
||||
slideNumber = ' (' + (++n) + '/' + l + ')';
|
||||
}
|
||||
}
|
||||
// TODO iframe
|
||||
document.title = Title.title + slideNumber;
|
||||
});
|
||||
|
||||
setEditable(!readOnly);
|
||||
initializing = false;
|
||||
|
||||
onLocal(); // push local state to avoid parse errors later.
|
||||
console.log(editor.getValue());
|
||||
Slide.update(editor.getValue());
|
||||
Cryptpad.removeLoadingScreen();
|
||||
|
||||
if (readOnly) {
|
||||
config.onRemote();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNew) {
|
||||
common.openTemplatePicker();
|
||||
}
|
||||
|
||||
var fmConfig = {
|
||||
dropArea: $('.CodeMirror'),
|
||||
body: $('body'),
|
||||
onUploaded: function (ev, data) {
|
||||
var parsed = Cryptpad.parsePadUrl(data.url);
|
||||
var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel);
|
||||
var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName;
|
||||
var mt = '<media-tag src="' + src + '" data-crypto-key="cryptpad:' + parsed.hashData.key + '"></media-tag>';
|
||||
editor.replaceSelection(mt);
|
||||
}
|
||||
};
|
||||
APP.FM = common.createFileManager(fmConfig);
|
||||
};
|
||||
|
||||
config.onRemote = function () {
|
||||
if (initializing) { return; }
|
||||
if (isHistoryMode) { return; }
|
||||
|
||||
var oldDoc = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson = APP.realtime.getUserDoc();
|
||||
|
||||
var hjson = JSON.parse(shjson);
|
||||
var remoteDoc = hjson.content;
|
||||
|
||||
if (hjson.metadata) {
|
||||
metadataMgr.updateMetadata(hjson.metadata);
|
||||
}
|
||||
|
||||
var highlightMode = hjson.highlightMode;
|
||||
if (highlightMode && highlightMode !== APP.highlightMode) {
|
||||
CodeMirror.setMode(highlightMode);
|
||||
}
|
||||
|
||||
CodeMirror.setValueAndCursor(oldDoc, remoteDoc, TextPatcher);
|
||||
|
||||
if (!readOnly) {
|
||||
var textValue = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson2 = stringifyInner(textValue);
|
||||
if (shjson2 !== shjson) {
|
||||
console.error("shjson2 !== shjson");
|
||||
TextPatcher.log(shjson, TextPatcher.diff(shjson, shjson2));
|
||||
APP.patchText(shjson2);
|
||||
}
|
||||
}
|
||||
Slide.update(remoteDoc);
|
||||
if (oldDoc !== remoteDoc) { Cryptpad.notify(); }
|
||||
};
|
||||
|
||||
config.onAbort = function () {
|
||||
// inform of network disconnect
|
||||
setEditable(false);
|
||||
toolbar.failed();
|
||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||
};
|
||||
|
||||
config.onConnectionChange = function (info) {
|
||||
setEditable(info.state);
|
||||
//toolbar.failed();
|
||||
if (info.state) {
|
||||
initializing = true;
|
||||
//toolbar.reconnecting(info.myId);
|
||||
Cryptpad.findOKButton().click();
|
||||
} else {
|
||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||
}
|
||||
};
|
||||
|
||||
config.onError = onConnectError;
|
||||
|
||||
cpNfInner = common.startRealtime(config);
|
||||
metadataMgr = cpNfInner.metadataMgr;
|
||||
|
||||
editor.on('change', onLocal);
|
||||
|
||||
Cryptpad.onLogout(function () { setEditable(false); });
|
||||
};
|
||||
|
||||
var CMEDITOR_CHECK_INTERVAL = 100;
|
||||
var cmEditorAvailable = function (cb) {
|
||||
var intr;
|
||||
var check = function () {
|
||||
if (window.CodeMirror) {
|
||||
clearTimeout(intr);
|
||||
cb(window.CodeMirror);
|
||||
}
|
||||
};
|
||||
intr = setInterval(function () {
|
||||
console.log("CodeMirror was not defined. Trying again in %sms", CMEDITOR_CHECK_INTERVAL);
|
||||
check();
|
||||
}, CMEDITOR_CHECK_INTERVAL);
|
||||
check();
|
||||
};
|
||||
var main = function () {
|
||||
var CM;
|
||||
var CodeMirror;
|
||||
var editor;
|
||||
var common;
|
||||
|
||||
nThen(function (waitFor) {
|
||||
cmEditorAvailable(waitFor(function (cm) {
|
||||
CM = cm;
|
||||
}));
|
||||
$(waitFor(function () {
|
||||
Cryptpad.addLoadingScreen();
|
||||
}));
|
||||
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
|
||||
}).nThen(function (/*waitFor*/) {
|
||||
CodeMirror = common.initCodeMirrorApp(null, CM);
|
||||
$('.CodeMirror').addClass('fullPage');
|
||||
editor = CodeMirror.editor;
|
||||
Cryptpad.onError(function (info) {
|
||||
if (info && info.type === "store") {
|
||||
onConnectError();
|
||||
}
|
||||
});
|
||||
common.isPresentUrl(function (err, val) {
|
||||
isPresentMode = val;
|
||||
andThen(editor, CodeMirror, common);
|
||||
});
|
||||
});
|
||||
};
|
||||
main();
|
||||
});
|
||||
|
||||
@@ -1,680 +1,41 @@
|
||||
// Load #1, load as little as possible because we are in a race to get the loading screen up.
|
||||
define([
|
||||
'/bower_components/nthen/index.js',
|
||||
'/api/config',
|
||||
'jquery',
|
||||
'/bower_components/chainpad-crypto/crypto.js',
|
||||
'/bower_components/chainpad-netflux/chainpad-netflux.js',
|
||||
'/bower_components/textpatcher/TextPatcher.js',
|
||||
'/common/toolbar2.js',
|
||||
'json.sortify',
|
||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||
'/common/cryptpad-common.js',
|
||||
'/common/cryptget.js',
|
||||
'/slide/slide.js',
|
||||
'/common/requireconfig.js',
|
||||
'/common/sframe-common-outer.js'
|
||||
], function (nThen, ApiConfig, $, RequireConfig, SFCommonO) {
|
||||
var requireConfig = RequireConfig();
|
||||
|
||||
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||
'less!/customize/src/less/cryptpad.less',
|
||||
], function ($, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT, Cryptpad, Cryptget, Slide) {
|
||||
var Messages = Cryptpad.Messages;
|
||||
|
||||
var module = window.APP = {
|
||||
Cryptpad: Cryptpad,
|
||||
TextPatcher: TextPatcher,
|
||||
Slide: Slide,
|
||||
};
|
||||
var APP = window.APP;
|
||||
|
||||
var SLIDE_BACKCOLOR_ID = "cryptpad-backcolor";
|
||||
var SLIDE_COLOR_ID = "cryptpad-color";
|
||||
|
||||
|
||||
$(function () {
|
||||
Cryptpad.addLoadingScreen();
|
||||
|
||||
var stringify = function (obj) {
|
||||
return JSONSortify(obj);
|
||||
// Loaded in load #2
|
||||
nThen(function (waitFor) {
|
||||
$(waitFor());
|
||||
}).nThen(function (waitFor) {
|
||||
var req = {
|
||||
cfg: requireConfig,
|
||||
req: [ '/common/loading.js' ],
|
||||
pfx: window.location.origin
|
||||
};
|
||||
var ifrw = module.ifrw = $('#pad-iframe')[0].contentWindow;
|
||||
var toolbar;
|
||||
var editor;
|
||||
window.rc = requireConfig;
|
||||
window.apiconf = ApiConfig;
|
||||
$('#sbox-iframe').attr('src',
|
||||
ApiConfig.httpSafeOrigin + '/slide/inner.html?' + requireConfig.urlArgs +
|
||||
'#' + encodeURIComponent(JSON.stringify(req)));
|
||||
|
||||
var secret = Cryptpad.getSecrets();
|
||||
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||
Slide.readOnly = readOnly;
|
||||
if (!secret.keys) {
|
||||
secret.keys = secret.key;
|
||||
}
|
||||
|
||||
var presentMode = Slide.isPresentURL();
|
||||
|
||||
var onConnectError = function () {
|
||||
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
||||
// This is a cheap trick to avoid loading sframe-channel in parallel with the
|
||||
// loading screen setup.
|
||||
var done = waitFor();
|
||||
var onMsg = function (msg) {
|
||||
var data = JSON.parse(msg.data);
|
||||
if (data.q !== 'READY') { return; }
|
||||
window.removeEventListener('message', onMsg);
|
||||
var _done = done;
|
||||
done = function () { };
|
||||
_done();
|
||||
};
|
||||
|
||||
var andThen = function (CMeditor) {
|
||||
var $iframe = $('#pad-iframe').contents();
|
||||
var $contentContainer = $iframe.find('#editorContainer');
|
||||
var CodeMirror = Cryptpad.createCodemirror(ifrw, Cryptpad, null, CMeditor);
|
||||
editor = CodeMirror.editor;
|
||||
|
||||
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
||||
var $pad = $('#pad-iframe');
|
||||
|
||||
var isHistoryMode = false;
|
||||
|
||||
var setEditable = module.setEditable = function (bool) {
|
||||
if (readOnly && bool) { return; }
|
||||
editor.setOption('readOnly', !bool);
|
||||
};
|
||||
|
||||
var Title;
|
||||
var UserList;
|
||||
var Metadata;
|
||||
|
||||
var setTabTitle = function (title) {
|
||||
var slideNumber = '';
|
||||
if (Slide.shown) { //Slide.index && Slide.content.length) {
|
||||
slideNumber = ' (' + Slide.index + '/' + Slide.content.length + ')';
|
||||
}
|
||||
document.title = title + slideNumber;
|
||||
};
|
||||
|
||||
var initialState = Messages.slideInitialState;
|
||||
|
||||
var $modal = $pad.contents().find('#modal');
|
||||
var $content = $pad.contents().find('#content');
|
||||
var $print = $pad.contents().find('#print');
|
||||
var slideOptions = {};
|
||||
|
||||
$content.click(function (e) {
|
||||
if (!e.target) { return; }
|
||||
var $t = $(e.target);
|
||||
if ($t.is('a') || $t.parents('a').length) {
|
||||
e.preventDefault();
|
||||
var $a = $t.is('a') ? $t : $t.parents('a').first();
|
||||
var href = $a.attr('href');
|
||||
window.open(href);
|
||||
}
|
||||
});
|
||||
|
||||
Slide.setModal($modal, $content, $pad, ifrw, slideOptions, initialState);
|
||||
|
||||
var enterPresentationMode = function (shouldLog) {
|
||||
Slide.show(true, editor.getValue());
|
||||
if (shouldLog) {
|
||||
Cryptpad.log(Messages.presentSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
if (presentMode) {
|
||||
enterPresentationMode(true);
|
||||
}
|
||||
|
||||
var textColor;
|
||||
var backColor;
|
||||
|
||||
var config = {
|
||||
initialState: '{}',
|
||||
websocketURL: Cryptpad.getWebsocketURL(),
|
||||
channel: secret.channel,
|
||||
// our public key
|
||||
validateKey: secret.keys.validateKey || undefined,
|
||||
readOnly: readOnly,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
transformFunction: JsonOT.validate,
|
||||
network: Cryptpad.getNetwork()
|
||||
};
|
||||
|
||||
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
||||
|
||||
var setHistory = function (bool, update) {
|
||||
isHistoryMode = bool;
|
||||
setEditable(!bool);
|
||||
if (!bool && update) {
|
||||
config.onRemote();
|
||||
}
|
||||
};
|
||||
|
||||
var initializing = true;
|
||||
|
||||
var stringifyInner = function (textValue) {
|
||||
var obj = {
|
||||
content: textValue,
|
||||
metadata: {
|
||||
users: UserList.userData,
|
||||
defaultTitle: Title.defaultTitle,
|
||||
slideOptions: slideOptions
|
||||
}
|
||||
};
|
||||
if (!initializing) {
|
||||
obj.metadata.title = Title.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 (isHistoryMode) { return; }
|
||||
if (readOnly) { return; }
|
||||
|
||||
editor.save();
|
||||
|
||||
var textValue = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson = stringifyInner(textValue);
|
||||
|
||||
module.patchText(shjson);
|
||||
Slide.update(textValue);
|
||||
|
||||
if (module.realtime.getUserDoc() !== shjson) {
|
||||
console.error("realtime.getUserDoc() !== shjson");
|
||||
}
|
||||
};
|
||||
|
||||
var metadataCfg = {
|
||||
slideOptions: function (newOpt) {
|
||||
if (stringify(newOpt) !== stringify(slideOptions)) {
|
||||
$.extend(slideOptions, newOpt);
|
||||
// TODO: manage realtime + cursor in the "options" modal ??
|
||||
Slide.updateOptions();
|
||||
}
|
||||
}
|
||||
};
|
||||
var updateColors = metadataCfg.slideColors = function (text, back) {
|
||||
if (text) {
|
||||
textColor = text;
|
||||
$modal.css('color', text);
|
||||
$modal.css('border-color', text);
|
||||
$pad.contents().find('#' + SLIDE_COLOR_ID).css('color', text);
|
||||
}
|
||||
if (back) {
|
||||
backColor = back;
|
||||
$modal.css('background-color', back);
|
||||
//$pad.contents().find('#' + SLIDE_COLOR_ID).css('background', back);
|
||||
$pad.contents().find('#' + SLIDE_BACKCOLOR_ID).css('color', back);
|
||||
}
|
||||
};
|
||||
|
||||
var createPrintDialog = function () {
|
||||
var slideOptionsTmp = {
|
||||
title: false,
|
||||
slide: false,
|
||||
date: false,
|
||||
transition: true,
|
||||
style: ''
|
||||
};
|
||||
|
||||
$.extend(slideOptionsTmp, slideOptions);
|
||||
var $container = $('<div class="alertify">');
|
||||
var $container2 = $('<div class="dialog">').appendTo($container);
|
||||
var $div = $('<div id="printOptions">').appendTo($container2);
|
||||
var $p = $('<p>', {'class': 'msg'}).appendTo($div);
|
||||
$('<b>').text(Messages.printOptions).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Slide number
|
||||
$('<input>', {type: 'checkbox', id: 'checkNumber', checked: slideOptionsTmp.slide}).on('change', function () {
|
||||
var c = this.checked;
|
||||
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: slideOptionsTmp.date}).on('change', function () {
|
||||
var c = this.checked;
|
||||
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: slideOptionsTmp.title}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.title = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'checkTitle'}).text(Messages.printTitle).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// Transition
|
||||
$('<input>', {type: 'checkbox', id: 'checkTransition', checked: slideOptionsTmp.transition}).on('change', function () {
|
||||
var c = this.checked;
|
||||
slideOptionsTmp.transition = c;
|
||||
}).appendTo($p).css('width', 'auto');
|
||||
$('<label>', {'for': 'checkTransition'}).text(Messages.printTransition).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
// CSS
|
||||
$('<label>', {'for': 'cssPrint'}).text(Messages.printCSS).appendTo($p);
|
||||
$p.append($('<br>'));
|
||||
var $textarea = $('<textarea>', {'id':'cssPrint'}).css({'width':'100%', 'height':'100px'}).appendTo($p)
|
||||
.on('keydown keyup', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
$textarea.val(slideOptionsTmp.style);
|
||||
window.setTimeout(function () { $textarea.focus(); }, 0);
|
||||
|
||||
var h;
|
||||
|
||||
var todo = function () {
|
||||
$.extend(slideOptions, slideOptionsTmp);
|
||||
slideOptions.style = $textarea.val();
|
||||
onLocal();
|
||||
$container.remove();
|
||||
Cryptpad.stopListening(h);
|
||||
};
|
||||
var todoCancel = function () {
|
||||
$container.remove();
|
||||
Cryptpad.stopListening(h);
|
||||
};
|
||||
|
||||
h = Cryptpad.listenForKeys(todo, todoCancel);
|
||||
|
||||
var $nav = $('<nav>').appendTo($div);
|
||||
$('<button>', {'class': 'cancel'}).text(Messages.cancelButton).appendTo($nav).click(todoCancel);
|
||||
$('<button>', {'class': 'ok'}).text(Messages.settings_save).appendTo($nav).click(todo);
|
||||
|
||||
return $container;
|
||||
};
|
||||
|
||||
config.onInit = function (info) {
|
||||
UserList = Cryptpad.createUserList(info, config.onLocal, Cryptget, Cryptpad);
|
||||
|
||||
var titleCfg = {
|
||||
updateLocalTitle: setTabTitle,
|
||||
getHeadingText: CodeMirror.getHeadingText
|
||||
};
|
||||
Title = Cryptpad.createTitle(titleCfg, config.onLocal, Cryptpad);
|
||||
|
||||
Slide.setTitle(Title);
|
||||
|
||||
Metadata = Cryptpad.createMetadata(UserList, Title, metadataCfg, Cryptpad);
|
||||
|
||||
var configTb = {
|
||||
displayed: ['title', 'useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit', 'upgrade'],
|
||||
userList: UserList.getToolbarConfig(),
|
||||
share: {
|
||||
secret: secret,
|
||||
channel: info.channel
|
||||
},
|
||||
title: Title.getTitleConfig(),
|
||||
common: Cryptpad,
|
||||
readOnly: readOnly,
|
||||
ifrw: ifrw,
|
||||
realtime: info.realtime,
|
||||
network: info.network,
|
||||
$container: $bar,
|
||||
$contentContainer: $contentContainer
|
||||
};
|
||||
toolbar = module.toolbar = Toolbar.create(configTb);
|
||||
|
||||
Title.setToolbar(toolbar);
|
||||
CodeMirror.init(config.onLocal, Title, toolbar);
|
||||
|
||||
var $rightside = toolbar.$rightside;
|
||||
var $drawer = toolbar.$drawer;
|
||||
|
||||
var editHash;
|
||||
|
||||
if (!readOnly) {
|
||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||
}
|
||||
|
||||
/* add a history button */
|
||||
var histConfig = {
|
||||
onLocal: config.onLocal,
|
||||
onRemote: config.onRemote,
|
||||
setHistory: setHistory,
|
||||
applyVal: function (val) {
|
||||
var remoteDoc = JSON.parse(val || '{}').content;
|
||||
editor.setValue(remoteDoc || '');
|
||||
editor.save();
|
||||
},
|
||||
$toolbar: $bar
|
||||
};
|
||||
var $hist = Cryptpad.createButton('history', true, {histConfig: histConfig});
|
||||
$drawer.append($hist);
|
||||
|
||||
/* save as template */
|
||||
if (!Cryptpad.isTemplate(window.location.href)) {
|
||||
var templateObj = {
|
||||
rt: info.realtime,
|
||||
Crypt: Cryptget,
|
||||
getTitle: function () { return document.title; }
|
||||
};
|
||||
var $templateButton = Cryptpad.createButton('template', true, templateObj);
|
||||
$rightside.append($templateButton);
|
||||
}
|
||||
|
||||
/* add an export button */
|
||||
var $export = Cryptpad.createButton('export', true, {}, CodeMirror.exportText);
|
||||
$drawer.append($export);
|
||||
|
||||
if (!readOnly) {
|
||||
/* add an import button */
|
||||
var $import = Cryptpad.createButton('import', true, {}, CodeMirror.importText);
|
||||
$drawer.append($import);
|
||||
}
|
||||
|
||||
/* add a forget button */
|
||||
var forgetCb = function (err) {
|
||||
if (err) { return; }
|
||||
setEditable(false);
|
||||
};
|
||||
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
||||
$rightside.append($forgetPad);
|
||||
|
||||
var fileDialogCfg = {
|
||||
$body: $iframe.find('body'),
|
||||
onSelect: function (href) {
|
||||
var parsed = Cryptpad.parsePadUrl(href);
|
||||
var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel);
|
||||
var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName;
|
||||
var mt = '<media-tag src="' + src + '" data-crypto-key="cryptpad:' + parsed.hashData.key + '"></media-tag>';
|
||||
editor.replaceSelection(mt);
|
||||
},
|
||||
data: APP
|
||||
};
|
||||
$('<button>', {
|
||||
title: Messages.filePickerButton,
|
||||
'class': 'rightside-button fa fa-picture-o',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
Cryptpad.createFileDialog(fileDialogCfg);
|
||||
}).appendTo($rightside);
|
||||
|
||||
var $previewButton = APP.$previewButton = Cryptpad.createButton(null, true);
|
||||
$previewButton.removeClass('fa-question').addClass('fa-eye');
|
||||
$previewButton.attr('title', Messages.previewButtonTitle);
|
||||
$previewButton.click(function () {
|
||||
var $c = $iframe.find('#editorContainer');
|
||||
if ($c.hasClass('preview')) {
|
||||
Cryptpad.setPadAttribute('previewMode', false, function (e) {
|
||||
if (e) { return console.log(e); }
|
||||
});
|
||||
$previewButton.removeClass('active');
|
||||
return void $c.removeClass('preview');
|
||||
}
|
||||
Cryptpad.setPadAttribute('previewMode', true, function (e) {
|
||||
if (e) { return console.log(e); }
|
||||
});
|
||||
$c.addClass('preview');
|
||||
$previewButton.addClass('active');
|
||||
Slide.updateFontSize();
|
||||
});
|
||||
$rightside.append($previewButton);
|
||||
|
||||
var $printButton = $('<button>', {
|
||||
title: Messages.printButtonTitle,
|
||||
'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});
|
||||
Cryptpad.feedback('PRINT_SLIDES');
|
||||
//$('body').append(createPrintDialog());
|
||||
}).append($('<span>', {'class': 'drawer'}).text(Messages.printText));
|
||||
|
||||
$drawer.append($printButton);
|
||||
|
||||
var $slideOptions = $('<button>', {
|
||||
title: Messages.slideOptionsTitle,
|
||||
'class': 'rightside-button fa fa-cog',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
$('body').append(createPrintDialog());
|
||||
}).append($('<span>', {'class': 'drawer'}).text(Messages.slideOptionsText));
|
||||
$drawer.append($slideOptions);
|
||||
|
||||
var $present = Cryptpad.createButton('present', true)
|
||||
.click(function () {
|
||||
enterPresentationMode(true);
|
||||
});
|
||||
if (presentMode) {
|
||||
$present.hide();
|
||||
}
|
||||
$rightside.append($present);
|
||||
|
||||
var configureColors = function () {
|
||||
var $back = $('<button>', {
|
||||
id: SLIDE_BACKCOLOR_ID,
|
||||
'class': 'fa fa-square rightside-button',
|
||||
'style': 'font-family: FontAwesome; color: #000;',
|
||||
title: Messages.backgroundButtonTitle
|
||||
});
|
||||
var $text = $('<button>', {
|
||||
id: SLIDE_COLOR_ID,
|
||||
'class': 'fa fa-i-cursor rightside-button',
|
||||
'style': 'font-family: FontAwesome; font-weight: bold; color: #fff;',
|
||||
title: Messages.colorButtonTitle
|
||||
});
|
||||
var $testColor = $('<input>', { type: 'color', value: '!' });
|
||||
var $check = $pad.contents().find("#colorPicker_check");
|
||||
if ($testColor.attr('type') !== "color" || $testColor.val() === '!') { return; }
|
||||
$back.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: backColor })
|
||||
.css({ display: 'none', })
|
||||
.on('change', function() {
|
||||
updateColors(undefined, this.value);
|
||||
onLocal();
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
$text.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: textColor })
|
||||
.css({ display: 'none', })
|
||||
.on('change', function() {
|
||||
updateColors(this.value, undefined);
|
||||
onLocal();
|
||||
$check.html('');
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
$rightside.append($back).append($text);
|
||||
};
|
||||
|
||||
configureColors();
|
||||
CodeMirror.configureTheme();
|
||||
|
||||
if (presentMode) {
|
||||
$('#top-bar').hide();
|
||||
}
|
||||
|
||||
// set the hash
|
||||
if (!window.location.hash || window.location.hash === '#') {
|
||||
Cryptpad.replaceHash(editHash);
|
||||
}
|
||||
};
|
||||
|
||||
config.onReady = function (info) {
|
||||
if (module.realtime !== info.realtime) {
|
||||
var realtime = module.realtime = info.realtime;
|
||||
module.patchText = TextPatcher.create({
|
||||
realtime: realtime,
|
||||
//logging: true
|
||||
});
|
||||
}
|
||||
|
||||
var userDoc = module.realtime.getUserDoc();
|
||||
|
||||
var isNew = false;
|
||||
if (userDoc === "" || userDoc === "{}") { isNew = true; }
|
||||
|
||||
var newDoc = "";
|
||||
if(userDoc !== "") {
|
||||
var hjson = JSON.parse(userDoc);
|
||||
newDoc = hjson.content;
|
||||
|
||||
if (typeof (hjson) !== 'object' || Array.isArray(hjson) ||
|
||||
(typeof(hjson.type) !== 'undefined' && hjson.type !== 'slide')) {
|
||||
var errorText = Messages.typeError;
|
||||
Cryptpad.errorLoadingScreen(errorText);
|
||||
throw new Error(errorText);
|
||||
}
|
||||
|
||||
if (hjson.highlightMode) {
|
||||
CodeMirror.setMode(hjson.highlightMode);
|
||||
}
|
||||
}
|
||||
if (!CodeMirror.highlightMode) {
|
||||
CodeMirror.setMode('markdown');
|
||||
}
|
||||
|
||||
// Update the user list (metadata) from the hyperjson
|
||||
Metadata.update(userDoc);
|
||||
editor.setValue(newDoc || initialState);
|
||||
|
||||
if (Cryptpad.initialName && Title.isDefaultTitle()) {
|
||||
Title.updateTitle(Cryptpad.initialName);
|
||||
}
|
||||
|
||||
Cryptpad.getPadAttribute('previewMode', function (e, data) {
|
||||
if (e) { return void console.error(e); }
|
||||
if ([true, undefined].indexOf(data) !== -1 && APP.$previewButton) {
|
||||
APP.$previewButton.click();
|
||||
}
|
||||
});
|
||||
|
||||
Slide.onChange(function (o, n, l) {
|
||||
var slideNumber = '';
|
||||
if (n !== null) {
|
||||
if (Slide.shown) { //Slide.index && Slide.content.length) {
|
||||
slideNumber = ' (' + (++n) + '/' + l + ')';
|
||||
}
|
||||
}
|
||||
document.title = Title.title + slideNumber;
|
||||
});
|
||||
|
||||
Cryptpad.removeLoadingScreen();
|
||||
setEditable(true);
|
||||
initializing = false;
|
||||
|
||||
onLocal(); // push local state to avoid parse errors later.
|
||||
Slide.update(editor.getValue());
|
||||
|
||||
if (readOnly) { return; }
|
||||
UserList.getLastName(toolbar.$userNameButton, isNew);
|
||||
|
||||
var fmConfig = {
|
||||
dropArea: $iframe.find('.CodeMirror'),
|
||||
body: $iframe.find('body'),
|
||||
onUploaded: function (ev, data) {
|
||||
//var cursor = editor.getCursor();
|
||||
//var cleanName = data.name.replace(/[\[\]]/g, '');
|
||||
//var text = '';
|
||||
var parsed = Cryptpad.parsePadUrl(data.url);
|
||||
var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel);
|
||||
var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName;
|
||||
var mt = '<media-tag src="' + src + '" data-crypto-key="cryptpad:' + parsed.hashData.key + '"></media-tag>';
|
||||
editor.replaceSelection(mt);
|
||||
}
|
||||
};
|
||||
APP.FM = Cryptpad.createFileManager(fmConfig);
|
||||
};
|
||||
|
||||
config.onRemote = function () {
|
||||
if (initializing) { return; }
|
||||
if (isHistoryMode) { return; }
|
||||
|
||||
var oldDoc = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson = module.realtime.getUserDoc();
|
||||
|
||||
// Update the user list (metadata) from the hyperjson
|
||||
Metadata.update(shjson);
|
||||
|
||||
var hjson = JSON.parse(shjson);
|
||||
var remoteDoc = hjson.content;
|
||||
|
||||
var highlightMode = hjson.highlightMode;
|
||||
if (highlightMode && highlightMode !== CodeMirror.highlightMode) {
|
||||
CodeMirror.setMode(highlightMode);
|
||||
}
|
||||
|
||||
CodeMirror.setValueAndCursor(oldDoc, remoteDoc, TextPatcher);
|
||||
|
||||
if (!readOnly) {
|
||||
var textValue = canonicalize(CodeMirror.$textarea.val());
|
||||
var shjson2 = stringifyInner(textValue);
|
||||
if (shjson2 !== shjson) {
|
||||
console.error("shjson2 !== shjson");
|
||||
TextPatcher.log(shjson, TextPatcher.diff(shjson, shjson2));
|
||||
module.patchText(shjson2);
|
||||
}
|
||||
}
|
||||
Slide.update(remoteDoc);
|
||||
|
||||
if (oldDoc !== remoteDoc) {
|
||||
Cryptpad.notify();
|
||||
}
|
||||
};
|
||||
|
||||
config.onAbort = function () {
|
||||
// inform of network disconnect
|
||||
setEditable(false);
|
||||
toolbar.failed();
|
||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||
};
|
||||
|
||||
config.onConnectionChange = function (info) {
|
||||
setEditable(info.state);
|
||||
toolbar.failed();
|
||||
if (info.state) {
|
||||
initializing = true;
|
||||
toolbar.reconnecting(info.myId);
|
||||
Cryptpad.findOKButton().click();
|
||||
} else {
|
||||
if (!Slide.isPresentURL()) {
|
||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
config.onError = onConnectError;
|
||||
|
||||
module.realtime = Realtime.start(config);
|
||||
|
||||
editor.on('change', onLocal);
|
||||
|
||||
Cryptpad.onLogout(function () { setEditable(false); });
|
||||
};
|
||||
|
||||
var interval = 100;
|
||||
|
||||
var second = function (CM) {
|
||||
Cryptpad.ready(function () {
|
||||
andThen(CM);
|
||||
Cryptpad.reportAppUsage();
|
||||
});
|
||||
Cryptpad.onError(function (info) {
|
||||
if (info && info.type === "store") {
|
||||
onConnectError();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var first = function () {
|
||||
if (ifrw.CodeMirror) {
|
||||
// it exists, call your continuation
|
||||
second(ifrw.CodeMirror);
|
||||
} else {
|
||||
console.log("CodeMirror was not defined. Trying again in %sms", interval);
|
||||
// try again in 'interval' ms
|
||||
setTimeout(first, interval);
|
||||
}
|
||||
};
|
||||
|
||||
first();
|
||||
window.addEventListener('message', onMsg);
|
||||
}).nThen(function (/*waitFor*/) {
|
||||
SFCommonO.start();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
h1 {
|
||||
font-size: 40px;
|
||||
}
|
||||
h2 {
|
||||
font-size: 37px;
|
||||
}
|
||||
h3 {
|
||||
font-size: 34px;
|
||||
}
|
||||
h4 {
|
||||
font-size: 31px;
|
||||
}
|
||||
h5 {
|
||||
font-size: 27px;
|
||||
}
|
||||
h6 {
|
||||
font-size: 24px;
|
||||
}
|
||||
body .CodeMirror {
|
||||
height: 100%;
|
||||
}
|
||||
body .CodeMirror-focused .cm-matchhighlight {
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
|
||||
background-position: bottom;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
#colorPicker_check {
|
||||
display: block;
|
||||
}
|
||||
@media print {
|
||||
@page {
|
||||
margin: 0;
|
||||
size: landscape;
|
||||
}
|
||||
body {
|
||||
display: block;
|
||||
}
|
||||
body .CodeMirror,
|
||||
body #cme_toolbox {
|
||||
display: none;
|
||||
}
|
||||
body * {
|
||||
visibility: hidden;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
}
|
||||
html .cp #print {
|
||||
display: block;
|
||||
visibility: visible;
|
||||
}
|
||||
html .cp #print * {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
#cme_toolbox {
|
||||
z-index: 10000;
|
||||
}
|
||||
#editorContainer {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
#editorContainer .CodeMirror {
|
||||
resize: none;
|
||||
width: 100vw;
|
||||
}
|
||||
#editorContainer.preview .CodeMirror {
|
||||
width: 50vw;
|
||||
}
|
||||
.preview .cp {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
.preview .cp div#modal:not(.shown) {
|
||||
position: relative;
|
||||
top: auto;
|
||||
left: auto;
|
||||
width: auto;
|
||||
display: block;
|
||||
height: 100%;
|
||||
}
|
||||
.preview .cp div#modal:not(.shown) #content .slide-container {
|
||||
width: 100%;
|
||||
}
|
||||
.preview .cp div#modal:not(.shown) #content .slide-frame {
|
||||
width: 50vw;
|
||||
height: 28.125vw;
|
||||
max-height: 100vh;
|
||||
max-width: 177.78vh;
|
||||
}
|
||||
.cp {
|
||||
/* Slide position (print mode) */
|
||||
/* Slide position (present mode) */
|
||||
/* Slide content */
|
||||
}
|
||||
.cp #print {
|
||||
position: relative;
|
||||
display: none;
|
||||
font-size: 10.125vw;
|
||||
/*.slide-frame:first-child {
|
||||
margin-top: ~"calc(((100vh - 56.25vw)/2))";
|
||||
}*/
|
||||
}
|
||||
.cp #print .slide-frame {
|
||||
display: block !important;
|
||||
padding: 0.5em;
|
||||
margin: auto;
|
||||
border: 1px solid black;
|
||||
height: 50.625vw;
|
||||
width: 90vw;
|
||||
page-break-after: always;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.cp #print .slide-frame li {
|
||||
min-width: 45vw;
|
||||
}
|
||||
.cp #print .slide-frame h1 {
|
||||
padding-top: 0;
|
||||
}
|
||||
.cp #print .slide-container {
|
||||
width: 90vw;
|
||||
height: 100vh;
|
||||
margin: 0vh 5vw;
|
||||
display: flex;
|
||||
}
|
||||
.cp #print .slide-container:last-child {
|
||||
height: calc(100vh - 2px);
|
||||
}
|
||||
.cp div.modal,
|
||||
.cp div#modal {
|
||||
background-color: black;
|
||||
color: white;
|
||||
/* Navigation buttons */
|
||||
box-sizing: border-box;
|
||||
z-index: 9001;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
display: none;
|
||||
background-color: #000;
|
||||
}
|
||||
.cp div.modal .button,
|
||||
.cp div#modal .button {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
font-size: 30px;
|
||||
opacity: 0.6;
|
||||
display: none;
|
||||
z-index: 9001;
|
||||
}
|
||||
.cp div.modal .button:hover,
|
||||
.cp div#modal .button:hover {
|
||||
opacity: 1;
|
||||
display: block !important;
|
||||
}
|
||||
.cp div.modal #button_exit,
|
||||
.cp div#modal #button_exit {
|
||||
left: 20px;
|
||||
top: 20px;
|
||||
}
|
||||
.cp div.modal #button_left,
|
||||
.cp div#modal #button_left {
|
||||
left: 6vw;
|
||||
bottom: 10vh;
|
||||
}
|
||||
.cp div.modal #button_right,
|
||||
.cp div#modal #button_right {
|
||||
right: 6vw;
|
||||
bottom: 10vh;
|
||||
}
|
||||
.cp div.modal.shown,
|
||||
.cp div#modal.shown {
|
||||
display: block;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
z-index: 100000;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
}
|
||||
.cp div.modal #content,
|
||||
.cp div#modal #content {
|
||||
font-size: 20vh;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cp div.modal #content .slide-frame,
|
||||
.cp div#modal #content .slide-frame {
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid;
|
||||
white-space: normal;
|
||||
vertical-align: middle;
|
||||
/* center things as much as possible
|
||||
|
||||
margin-top: 50vh;
|
||||
margin-bottom: 50vh;
|
||||
transform: translateY(-50%);
|
||||
|
||||
*/
|
||||
padding: 0.5em;
|
||||
width: 100vw;
|
||||
height: 56.25vw;
|
||||
max-height: 100vh;
|
||||
max-width: 177.78vh;
|
||||
margin: auto;
|
||||
}
|
||||
.cp div.modal #content .slide-container,
|
||||
.cp div#modal #content .slide-container {
|
||||
display: inline-flex;
|
||||
height: 100%;
|
||||
width: 100vw;
|
||||
text-align: center;
|
||||
vertical-align: top;
|
||||
}
|
||||
.cp div.modal #content.transition .slide-container,
|
||||
.cp div#modal #content.transition .slide-container {
|
||||
transition: margin-left 1s;
|
||||
}
|
||||
.cp div.modal .center,
|
||||
.cp div#modal .center {
|
||||
position: relative;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
border: 1px solid #ffffff;
|
||||
text-align: center;
|
||||
}
|
||||
.cp div.modal.shown,
|
||||
.cp div#modal.shown {
|
||||
display: block;
|
||||
}
|
||||
.cp div#modal #content .slide-frame,
|
||||
.cp #print .slide-frame {
|
||||
text-align: left;
|
||||
position: relative;
|
||||
}
|
||||
.cp div#modal #content .slide-frame *,
|
||||
.cp #print .slide-frame * {
|
||||
font-size: 27.5%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame * *,
|
||||
.cp #print .slide-frame * * {
|
||||
font-size: 100%;
|
||||
line-height: 1em;
|
||||
}
|
||||
.cp div#modal #content .slide-frame ul ul,
|
||||
.cp #print .slide-frame ul ul,
|
||||
.cp div#modal #content .slide-frame ol ul,
|
||||
.cp #print .slide-frame ol ul,
|
||||
.cp div#modal #content .slide-frame ul ol,
|
||||
.cp #print .slide-frame ul ol,
|
||||
.cp div#modal #content .slide-frame ol ol,
|
||||
.cp #print .slide-frame ol ol {
|
||||
margin: 0;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h1,
|
||||
.cp #print .slide-frame h1 {
|
||||
font-size: 50%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h2,
|
||||
.cp #print .slide-frame h2 {
|
||||
font-size: 42%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h3,
|
||||
.cp #print .slide-frame h3 {
|
||||
font-size: 36%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h4,
|
||||
.cp #print .slide-frame h4 {
|
||||
font-size: 30%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h5,
|
||||
.cp #print .slide-frame h5 {
|
||||
font-size: 22%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h6,
|
||||
.cp #print .slide-frame h6 {
|
||||
font-size: 16%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame h1,
|
||||
.cp #print .slide-frame h1,
|
||||
.cp div#modal #content .slide-frame h2,
|
||||
.cp #print .slide-frame h2,
|
||||
.cp div#modal #content .slide-frame h3,
|
||||
.cp #print .slide-frame h3,
|
||||
.cp div#modal #content .slide-frame h4,
|
||||
.cp #print .slide-frame h4,
|
||||
.cp div#modal #content .slide-frame h5,
|
||||
.cp #print .slide-frame h5,
|
||||
.cp div#modal #content .slide-frame h6,
|
||||
.cp #print .slide-frame h6 {
|
||||
color: inherit;
|
||||
text-align: center;
|
||||
padding-top: 0;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.cp div#modal #content .slide-frame pre > code,
|
||||
.cp #print .slide-frame pre > code {
|
||||
display: block;
|
||||
position: relative;
|
||||
border: 1px solid #333;
|
||||
width: 90%;
|
||||
margin: auto;
|
||||
padding-left: .25vw;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
.cp div#modal #content .slide-frame ul,
|
||||
.cp #print .slide-frame ul,
|
||||
.cp div#modal #content .slide-frame ol,
|
||||
.cp #print .slide-frame ol {
|
||||
min-width: 50%;
|
||||
max-width: 100%;
|
||||
display: table;
|
||||
margin: 0 auto;
|
||||
padding-left: 0.3em;
|
||||
}
|
||||
.cp div#modal #content .slide-frame img,
|
||||
.cp #print .slide-frame img {
|
||||
position: relative;
|
||||
min-width: 1%;
|
||||
max-width: 90%;
|
||||
max-height: 90%;
|
||||
margin: auto;
|
||||
}
|
||||
.cp div#modal #content .slide-frame .slideNumber,
|
||||
.cp #print .slide-frame .slideNumber {
|
||||
position: absolute;
|
||||
right: 5vh;
|
||||
bottom: 5vh;
|
||||
font-size: 10%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame .slideDate,
|
||||
.cp #print .slide-frame .slideDate {
|
||||
position: absolute;
|
||||
left: 5vh;
|
||||
bottom: 5vh;
|
||||
font-size: 10%;
|
||||
line-height: 110%;
|
||||
}
|
||||
.cp div#modal #content .slide-frame .slideTitle,
|
||||
.cp #print .slide-frame .slideTitle {
|
||||
position: absolute;
|
||||
bottom: 5vh;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
text-align: center;
|
||||
font-size: 10%;
|
||||
line-height: 110%;
|
||||
}
|
||||
#fileDialog {
|
||||
position: absolute;
|
||||
background-color: rgba(200, 200, 200, 0.8);
|
||||
top: 15vh;
|
||||
bottom: 15vh;
|
||||
left: 10vw;
|
||||
right: 10vw;
|
||||
border: 1px solid black;
|
||||
z-index: 10;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
#fileDialog .close {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#fileDialog .element {
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid #ccc;
|
||||
margin: 5px;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
background-color: white;
|
||||
padding: 5px;
|
||||
align-items: center;
|
||||
}
|
||||
#fileDialog .element span {
|
||||
width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/common/diffMarked.js',
|
||||
'/common/cryptpad-common.js',
|
||||
],function ($, DiffMd, Cryptpad) {
|
||||
],function ($, DiffMd) {
|
||||
|
||||
var Slide = {
|
||||
index: 0,
|
||||
@@ -13,13 +12,13 @@ define([
|
||||
var ifrw;
|
||||
var $modal;
|
||||
var $content;
|
||||
var $pad;
|
||||
var placeholder;
|
||||
var options;
|
||||
var separator = '<hr data-pewpew="pezpez">';
|
||||
var separatorReg = /<hr data\-pewpew="pezpez">/g;
|
||||
var slideClass = 'slide-frame';
|
||||
var slideClass = 'cp-app-slide-frame';
|
||||
var Title;
|
||||
var Common;
|
||||
|
||||
Slide.onChange = function (f) {
|
||||
if (typeof(f) === 'function') {
|
||||
@@ -60,21 +59,21 @@ define([
|
||||
};
|
||||
|
||||
var fixCSS = function (css) {
|
||||
var append = '.cp #print .slide-frame ';
|
||||
var append2 = '.cp div#modal #content .slide-frame ';
|
||||
var append = '.cp #cp-app-slide-print .cp-app-slide-frame ';
|
||||
var append2 = '.cp div#cp-app-slide-modal #cp-app-slide-modal-content .cp-app-slide-frame ';
|
||||
return css.replace(/(\n*)([^\n}]+)\s*\{/g, '$1' + append + '$2,' + append2 + '$2 {');
|
||||
};
|
||||
|
||||
var goTo = Slide.goTo = function (i) {
|
||||
i = i || 0;
|
||||
Slide.index = i;
|
||||
$content.find('.slide-container').first().css('margin-left', -(i*100)+'%');
|
||||
$content.find('.cp-app-slide-container').first().css('margin-left', -(i*100)+'%');
|
||||
updateFontSize();
|
||||
change(Slide.lastIndex, Slide.index);
|
||||
$modal.find('#button_left > span').css({
|
||||
$modal.find('#cp-app-slide-modal-left > span').css({
|
||||
opacity: Slide.index === 0? 0: 1
|
||||
});
|
||||
$modal.find('#button_right > span').css({
|
||||
$modal.find('#cp-app-slide-modal-right > span').css({
|
||||
opacity: Slide.index === (getNumberOfSlides() -1)? 0: 1
|
||||
});
|
||||
};
|
||||
@@ -82,29 +81,29 @@ define([
|
||||
if (typeof(Slide.content) !== 'string') { return; }
|
||||
|
||||
var c = Slide.content;
|
||||
var m = '<span class="slide-container"><span class="'+slideClass+'">'+DiffMd.render(c).replace(separatorReg, '</span></span><span class="slide-container"><span class="'+slideClass+'">')+'</span></span>';
|
||||
var m = '<span class="cp-app-slide-container"><span class="'+slideClass+'">'+DiffMd.render(c).replace(separatorReg, '</span></span><span class="cp-app-slide-container"><span class="'+slideClass+'">')+'</span></span>';
|
||||
|
||||
DiffMd.apply(m, $content);
|
||||
|
||||
var length = getNumberOfSlides();
|
||||
$modal.find('style.slideStyle').remove();
|
||||
$modal.find('style.cp-app-slide-style').remove();
|
||||
if (options.style && Slide.shown) {
|
||||
$modal.prepend($('<style>', {'class': 'slideStyle'}).text(fixCSS(options.style)));
|
||||
$modal.prepend($('<style>', {'class': 'cp-app-slide-style'}).text(fixCSS(options.style)));
|
||||
}
|
||||
$content.find('.slide-frame').each(function (i, el) {
|
||||
$content.find('.cp-app-slide-frame').each(function (i, el) {
|
||||
if (options.slide) {
|
||||
$('<div>', {'class': 'slideNumber'}).text((i+1)+'/'+length).appendTo($(el));
|
||||
$('<div>', {'class': 'cp-app-slide-number'}).text((i+1)+'/'+length).appendTo($(el));
|
||||
}
|
||||
if (options.date) {
|
||||
$('<div>', {'class': 'slideDate'}).text(new Date().toLocaleDateString()).appendTo($(el));
|
||||
$('<div>', {'class': 'cp-app-slide-date'}).text(new Date().toLocaleDateString()).appendTo($(el));
|
||||
}
|
||||
if (options.title) {
|
||||
$('<div>', {'class': 'slideTitle'}).text(Title.title).appendTo($(el));
|
||||
$('<div>', {'class': 'cp-app-slide-title'}).text(Title.title).appendTo($(el));
|
||||
}
|
||||
});
|
||||
$content.removeClass('transition');
|
||||
$content.removeClass('cp-app-slide-transition');
|
||||
if (options.transition || typeof(options.transition) === "undefined") {
|
||||
$content.addClass('transition');
|
||||
$content.addClass('cp-app-slide-transition');
|
||||
}
|
||||
//$content.find('.' + slideClass).hide();
|
||||
//$content.find('.' + slideClass + ':eq( ' + i + ' )').show();
|
||||
@@ -116,46 +115,29 @@ define([
|
||||
draw(Slide.index);
|
||||
};
|
||||
|
||||
var isPresentURL = Slide.isPresentURL = function () {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
return parsed && parsed.hashData && parsed.hashData.present;
|
||||
};
|
||||
|
||||
var show = Slide.show = function (bool, content) {
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
var hashData = parsed.hashData || {};
|
||||
Slide.shown = bool;
|
||||
if (bool) {
|
||||
Slide.update(content);
|
||||
Slide.draw(Slide.index);
|
||||
$modal.addClass('shown');
|
||||
$modal.addClass('cp-app-slide-shown');
|
||||
$(ifrw).focus();
|
||||
change(null, Slide.index);
|
||||
if (!isPresentURL()) {
|
||||
window.location += parsed.getUrl({present: true, embed: hashData.embed});
|
||||
}
|
||||
$pad.contents().find('.cryptpad-present-button').hide();
|
||||
$pad.contents().find('.cryptpad-source-button').show();
|
||||
$pad.addClass('fullscreen');
|
||||
$('#iframe-container').addClass('fullscreen');
|
||||
$('.top-bar').hide();
|
||||
Common.setPresentUrl(true);
|
||||
$('.cp-app-slide-present-button').hide();
|
||||
updateFontSize();
|
||||
return;
|
||||
}
|
||||
window.location = parsed.getUrl({embed: hashData.embed});
|
||||
Common.setPresentUrl(false);
|
||||
change(Slide.index, null);
|
||||
$pad.contents().find('.cryptpad-present-button').show();
|
||||
$pad.contents().find('.cryptpad-source-button').hide();
|
||||
$pad.removeClass('fullscreen');
|
||||
$('#iframe-container').removeClass('fullscreen');
|
||||
$('.top-bar').show();
|
||||
$modal.removeClass('shown');
|
||||
$('.cp-app-slide-present-button').show();
|
||||
$('.cp-app-slide-source-button').hide();
|
||||
$modal.removeClass('cp-app-slide-shown');
|
||||
updateFontSize();
|
||||
};
|
||||
|
||||
Slide.update = function (content) {
|
||||
updateFontSize();
|
||||
//if (!init) { return; }
|
||||
if (!content) { content = ''; }
|
||||
var old = Slide.content;
|
||||
Slide.content = content.replace(/\n\s*\-\-\-\s*\n/g, '\n\n'+separator+'\n\n');
|
||||
@@ -199,33 +181,34 @@ define([
|
||||
};
|
||||
|
||||
var addEvent = function () {
|
||||
console.log($modal);
|
||||
var icon_to;
|
||||
$modal.mousemove(function () {
|
||||
var $buttons = $modal.find('.button');
|
||||
var $buttons = $modal.find('.cp-app-slide-modal-button');
|
||||
$buttons.show();
|
||||
if (icon_to) { window.clearTimeout(icon_to); }
|
||||
icon_to = window.setTimeout(function() {
|
||||
$buttons.fadeOut();
|
||||
}, 1000);
|
||||
});
|
||||
$modal.find('#button_exit').click(function () {
|
||||
$modal.find('#cp-app-slide-modal-exit').click(function () {
|
||||
var ev = $.Event("keyup");
|
||||
ev.which = 27;
|
||||
$modal.trigger(ev);
|
||||
});
|
||||
$modal.find('#button_left').click(function () {
|
||||
$modal.find('#cp-app-slide-modal-left').click(function () {
|
||||
var ev = $.Event("keyup");
|
||||
ev.which = 37;
|
||||
$modal.trigger(ev);
|
||||
});
|
||||
$modal.find('#button_right').click(function () {
|
||||
$modal.find('#cp-app-slide-modal-right').click(function () {
|
||||
console.log('right');
|
||||
var ev = $.Event("keyup");
|
||||
ev.which = 39;
|
||||
$modal.trigger(ev);
|
||||
});
|
||||
|
||||
$pad.contents().find('.CodeMirror').keyup(function (e) { e.stopPropagation(); });
|
||||
$('.CodeMirror').keyup(function (e) { e.stopPropagation(); });
|
||||
$(ifrw).on('keyup', function (e) {
|
||||
//if (!Slide.shown) { return; }
|
||||
if (e.ctrlKey) { return; }
|
||||
@@ -302,11 +285,11 @@ define([
|
||||
};
|
||||
|
||||
|
||||
Slide.setModal = function ($m, $c, $p, iframe, opt, ph) {
|
||||
Slide.setModal = function (common, $m, $c, opt, ph) {
|
||||
Common = common;
|
||||
$modal = Slide.$modal = $m;
|
||||
$content = Slide.$content = $c;
|
||||
$pad = Slide.$pad = $p;
|
||||
ifrw = Slide.ifrw = iframe;
|
||||
ifrw = Slide.ifrw = window;
|
||||
placeholder = Slide.placeholder = ph;
|
||||
options = Slide.options = opt;
|
||||
addEvent();
|
||||
|
||||
Reference in New Issue
Block a user