From 8de9a596f19d956911e80ea5d199bf0bf4cf73c5 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Nov 2017 19:11:27 +0100 Subject: [PATCH] Fix cursor in thumbnails --- www/code/inner.js | 8 ++++---- www/common/common-thumbnail.js | 3 ++- www/common/sframe-app-framework.js | 9 +++++---- www/pad/inner.js | 4 ++++ www/poll/inner.js | 1 + www/whiteboard/inner.js | 1 + 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index 7296d07d3..6ec2c439d 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -7,7 +7,6 @@ define([ '/common/sframe-common.js', '/common/sframe-app-framework.js', '/common/common-util.js', - '/common/common-thumbnail.js', '/common/modes.js', 'cm/lib/codemirror', @@ -46,7 +45,6 @@ define([ SFCommon, Framework, Util, - Thumb, Modes, CMeditor) { @@ -350,11 +348,13 @@ define([ getContainer: getThumbnailContainer, filter: function (el, before) { if (before) { - $(el).parents().css('overflow', 'visible'); + // Overflow visible to the parents makes it look better but + // it creates chaos in the editbale area + //$(el).parents().css('overflow', 'visible'); $(el).css('max-height', Math.max(600, $(el).width()) + 'px'); return; } - $(el).parents().css('overflow', ''); + //$(el).parents().css('overflow', ''); $(el).css('max-height', ''); } } diff --git a/www/common/common-thumbnail.js b/www/common/common-thumbnail.js index fb7edafc4..eb15c831b 100644 --- a/www/common/common-thumbnail.js +++ b/www/common/common-thumbnail.js @@ -5,7 +5,8 @@ define([ var Thumb = { dimension: 100, padDimension: 200, - UPDATE_INTERVAL: 5000 + UPDATE_INTERVAL: 60000, + UPDATE_FIRST: 5000 }; var supportedTypes = [ diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index ca350304e..c25851b21 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -280,12 +280,13 @@ define([ if (!cpNfInner.chainpad) { return; } var content = cpNfInner.chainpad.getUserDoc(); if (content === oldThumbnailState) { return; } - Thumb.fromDOM(options.thumbnail, function (err, b64) { - oldThumbnailState = content; - SFUI.setPadThumbnail(href, b64); - }); + Thumb.fromDOM(options.thumbnail, function (err, b64) { + oldThumbnailState = content; + SFUI.setPadThumbnail(href, b64); + }); }; window.setInterval(mkThumbnail, Thumb.UPDATE_INTERVAL); + window.setTimeout(mkThumbnail, Thumb.UPDATE_FIRST); } if (newPad) { diff --git a/www/pad/inner.js b/www/pad/inner.js index 34340c0a8..a8020e28e 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -557,6 +557,7 @@ define([ getContainer: function () { return $('iframe').contents().find('html')[0]; }, filter: function (el, before) { if (before) { + module.cursor.update(); $(el).parents().css('overflow', 'visible'); $(el).css('max-width', '1200px'); $(el).css('max-height', Math.max(600, $(el).width()) + 'px'); @@ -569,6 +570,9 @@ define([ $(el).css('max-height', ''); $(el).css('overflow', ''); $(el).find('body').css('background-color', '#fff'); + var sel = module.cursor.makeSelection(); + var range = module.cursor.makeRange(); + module.cursor.fixSelection(sel, range); } } }, waitFor(function (fw) { window.APP.framework = framework = fw; })); diff --git a/www/poll/inner.js b/www/poll/inner.js index 3f66a965d..67fc8e796 100644 --- a/www/poll/inner.js +++ b/www/poll/inner.js @@ -837,6 +837,7 @@ define([ }); }; window.setInterval(mkThumbnail, Thumb.UPDATE_INTERVAL); + window.setTimeout(mkThumbnail, Thumb.UPDATE_FIRST); }; var checkDeletedCells = function () { diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index efa45233e..a118d2ede 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -393,6 +393,7 @@ define([ }); }; window.setInterval(mkThumbnail, Thumb.UPDATE_INTERVAL); + window.setTimeout(mkThumbnail, Thumb.UPDATE_FIRST); }; config.onInit = function (info) {