only add the splitter once

pull/1/head
Pierre Bondoerffer 7 years ago
parent 4026994310
commit 9dce40f3af
No known key found for this signature in database
GPG Key ID: C0C7C0C5063F2236

@ -388,30 +388,32 @@ define([
}); });
// add the splitter // add the splitter
var $preview = $iframe.find('#previewContainer'); if (!$iframe.has('.cp-splitter').length) {
var splitter = $('<div>', { var $preview = $iframe.find('#previewContainer');
'class': 'cp-splitter' var splitter = $('<div>', {
}).appendTo($preview); 'class': 'cp-splitter'
}).appendTo($preview);
$preview.on('scroll', function() {
splitter.css('top', $preview.scrollTop() + 'px'); $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) { splitter.on('mousedown', function (e) {
e.preventDefault(); e.preventDefault();
var x = e.pageX; var x = e.pageX;
var w = $target.width(); var w = $target.width();
$iframe.on('mouseup mousemove', function handler(evt) { $iframe.on('mouseup mousemove', function handler(evt) {
if (evt.type === 'mouseup') { if (evt.type === 'mouseup') {
$iframe.off('mouseup mousemove', handler); $iframe.off('mouseup mousemove', handler);
return; return;
} }
$target.css('width', (w - x + evt.pageX) + 'px'); $target.css('width', (w - x + evt.pageX) + 'px');
});
}); });
}); }
Cryptpad.removeLoadingScreen(); Cryptpad.removeLoadingScreen();
setEditable(true); setEditable(true);

Loading…
Cancel
Save