From f69f97bd42e54a688ef81784c0fe7b2d3d572b07 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 22 Sep 2023 18:30:14 +0200 Subject: [PATCH] wip #6193 @0.5 --- js/quiz.resize.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/js/quiz.resize.js b/js/quiz.resize.js index 89f9d01..f9aa576 100644 --- a/js/quiz.resize.js +++ b/js/quiz.resize.js @@ -1,16 +1,35 @@ function QuizResize(quiz) { this.quiz = quiz; + + this.desktopWidth = 1200; + this.desktopHeight = 680; + this.mobileWidth = 390; + + this.measureSizes(); + this.resizePopup(); } QuizResize.prototype = { - resize: function () { + + resizePopup: function () { + if (window.opener === null) { + return; + } + if (this.ww >= this.desktopWidth && this.hh >= this.desktopHeight) { + return; + } + + window.resizeTo(Math.min(screen.width, this.desktopWidth), Math.min(screen.height, this.desktopHeight)); + }, + + measureSizes: function () { this.ww = $(window).width(); this.hh = $(window).height(); this.ratio = this.ww / this.hh; + }, + resize: function () { + this.measureSizes(); - this.desktopWidth = 1200; - this.desktopHeight = 680; - this.mobileWidth = 390; this.updateViewport(); @@ -68,7 +87,7 @@ QuizResize.prototype = { $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes'); let s = 1; let qcss = {}; - if (this.ww < this.desktopWidth || this.hh < this.desktopHeight) { + if (this.ww <= this.desktopWidth || this.hh <= this.desktopHeight) { let sw = this.ww / this.desktopWidth; let sh = this.hh / this.desktopHeight; s = Math.min(sw, sh); -- 2.39.5