]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6182 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 18 Aug 2023 17:48:21 +0000 (19:48 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 18 Aug 2023 17:48:21 +0000 (19:48 +0200)
js/quiz.resize.js
js/quiz.screen.intro.js
js/quiz.utils.js

index 2ec11924a31880b0bdec151e379dd84e763a06e0..6d5c755fe34cd15703d354c0edcd3c55ff4b6d12 100644 (file)
@@ -6,31 +6,32 @@ QuizResize.prototype = {
     resize: function () {
         this.ww = $(window).width();
         this.hh = $(window).height();
-        let intro_text_mobile = this.quiz.data.intro_text_mobile
-        let intro_text = this.quiz.data.intro_text
+
+        if (this.isMobile()) {
+            $('html').addClass('m');
+        } else {
+            $('html').removeClass('m');
+        }
+
         const iconReset = getSpriteIcon("quiz-reset")
         const textReset = "Reset"
 
         // Exécuter ici toutes opérations qui doivent intervenir lorsque la fenêtre est redimensionnée par le système ou l'utilisateur
         //
-        if(this.ww <= 390) {
-            $("#welcome p").html(this.nl2br(intro_text_mobile))
-        }else {
-            $("#welcome p").html(this.nl2br(intro_text))
-        }
-
+        this.quiz.screens.intro.resize(this.ww, this.hh);
         //
-        if(this.ww <= 992) {
+        if (this.ww <= 992) {
             $(".btn.reset .text").html(iconReset)
         } else {
             $(".btn.reset .text").html(textReset)
         }
+
+    },
+
+    isMobile: function () {
+        return this.ww <= 390;
     },
 
-    nl2br: function(str) {
-        if (!str) return str;
-        return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
-    }
 }
 
 export default QuizResize;
index b468f2d6a43a3f6ba928c712e40a4fb17cd0dc15..ad3e6c8b9924179de6f99e557b69363a05c766f9 100644 (file)
@@ -33,6 +33,16 @@ QuizScreenIntro.prototype = {
         })
     },
 
+    resize: function (ww, hh) {
+        let intro_text_mobile = this.quiz.data.intro_text_mobile
+        let intro_text = this.quiz.data.intro_text
+        if (ww <= 390) {
+            $("#welcome p").html(this.quiz.utils.nl2br(intro_text_mobile))
+        } else {
+            $("#welcome p").html(this.quiz.utils.nl2br(intro_text))
+        }
+    },
+
 }
 
 export default QuizScreenIntro;
index a0abb1e117dbcc455eb06e7d296ab77c7e7364c1..3e7aa66704bb9f2223be95843c90ec1ec774dceb 100644 (file)
@@ -21,7 +21,12 @@ QuizUtils.prototype = {
             return false;
         }
         return true;
-    }
+    },
+
+    nl2br: function (str) {
+        if (!str) return str;
+        return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
+    },
 }
 
-export default QuizUtils;
\ No newline at end of file
+export default QuizUtils;