From e46dfa93a319bab3ea756f9788600d6e408cf510 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 18 Aug 2023 19:48:21 +0200 Subject: [PATCH] wip #6182 @1 --- js/quiz.resize.js | 27 ++++++++++++++------------- js/quiz.screen.intro.js | 10 ++++++++++ js/quiz.utils.js | 9 +++++++-- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/js/quiz.resize.js b/js/quiz.resize.js index 2ec1192..6d5c755 100644 --- a/js/quiz.resize.js +++ b/js/quiz.resize.js @@ -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, '
'); - } } export default QuizResize; diff --git a/js/quiz.screen.intro.js b/js/quiz.screen.intro.js index b468f2d..ad3e6c8 100644 --- a/js/quiz.screen.intro.js +++ b/js/quiz.screen.intro.js @@ -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; diff --git a/js/quiz.utils.js b/js/quiz.utils.js index a0abb1e..3e7aa66 100644 --- a/js/quiz.utils.js +++ b/js/quiz.utils.js @@ -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, '
'); + }, } -export default QuizUtils; \ No newline at end of file +export default QuizUtils; -- 2.39.5