From 4026994310b897cd84db9624eaf057541b6226e4 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Thu, 10 Aug 2017 14:25:31 +0200 Subject: [PATCH 1/3] make splitter work when scrolling --- www/code/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/code/main.js b/www/code/main.js index 7591f12a2..44cab6d36 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -388,11 +388,17 @@ define([ }); // add the splitter + var $preview = $iframe.find('#previewContainer'); var splitter = $('
', { 'class': 'cp-splitter' - }).appendTo($iframe.find('#previewContainer')); + }).appendTo($preview); + + $preview.on('scroll', function() { + splitter.css('top', $preview.scrollTop() + 'px'); + }); var $target = $iframe.find('.CodeMirror'); + splitter.on('mousedown', function (e) { e.preventDefault(); var x = e.pageX; From 9dce40f3afe925ccf4d6cca08160d106ab4e0113 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Thu, 10 Aug 2017 14:34:48 +0200 Subject: [PATCH 2/3] only add the splitter once --- www/code/main.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) 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); From baf64114a6a69b95107e00437517d8fc949a128b Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Thu, 10 Aug 2017 14:45:56 +0200 Subject: [PATCH 3/3] point to homepage in drive --- customize.dist/translations/messages.js | 1 + www/common/toolbar2.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index ec7cac571..7c5c64ceb 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -611,6 +611,7 @@ define(function () { out.header_support = ' OpenPaaS-ng'; out.updated_0_header_logoTitle = 'Go to your CryptDrive'; out.header_logoTitle = out.updated_0_header_logoTitle; + out.header_homeTitle = 'Go to CryptPad homepage'; // Initial states diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index 4a8032ad4..519700624 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -624,9 +624,14 @@ define([ }).appendTo(toolbar.$top); // We need to override the "a" tag action here because it is inside the iframe! + var inDrive = /^\/drive/; + + var href = inDrive ? '/index.html' : '/drive/'; + var buttonTitle = inDrive ? Messages.header_homeTitle : Messages.header_logoTitle; + var $aTag = $('', { - href: "/drive/", - title: Messages.header_logoTitle, + href: href, + title: buttonTitle, 'class': "cryptpad-logo" }).append($('', { src: '/customize/images/logo_white.png' @@ -634,10 +639,10 @@ define([ var onClick = function (e) { e.preventDefault(); if (e.ctrlKey) { - window.open('/drive/'); + window.open(href); return; } - window.location = "/drive/"; + window.location = href; }; var onContext = function (e) { e.stopPropagation(); };