Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Content-preview script #14644

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@

<resources type="Footer" />

<script at="Foot" depends-on="jQuery">
var renderPreviewUrl = $(document.getElementById('renderPreviewUrl')).data('value');
var iframe = document.getElementById('iframe');
var previewEventTimer = null;
var previewRenderTimer = null;
var previewRendering;
var previewRenderData;
var initialized;
<script>
let iframe = document.getElementById('iframe');
let previewRenderTimer = null, previewRendering, previewRenderData, initialized, renderPreviewUrl;

$(function () {
var previewEventTimer = null;
renderPreviewUrl = document.getElementById('renderPreviewUrl').getAttribute('data-value');
$(window).on('storage', function (ev) {
if (ev.key.indexOf('contentpreview:not-connected:') !== -1) {
$(notConnectedWarning).show();
Expand All @@ -50,7 +47,7 @@
});

// override default behaviour of Bootstrap's. We only hide, not remove the alert.
$('#close-connect-warning').on('click', function(){
$('#close-connect-warning').on('click', function () {
$('#notConnectedWarning').hide();
});

Expand All @@ -72,7 +69,7 @@

iframe.onload = function () {
// The iframe may not be well setup after the first loading and then on the first editor update
// we may lose the scrolling position. A workaround is to refrech the page once after or to add
// we may lose the scrolling position. A workaround is to re-fetch the page once after or to add
// here a delay that really block the thread before exiting. Here, we just rewrite the document.
if (!initialized) {
if (this.contentWindow) {
Expand Down
Loading