]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6182 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Aug 2023 12:52:16 +0000 (14:52 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 21 Aug 2023 12:52:16 +0000 (14:52 +0200)
js/quiz.animations.js
js/quiz.screen.outro.js
js/quiz.screens.js
js/quiz.utils.js
style/006-animations.sass [new file with mode: 0644]
style/style.sass
views/screens/outro.blade.php

index 8c45b75f350365861641970faa2432272b480f54..339de781ab1407f35d49d0fa21eae00941fe0da0 100644 (file)
@@ -54,6 +54,15 @@ QuizAnimations.prototype = {
         clearTimeout(this.instantReviewAnimationTimeout);
     },
 
+    fadeOut: function (el, remove) {
+        $(el).addClass('animateOpacity disabled').css('opacity', 0);
+        if (remove === true) {
+            setTimeout(function () {
+                $(el).remove();
+            }, 500);
+        }
+    },
+
     triggeredBtn: function () {
         /*$(document).on("mousedown", ".btn", function() {
             gsap.to($(this), { scale: .9, duration: 0.3 });
index 7728524d269a029d87006e558faaf5a53ea84bdc..cffde79505fef397fa2733b0e1cf70c94469e258 100644 (file)
@@ -2,13 +2,21 @@ import SimpleBar from 'simplebar'
 import 'simplebar/dist/simplebar.css'
 import Handlebars from "handlebars";
 
-function QuizScreenOutro(quiz) {
-    this.quiz = quiz;
+function QuizScreenOutro(screens) {
+    this.quiz = screens.quiz;
+    this.screens = screens;
+
+    this.initEvents();
 }
 
 QuizScreenOutro.prototype = {
-    show: function () {
+    initEvents: function () {
+        $(document).on("click", ".toggle-answers-review", function () {
+            $(".score-answers-review_container").toggleClass("active")
+        })
+    },
 
+    show: function () {
         let maxScore = this.quiz.score.maxScore,
             score = this.quiz.score.score
 
@@ -55,8 +63,7 @@ QuizScreenOutro.prototype = {
         // https://github.com/Grsmto/simplebar/tree/master/packages/simplebar
         const simpleBar = new SimpleBar($ul.get(0))
     }
-
 };
 
 
-export default QuizScreenOutro;
\ No newline at end of file
+export default QuizScreenOutro;
index a578f8dc4d614ef486d0003a093eed94778bcb4e..300af609c1595ba0f7be19860115021dafbdb66a 100644 (file)
@@ -35,6 +35,9 @@ QuizScreens.prototype = {
                 alert('Please select at least one answer');
                 return false;
             }
+
+            //
+
             if ($(this).hasClass('validate')) {
                 let review = $this.sendUserAnswers();
                 // Si la revue instantanée est activée, on affiche les résultats
@@ -62,8 +65,14 @@ QuizScreens.prototype = {
         $(form).addClass('disabled');
 
         // Remove validate button and show continue button
-        $(activeScreen).find('.btn.validate').addClass('none');
-        $(activeScreen).find('.btn.continue').removeClass('none');
+        setTimeout(function () {
+            $(activeScreen).find('.btn.continue').removeClass('none')
+            $(activeScreen).find('.btn.validate').addClass('none');
+        }, 10);
+
+
+        // Hide reset button
+        this.quiz.animations.fadeOut($(activeScreen).find('.btn.reset'), true);
 
         let results = review.answersStatus;
 
@@ -80,7 +89,7 @@ QuizScreens.prototype = {
             if (answerResult !== "neutral") {
                 $el.find(".access").addClass(answerResult).html(icon);
             } else {
-                $el.find(".access").remove();
+                this.quiz.animations.fadeOut($el.find(".access"));
             }
         }
     },
@@ -89,7 +98,7 @@ QuizScreens.prototype = {
         let nextQuestionIndex = this.quiz.question.currentPosition() + 1;
         let nextScreen;
         if (nextQuestionIndex >= this.quiz.question.count()) {
-            nextScreen = 'review';
+            nextScreen = 'outro';
         } else {
             nextScreen = 'q-' + nextQuestionIndex;
         }
@@ -122,8 +131,13 @@ QuizScreens.prototype = {
                 callback();
             }
             $this.activeScreen = screenToShow;
+            // Reset form to prevent browser letting a option selected after a refresh
+            $this.resetForm();
             $this.currentQuestionAnswers = [];
             $this.quiz.progressbar.update();
+            if (screen === 'outro') {
+                $this.outro.show();
+            }
         });
     },
 
@@ -132,7 +146,7 @@ QuizScreens.prototype = {
         return this.getActiveScreen().find('form');
     },
 
-    resetForm: () => {
+    resetForm: function () {
         this.getCurrentForm().find("input").prop("checked", false)
     },
 
index 3e7aa66704bb9f2223be95843c90ec1ec774dceb..473512e2507f7bf8e71a12ccf6f1eec329c9cc7b 100644 (file)
@@ -4,10 +4,14 @@ function QuizUtils() {
 
 QuizUtils.prototype = {
     isVisible(e) {
-        if ($(e).length == 0) {
+        if ($(e).length === 0) {
+            return false;
+        }
+        if ($(e).css('display') === 'none' || $(e).css('visibility') === 'hidden' || $(e).css('opacity') == 0) {
             return false;
         }
         let elt = $(e).get(0);
+
         return elt.offsetWidth || elt.offsetHeight || elt.getClientRects().length;
     },
     isEnabled: function (e) {
@@ -20,6 +24,7 @@ QuizUtils.prototype = {
         if ($(e).hasClass('disabled') || $(e).closest('.disabled').length > 0) {
             return false;
         }
+        console.log('is enabled', e);
         return true;
     },
 
diff --git a/style/006-animations.sass b/style/006-animations.sass
new file mode 100644 (file)
index 0000000..ef94da6
--- /dev/null
@@ -0,0 +1,2 @@
+.animateOpacity
+    transition: opacity 350ms
index b3a649cc416f1757e550b0b118bc42c2e5a2fd53..cd6f311a09c65dadcfd33409dd58bbebc2c046e1 100644 (file)
@@ -2,6 +2,7 @@
 @import 002-item-variables
 @import 003-reset
 @import 004-mixins
+@import 006-animations
 
 @import 100-global
 @import 101-header-footer
index af8918d090e2945b221eeb887906eb86ca00c9f2..42621598767f0b8ea66b861de87300153ae383f8 100644 (file)
@@ -1,4 +1,4 @@
-<div class="container-screen none" data-screen="review">
+<div class="container-screen none" data-screen="outro">
     @include('header_title', ['data', $data])
     <div class="screen score" id="score">
         <div class="score-content">