]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6193 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 22 Sep 2023 16:30:14 +0000 (18:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 22 Sep 2023 16:30:14 +0000 (18:30 +0200)
js/quiz.resize.js

index 89f9d0120032e8b6b90119d2dea15493fc85abe0..f9aa576853da4c9605e6063e8153802b69d82422 100644 (file)
@@ -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);