diff --git a/www/code/main.js b/www/code/main.js
index 44cab6d36..ebdd52ede 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -388,30 +388,32 @@ define([
});
// add the splitter
- var $preview = $iframe.find('#previewContainer');
- var splitter = $('
', {
- 'class': 'cp-splitter'
- }).appendTo($preview);
-
- $preview.on('scroll', function() {
- splitter.css('top', $preview.scrollTop() + 'px');
- });
+ if (!$iframe.has('.cp-splitter').length) {
+ var $preview = $iframe.find('#previewContainer');
+ var splitter = $('
', {
+ 'class': 'cp-splitter'
+ }).appendTo($preview);
+
+ $preview.on('scroll', function() {
+ splitter.css('top', $preview.scrollTop() + 'px');
+ });
- var $target = $iframe.find('.CodeMirror');
+ var $target = $iframe.find('.CodeMirror');
- splitter.on('mousedown', function (e) {
- e.preventDefault();
- var x = e.pageX;
- var w = $target.width();
+ splitter.on('mousedown', function (e) {
+ e.preventDefault();
+ var x = e.pageX;
+ var w = $target.width();
- $iframe.on('mouseup mousemove', function handler(evt) {
- if (evt.type === 'mouseup') {
- $iframe.off('mouseup mousemove', handler);
- return;
- }
- $target.css('width', (w - x + evt.pageX) + 'px');
+ $iframe.on('mouseup mousemove', function handler(evt) {
+ if (evt.type === 'mouseup') {
+ $iframe.off('mouseup mousemove', handler);
+ return;
+ }
+ $target.css('width', (w - x + evt.pageX) + 'px');
+ });
});
- });
+ }
Cryptpad.removeLoadingScreen();
setEditable(true);